/** This method is used to read a trajectory from a file */ void Trajectory::readTrajectory(FILE* f){ if (f == NULL) throwError("File pointer is NULL - cannot read gain coefficients!!"); //have a temporary buffer used to read the file line by line... char buffer[200]; TrajectoryComponent* newComponent; //this is where it happens. while (!feof(f)){ //get a line from the file... fgets(buffer, 200, f); if (strlen(buffer)>195) throwError("The input file contains a line that is longer than ~200 characters - not allowed"); char *line = lTrim(buffer); int lineType = getConLineType(line); switch (lineType) { case CON_STRENGTH_TRAJECTORY_START: //read in the base trajectory if( strengthTraj != NULL ) throwError( "Two strength trajectory, this is illegal!" ); strengthTraj = new Trajectory1D(); SimBiConState::readTrajectory1D(f, *strengthTraj, CON_STRENGTH_TRAJECTORY_END ); break; case CON_TRAJECTORY_END: //we're done... return; break; case CON_CHAR_FRAME_RELATIVE: relToCharFrame = true; break; case CON_COMMENT: break; case CON_TRAJ_COMPONENT: //read in the base trajectory newComponent = new TrajectoryComponent(); newComponent->readTrajectoryComponent(f); components.push_back(newComponent); break; case CON_NOT_IMPORTANT: tprintf("Ignoring input line: \'%s\'\n", line); break; default: throwError("Incorrect SIMBICON input file: \'%s\' - unexpected line.", buffer); } } throwError("Incorrect SIMBICON input file: No \'/trajectory\' found ", buffer); }
/** This method is used to read a trajectory from a file */ void Trajectory::readTrajectory(FILE* f){ //have a temporary buffer used to read the file line by line... char buffer[200]; TrajectoryComponent* newComponent; //this is where it happens. while (!feof(f)){ //get a line from the file... fgets(buffer, 200, f); char *line = lTrim(buffer); int lineType = getConLineType(line); switch (lineType) { case CON_STRENGTH_TRAJECTORY_START: //read in the base trajectory if( strengthTraj != NULL ) return; strengthTraj = new Trajectory1D(); SimBiConState::readTrajectory1D(f, *strengthTraj, CON_STRENGTH_TRAJECTORY_END ); break; case CON_TRAJECTORY_END: //we're done... return; break; case CON_CHAR_FRAME_RELATIVE: relToCharFrame = true; break; case CON_COMMENT: break; case CON_TRAJ_COMPONENT: //read in the base trajectory newComponent = new TrajectoryComponent(); newComponent->readTrajectoryComponent(f); components.push_back(newComponent); break; case CON_NOT_IMPORTANT: break; default: return; } } return; }