void parseCommandLine( int argc, char** argv ) { osgGIS::Registry* registry = osgGIS::Registry::instance(); osg::ArgumentParser arguments( &argc, argv ); std::string str; // the input vector file that we will compile: while( arguments.read( "--input", input_file ) ); // terrain: while( arguments.read( "--terrain", terrain_file ) ); // Color of the output geometry: while( arguments.read( "--color", str ) ) sscanf( str.c_str(), "%f,%f,%f,%f", &color.x(), &color.y(), &color.z(), &color.a() ); while( arguments.read( "--random-colors" ) ) color.a() = 0.0; //while( arguments.read( "--buffer", str ) ) // sscanf( str.c_str(), "%f", &buffer ); // validate arguments: if ( input_file.empty() ) //|| terrain_file.empty() ) { arguments.getApplicationUsage()->write( std::cout, osg::ApplicationUsage::COMMAND_LINE_OPTION ); exit(-1); } }
void parseCommandLine( int argc, char** argv ) { osgGIS::Registry* registry = osgGIS::Registry::instance(); osg::ArgumentParser arguments( &argc, argv ); arguments.getApplicationUsage()->setApplicationName( arguments.getApplicationName() ); arguments.getApplicationUsage()->setDescription( arguments.getApplicationName() + " clamps vector data to a terrain dataset." ); arguments.getApplicationUsage()->setCommandLineUsage( arguments.getApplicationName() + " [--input vector_file [options..]"); arguments.getApplicationUsage()->addCommandLineOption( "-h or --help", "Display all available command line paramters"); // request for help: if ( arguments.read( "-h" ) || arguments.read( "--help" ) ) { usage( arguments.getApplicationName().c_str(), 0 ); exit(-1); } std::string str; // the input vector file that we will compile: while( arguments.read( "--input", input_file ) ); // output file for vector geometry: while( arguments.read( "--output", output_file ) ); // Color of the output geometry: while( arguments.read( "--color", str ) ) sscanf( str.c_str(), "%f,%f,%f,%f", &color.x(), &color.y(), &color.z(), &color.a() ); while( arguments.read( "--random-colors" ) ) color.a() = 0.0; while( arguments.read( "--fade-lods" ) ) fade_lods = true; while( arguments.read( "--buffer", str ) ) sscanf( str.c_str(), "%f", &buffer ); // validate arguments: if ( input_file.length() == 0 ) { arguments.getApplicationUsage()->write( std::cout, osg::ApplicationUsage::COMMAND_LINE_OPTION ); exit(-1); } }
osgGIS::FilterGraph* createFilterGraph() { osgGIS::Registry* registry = osgGIS::Registry::instance(); // The FilterGraph is a series of filters that will transform the GIS // feature data into a scene graph. osgGIS::FilterGraph* graph = new osgGIS::FilterGraph(); // Buffer if necessary: if ( buffer != 0.0f ) graph->appendFilter( new osgGIS::BufferFilter( buffer ) ); // Construct osg::Drawable's from the incoming feature batches: osgGIS::BuildGeomFilter* gf = new osgGIS::BuildGeomFilter(); gf->setColor( color ); if ( color.a() == 0 ) gf->setColorScript( new osgGIS::Script( "vec4(math.random(),math.random(),math.random(),1)" ) ); //gf->setRandomizeColors( color.a() == 0 ); graph->appendFilter( gf ); // Bring all the drawables into a single collection so that they // all fall under the same osg::Geode. graph->appendFilter( new osgGIS::CollectionFilter() ); // Construct a Node that contains the drawables and adjust its state set. osgGIS::BuildNodesFilter* bnf = new osgGIS::BuildNodesFilter(); //bnf->setDisableLighting( true ); bnf->setAlphaBlending( true ); bnf->setOptimize( false ); graph->appendFilter( bnf ); return graph; }