void CArgs_gray::SetCmdLine( int argc, char* argv[] ) { // start log flog = FileOpenOrDie( "HEQLayers.log", "w" ); // log start time time_t t0 = time( NULL ); char atime[32]; strcpy( atime, ctime( &t0 ) ); atime[24] = '\0'; // remove the newline fprintf( flog, "Start: %s ", atime ); // parse command line args if( argc < 3 ) { printf( "Usage: HEQLayers <xml-file> <tag> [options].\n" ); exit( 42 ); } for( int i = 1; i < argc; ++i ) { vector<int> vi; // echo to log fprintf( flog, "%s ", argv[i] ); if( argv[i][0] != '-' ) { if( !infile ) infile = argv[i]; else tag = argv[i]; } else if( GetArg( &zmin, "-zmin=%d", argv[i] ) ) ; else if( GetArg( &zmax, "-zmax=%d", argv[i] ) ) ; else if( GetArg( &pct, "-pct=%lf", argv[i] ) ) ; else if( GetArgList( vi, "-lrbt=", argv[i] ) && vi.size() == 4 ) memcpy( &roi, &vi[0], 4*sizeof(int) ); else { printf( "Did not understand option '%s'.\n", argv[i] ); exit( 42 ); } } fprintf( flog, "\n\n" ); fflush( flog ); }
void CArgs_alnmon::SetCmdLine( int argc, char* argv[] ) { // start log flog = FileOpenOrDie( "cross_lowres.log", "w" ); // log start time time_t t0 = time( NULL ); char atime[32]; strcpy( atime, ctime( &t0 ) ); atime[24] = '\0'; // remove the newline fprintf( flog, "Assemble stack: %s ", atime ); // parse command line args if( argc < 2 ) { printf( "Usage: cross_lowres -z=i,j [options].\n" ); exit( 42 ); } vector<int> vi; for( int i = 1; i < argc; ++i ) { // echo to log fprintf( flog, "%s ", argv[i] ); if( GetArgList( vi, "-z=", argv[i] ) ) { if( 2 == vi.size() ) { zmin = vi[0]; zmax = vi[1]; } else { fprintf( flog, "Bad format in -z [%s].\n", argv[i] ); exit( 42 ); } } else if( IsArg( "-table", argv[i] ) ) table = true; else { printf( "Did not understand option '%s'.\n", argv[i] ); exit( 42 ); } } fprintf( flog, "\n\n" ); fflush( flog ); }
bool CArgs::SetCmdLine( int argc, char* argv[] ) { // Parse command line args vector<int> vi; for( int i = 1; i < argc; ++i ) { if( GetArgStr( tempdir, "-temp=", argv[i] ) ) { printf( "Temp dir: '%s'.\n", tempdir ); GetIDB( tempdir ); } else if( GetArgStr( cachedir, "-cache=", argv[i] ) ) printf( "Cache dir: '%s'.\n", cachedir ); else if( GetArgStr( prior, "-prior=", argv[i] ) ) printf( "Prior solutions: '%s'.\n", prior ); else if( GetArgStr( mode, "-mode=", argv[i] ) ) printf( "Mode: '%s'.\n", mode ); else if( GetArg( &nwks, "-nwks=%d", argv[i] ) ) ; else if( GetArgList( vi, "-zi=", argv[i] ) ) { if( 2 == vi.size() ) { zilo = vi[0]; zihi = vi[1]; printf( "zi [%d %d]\n", zilo, zihi ); } else { printf( "Bad format in -zi [%s].\n", argv[i] ); return false; } } else if( GetArgList( vi, "-zo=", argv[i] ) ) { if( 2 == vi.size() ) { zolo = vi[0]; zohi = vi[1]; printf( "zo [%d %d]\n", zolo, zohi ); } else { printf( "Bad format in -zo [%s].\n", argv[i] ); return false; } } else if( GetArg( &Wr, "-Wr=T,%lf", argv[i] ) ) { regtype = 'T'; printf( "Rglizer Wr: T, %g\n", Wr ); } else if( GetArg( &Wr, "-Wr=R,%lf", argv[i] ) ) { regtype = 'R'; printf( "Rglizer Wr: R, %g\n", Wr ); } else if( GetArg( &Etol, "-Etol=%lf", argv[i] ) ) printf( "Error tol: %g\n", Etol ); else if( GetArg( &iters, "-iters=%d", argv[i] ) ) printf( "Iterations: %d\n", iters ); else if( GetArg( &splitmin, "-splitmin=%d", argv[i] ) ) printf( "Split-min: %d\n", splitmin ); else if( GetArg( &maxthreads, "-maxthreads=%d", argv[i] ) ) printf( "Maxthreads: %d\n", maxthreads ); else if( IsArg( "-untwist", argv[i] ) ) untwist = true; else { printf( "Did not understand option '%s'.\n", argv[i] ); return false; } } return true; }
void CArgs_rgbm::SetCmdLine( int argc, char* argv[] ) { // start log flog = FileOpenOrDie( "RGBMerge.log", "w" ); // log start time time_t t0 = time( NULL ); char atime[32]; strcpy( atime, ctime( &t0 ) ); atime[24] = '\0'; // remove the newline fprintf( flog, "Start: %s ", atime ); // parse command line args if( argc < 4 ) { printf( "Usage: RGBMerge <xml-file> <tag>" " <-[R,G,B]=i,pct> [options].\n" ); exit( 42 ); } for( int i = 1; i < argc; ++i ) { vector<int> vi; // echo to log fprintf( flog, "%s ", argv[i] ); if( argv[i][0] != '-' ) { if( !infile ) infile = argv[i]; else tag = argv[i]; } else if( GetArg( &zmin, "-zmin=%d", argv[i] ) ) ; else if( GetArg( &zmax, "-zmax=%d", argv[i] ) ) ; else if( ScanChan( 0, "-R=%d", argv[i] ) ) ; else if( ScanChan( 1, "-G=%d", argv[i] ) ) ; else if( ScanChan( 2, "-B=%d", argv[i] ) ) ; else if( GetArgStr( span, "-spanRGB=", argv[i] ) ) ; else if( GetArgList( vi, "-lrbt=", argv[i] ) && vi.size() == 4 ) memcpy( &roi, &vi[0], 4*sizeof(int) ); else { printf( "Did not understand option '%s'.\n", argv[i] ); exit( 42 ); } } fprintf( flog, "\n\n" ); fflush( flog ); }
// // Override the abstract Create function to make this // a real class. // Create works its way through the text in the scanner one // line at a time. Each line must contain a command and a set // of arguments. Create examines the command and then calls // on helper functions to do the right things with the arguments. // bool CGLAList::Create() { if (mScan == NULL) { // Quit if there is no scanner return false; } // // Work through the file. // Each line should begin with a command and then be // followed by a set of numeric arguments. // Lexeme* cLex; CSymbol* cSym = NULL; bool finished = false; Start(); while ((cLex = mScan->NextLex())->lex != LEof) { if (cLex->lex == LNewLine || cLex->lex==LSpace) continue; if (cLex->lex == LWord) { // Hope we have a command #ifdef DEBUG eprintf("Word %s ", cLex->sVal); wxLogMessage(gMsgBuff); #endif cSym = gSymTab->LookUpWord(cLex->sVal); // // Now read in the arguments. // int nArg = GetArgList(); #ifdef DEBUG eprintf("Found %d arguments",nArg); wxLogMessage(gMsgBuff); for (int ii = 0; ii < nArg; ++ii) { eprintf(" %f", gArguments[ii]); wxLogMessage(gMsgBuff); } wxLogMessage("\r\n"); #endif if (cSym != NULL) { // // Found a valid command, dispatch a function // to handle it. // #ifdef DEBUG eprintf("matches symbol %d\r\n",cSym->mSym); wxLogMessage(gMsgBuff); #endif switch (cSym->mSym) { case kGLColor: if (nArg >= 3) { GLfloat color[4]; color[0] = gArguments[0]; color[1] = gArguments[1]; color[2] = gArguments[2]; if (nArg > 3) { color[3] = gArguments[3]; } else { color[3] = 1.0f; } glMaterialfv(GL_FRONT, GL_AMBIENT, color); glMaterialfv(GL_FRONT, GL_SPECULAR, color); glColor3fv(color); } break; case kGLPoint: if (nArg >= 3) { glBegin(GL_POINTS); glVertex3fv(gArguments); glEnd(); mBounds->AddPoint3fv(&gArguments[0]); } break; case kGLTranslate: if (nArg >= 3) { glTranslatef(gArguments[0],gArguments[1],gArguments[2]); } break; case kGLLine: BuildLine(nArg); break; case kGLPolyLine: BuildPolyLine(nArg); break; case kGLSphere: BuildSphere(nArg); break; case kGLBox: BuildBox(nArg); break; case kGLTriangle: BuildTriangle(nArg); break; case kGLCylinder: BuildCylinder(nArg); break; case kGLCap: BuildCap(nArg); break; case kGLEnd: finished = true; break; default: eprintf("CGLAList.Create: Unimplemented GLA verb %s.\r\n", cSym->mName); break; } } else { eprintf("CGLAList.Create: %s is an unrecognised GLA verb.\r\n", cLex->sVal); } } else { // Did not find a command // // Print a message. // eprintf("CGLAList.Create: Cound not find a command on line %lu.\r\n", mScan->LineNumber()); eprintf("%s", mScan->GetLine()); } if (finished) break; // // Eat tokens til we get to the // end of the line (or a premature EOF) // while ((cLex = mScan->NextLex())->lex != LNewLine && cLex->lex != LEof); } // end while End(); ReleaseScanner(); return true; }