Пример #1
0
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);
    }
}
Пример #2
0
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);
    }
}