本文整理汇总了C++中Trajectory::readTrajectory方法的典型用法代码示例。如果您正苦于以下问题:C++ Trajectory::readTrajectory方法的具体用法?C++ Trajectory::readTrajectory怎么用?C++ Trajectory::readTrajectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Trajectory
的用法示例。
在下文中一共展示了Trajectory::readTrajectory方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readState
/**
This method is used to read the state parameters from a file
*/
void SimBiConState::readState(FILE* f, int offset){
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];
Trajectory* tempTraj;
//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_STATE_END:
//we're done...
return;
break;
case CON_NEXT_STATE:
if (sscanf(line, "%d", &this->nextStateIndex) != 1)
throwError("An index must be specified when using the \'nextState\' keyword");
this->nextStateIndex += offset;
break;
case CON_STATE_DESCRIPTION:
strcpy(this->description, trim(line));
break;
case CON_STATE_TIME:
if (sscanf(line, "%lf", &stateTime)!=1)
throwError("The time that is expected to be spent in this state needs to be provided.");
break;
case CON_STATE_STANCE:
reverseStance = false;
keepStance = false;
if (strncmp(trim(line), "left",4) == 0)
stateStance = LEFT_STANCE;
else
if (strncmp(trim(line), "right", 5) == 0)
stateStance = RIGHT_STANCE;
else
if (strncmp(trim(line), "reverse", 7) == 0)
reverseStance = true;
else if (strncmp(trim(line), "same", 4) == 0)
keepStance = true;
else
throwError("When using the \'stateStance\' keyword, \'left\', \'right\' or \'reverse\' must be specified.");
break;
case CON_TRANSITION_ON:
transitionOnFootContact = false;
if (strncmp(trim(line), "footDown", 8) == 0)
transitionOnFootContact = true;
else
if (strncmp(trim(line), "timeUp", 6) == 0)
//nothn' to do, since this is the default
;
else
throwError("When using the \'transitionOn\' keyword, \'footDown\' or \'timeUp\' must be specified.");
break;
case CON_TRAJECTORY_START:
//create a new trajectory, and read its information from the file
tempTraj = new Trajectory();
strcpy(tempTraj->jName, trim(line));
tempTraj->readTrajectory(f);
this->sTraj.push_back(tempTraj);
break;
case CON_D_TRAJX_START:
if( dTrajX != NULL )
throwError( "Two dTrajX trajectory, this is illegal!" );
dTrajX = new Trajectory1D();
readTrajectory1D( f, *dTrajX, CON_D_TRAJX_END );
break;
case CON_D_TRAJZ_START:
if( dTrajZ != NULL )
throwError( "Two dTrajZ trajectory, this is illegal!" );
dTrajZ = new Trajectory1D();
readTrajectory1D( f, *dTrajZ, CON_D_TRAJZ_END );
break;
case CON_V_TRAJX_START:
if( vTrajX != NULL )
throwError( "Two vTrajX trajectory, this is illegal!" );
vTrajX = new Trajectory1D();
readTrajectory1D( f, *vTrajX, CON_V_TRAJX_END );
break;
case CON_V_TRAJZ_START:
if( vTrajZ != NULL )
throwError( "Two vTrajZ trajectory, this is illegal!" );
vTrajZ = new Trajectory1D();
readTrajectory1D( f, *vTrajZ, CON_V_TRAJZ_END );
break;
//.........这里部分代码省略.........
示例2: readState
/**
This method is used to read the state parameters from a file
*/
void SimBiConState::readState(FILE* f, int offset){
//have a temporary buffer used to read the file line by line...
char buffer[200];
Trajectory* tempTraj;
//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_STATE_END:
//we're done...
return;
break;
case CON_NEXT_STATE:
if (sscanf(line, "%d", &this->nextStateIndex) != 1)
return;
this->nextStateIndex += offset;
break;
case CON_STATE_DESCRIPTION:
strcpy(this->description, trim(line));
break;
case CON_STATE_TIME:
if (sscanf(line, "%lf", &stateTime)!=1)
return;
break;
case CON_STATE_STANCE:
reverseStance = false;
keepStance = false;
if (strncmp(trim(line), "left",4) == 0)
stateStance = LEFT_STANCE;
else
if (strncmp(trim(line), "right", 5) == 0)
stateStance = RIGHT_STANCE;
else
if (strncmp(trim(line), "reverse", 7) == 0)
reverseStance = true;
else if (strncmp(trim(line), "same", 4) == 0)
keepStance = true;
else
return;
break;
case CON_TRANSITION_ON:
transitionOnFootContact = false;
if (strncmp(trim(line), "footDown", 8) == 0)
transitionOnFootContact = true;
else
if (strncmp(trim(line), "timeUp", 6) == 0)
//nothn' to do, since this is the default
;
else
return;
break;
case CON_TRAJECTORY_START:
//create a new trajectory, and read its information from the file
tempTraj = new Trajectory();
strcpy(tempTraj->jName, trim(line));
tempTraj->readTrajectory(f);
this->sTraj.push_back(tempTraj);
break;
case CON_D_TRAJX_START:
if( dTrajX != NULL )
return;
dTrajX = new Trajectory1D();
readTrajectory1D( f, *dTrajX, CON_D_TRAJX_END );
break;
case CON_D_TRAJZ_START:
if( dTrajZ != NULL )
return;
dTrajZ = new Trajectory1D();
readTrajectory1D( f, *dTrajZ, CON_D_TRAJZ_END );
break;
case CON_V_TRAJX_START:
if( vTrajX != NULL )
return;
vTrajX = new Trajectory1D();
readTrajectory1D( f, *vTrajX, CON_V_TRAJX_END );
break;
case CON_V_TRAJZ_START:
if( vTrajZ != NULL )
return;
vTrajZ = new Trajectory1D();
readTrajectory1D( f, *vTrajZ, CON_V_TRAJZ_END );
break;
case CON_COMMENT:
break;
//.........这里部分代码省略.........