// computes bbox of an OFF object. #include #include #include #include #include #include #include #include #include using namespace std; bool verbose = false; bool unitcube = false; // main function with standard unix commandline arguments // ------------------------------------------------------ int main( int argc, char **argv) { int n = 0; // number of filenames char *filename[1] = { NULL }; // stop compiler warning (too hard to rewrite the code to avoid it) bool help = false; for (int i = 1; i < argc; i++) { // check commandline options if ( strcmp( "-v", argv[i]) == 0) verbose = true; else if ( strcmp( "-unit", argv[i]) == 0) unitcube = true; else if ( (strcmp( "-h", argv[i]) == 0) || (strcmp( "-help", argv[i]) == 0)) help = true; else if ( n < 1 ) { filename[ n++] = argv[i]; } else { n++; break; } } if ((n > 1) || help) { if ( ! help) cerr << "Error: in parameter list" << endl; cerr << "Usage: " << argv[0] << " [] [ []]" << endl; cerr << "Usage: " << argv[0] << " [] []" << endl; cerr << " computes the bbox of the coordinates of an OFF object." << endl; cerr << " -unit prints transformation to unit cube." << endl; cerr << " (can be used with 'off_transform')" << endl; cerr << " -v verbose." << endl; exit( ! help); } CGAL::Verbose_ostream verr( verbose); verr << argv[0] << ": verbosity on." << endl; const char* name = "cin"; istream* p_in = &cin; ifstream in; if ( n > 0) { in.open( filename[0]); p_in = ∈ name = filename[0]; } if ( ! * p_in) { cerr << argv[0] << ": error: cannot open file '"<< name << "' for reading." < 0 && 2/d < s) s = 2/d; d = bbox.ymax() - bbox.ymin(); if ( d > 0 && 2/d < s) s = 2/d; d = bbox.zmax() - bbox.zmin(); if ( d > 0 && 2/d < s) s = 2/d; if ( s == DBL_MAX) s = 1; cout << "-trans " << (-(bbox.xmin() + bbox.xmax())/2) << " " << (-(bbox.ymin() + bbox.ymax())/2) << " " << (-(bbox.zmin() + bbox.zmax())/2) << " -scale " << s << endl; } return 0; } // EOF //