--- trunk/tcProps/readWrite.c 2004/02/16 20:35:58 1054 +++ trunk/tcProps/readWrite.c 2004/02/16 21:50:34 1055 @@ -46,6 +46,7 @@ int setFrames( char* inFile ){ struct linkedPos* currPos; fpos_t *currPT; char readBuffer[BUFFER_SIZE]; + char trash[BUFFER_SIZE]; char* foo; int lineNum = 0; @@ -61,6 +62,7 @@ int setFrames( char* inFile ){ headPos = (struct linkedPos*)malloc(sizeof(struct linkedPos)); + currPos = headPos; while( !feof( inFile ) ){ currPT = (fpos_t *)malloc(sizeof(fpos_t)); @@ -76,9 +78,139 @@ int setFrames( char* inFile ){ exit(0); } + currPos->next = (struct linkedPos*)malloc(sizeof(struct linkedPos)); + currPos = currPos->next; + currPos->myPos = currPT; + nFrames++; + i = atoi(readBuffer); + + fgets( readBuffer, sizeof( readBuffer ), inFile ); + lineNum++; + if( feof( inFile ) ){ + fprintf( stderr, + "File \"%s\" ended unexpectedly at line %d\n", + inName, + lineNum ); + exit(0); + } + // parse the comment line + + foo = strtok(readBuffer, " ,;\t"); + + if(foo == NULL){ + fprintf(stderr, + "error in reading time from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->timeStamp = atof( foo ); + + // get the Hx vector + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hx[0] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[0][0] = atof( foo ); + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hx[1] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[1][0] = atof( foo ); + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hx[2] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[2][0] = atof( foo ); + + // get the Hy vector + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hy[0] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[0][1] = atof( foo ); + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hy[1] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[1][1] = atof( foo ); + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hy[2] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[2][1] = atof( foo ); + + // get the Hz vector + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hz[0] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[0][2] = atof( foo ); + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hz[1] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[1][2] = atof( foo ); + + foo = strtok(NULL, " ,;\t"); + if(foo == NULL){ + fprintf(stderr, + "error in reading Hz[2] from %s at line %d\n", + inName, lineNum ); + exit(0); + } + currPos->Hmat[2][2] = atof( foo ); + + // skip the atoms + + for(j=0; j