--- trunk/SHAPES/SHAPE.cpp 2004/06/23 20:53:17 1290 +++ trunk/SHAPES/SHAPE.cpp 2004/06/24 15:56:05 1299 @@ -35,23 +35,21 @@ void SHAPE::readSHAPEfile(const char *fname) { printf("Could not open SHAPE file %s\n", fname); exit(-1); } - rewind(shapeFile); - lineNum = 0; + + findBegin( "ShapeInfo" ); + eof_test = fgets( readLine, sizeof(readLine), shapeFile ); - lineNum++; - if( eof_test == NULL ){ - printf("Error in reading SHAPE from SHAPE file at line %d.\n", - lineNum ); - exit(-1); - } - // first find the shape name: + while( eof_test != NULL ){ // toss comment lines if( readLine[0] != '!' && readLine[0] != '#' ){ + + foo = strtok(readLine, " ,;\t"); + if (!strcasecmp(foo, "end")) break; nTokens = count_tokens(readLine, " ,;\t"); if (nTokens < 5) { - printf("Not enough data on information line in SHAPE file.\n"); + printf("Not enough data on shapeInfo line in SHAPE file.\n"); exit(-1); } @@ -68,7 +66,6 @@ void SHAPE::readSHAPEfile(const char *fname) { break; } eof_test = fgets( readLine, sizeof(readLine), shapeFile ); - lineNum++; } findBegin( "ContactFunctions" ); @@ -257,4 +254,45 @@ int SHAPE::count_tokens(char *line, char *delimiters) free(working_line); return(ntokens); +} + + +double SHAPE::getSigmaAt(double costheta, double phi) { + + vector::iterator sigmaIter; + double sigma; + + sigma = 0.0; + + for(sigmaIter = sigmaFuncs.begin(); sigmaIter != sigmaFuncs.end(); + ++sigmaIter) + sigma += (*sigmaIter)->getValueAt(costheta, phi); + + return sigma; } + +double SHAPE::getSAt(double costheta, double phi) { + + vector::iterator sIter; + double s; + + s = 0.0; + + for(sIter = sFuncs.begin(); sIter != sFuncs.end(); ++sIter) + s += (*sIter)->getValueAt(costheta, phi); + + return s; +} + +double SHAPE::getEpsAt(double costheta, double phi) { + + vector::iterator epsIter; + double eps; + + eps = 0.0; + + for(epsIter = epsFuncs.begin(); epsIter != epsFuncs.end(); ++epsIter) + eps += (*epsIter)->getValueAt(costheta, phi); + + return eps; +}