Foam::autoPtr<Foam::chemistrySolver<CompType, ThermoType> >
Foam::chemistrySolver<CompType, ThermoType>::New
(
    ODEChemistryModel<CompType, ThermoType>& model,
    const word& compTypeName,
    const word& thermoTypeName
)
{
    word modelName(model.lookup("chemistrySolver"));

    word chemistrySolverType =
        modelName + '<' + compTypeName + ',' + thermoTypeName + '>';

    Info<< "Selecting chemistrySolver " << modelName << endl;

    typename dictionaryConstructorTable::iterator cstrIter =
        dictionaryConstructorTablePtr_->find(chemistrySolverType);

    if (cstrIter == dictionaryConstructorTablePtr_->end())
    {
        wordList models = dictionaryConstructorTablePtr_->toc();
        forAll(models, i)
        {
            models[i] = models[i].replace
            (
                '<' + compTypeName + ',' + thermoTypeName + '>',
                ""
            );
        }
std::vector<ResultEntry> DataStore::findAllResultEntries() {
  std::vector<ResultEntry> entries;

  const char *q = "select id, model_name, subject_name, notes, date, value, statistics from result order by date desc";
  sqlite3_stmt *stmt = query(q);

  int rc;
  while((rc = sqlite3_step(stmt)) != SQLITE_DONE) {
    switch(rc) {
      case SQLITE_ROW:
        int id = sqlite3_column_int(stmt, 0);
        std::string modelName(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 1)));
        std::string subjectName(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 2)));
        std::string notes(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 3)));
        std::string date(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 4)));
        double value = sqlite3_column_double(stmt, 5);
        std::string statistics(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 6)));

        entries.push_back(ResultEntry(id, modelName, subjectName, notes, date, value, "", "", statistics));
        break;
    }
  }

  sqlite3_finalize(stmt);

  return entries;
}
ResultEntry DataStore::findResultForIdWithExportdData(int id) {
  const char *q = sqlite3_mprintf("select id, model_name, subject_name, notes, date, value, exported_data, exported_message, statistics from result where id = '%d'", id);
  sqlite3_stmt *stmt = query(q);

  int rc;
  while((rc = sqlite3_step(stmt)) != SQLITE_DONE) {
    switch(rc) {
      case SQLITE_ROW:
        int id = sqlite3_column_int(stmt, 0);
        std::string modelName(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 1)));
        std::string subjectName(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 2)));
        std::string notes(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 3)));
        std::string date(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 4)));
        double value = sqlite3_column_double(stmt, 5);
        std::string exportedData(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 6)));
        std::string exportedMessage(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 7)));
        std::string statistics(reinterpret_cast<char const*>(sqlite3_column_text(stmt, 8)));

        ResultEntry entry = ResultEntry(id, modelName, subjectName, notes, date, value, exportedData, exportedMessage, statistics);

        sqlite3_free((void *) q);
        sqlite3_finalize(stmt);

        return entry;
    }
  }

  throw std::runtime_error("No result for given id");
}
void saveLPOModel( std::ostream & os, const std::shared_ptr<LPOModel> & p ) {
    std::string name = modelName( p );
    if(!name.size())
        throw std::invalid_argument("Failed to save LPOModel!");
    saveString( os, name );
    p->save( os );
}
Beispiel #5
0
int main(int argc, char** argv) {
	if (argc == 3) {
		// ex. "Commander.s3o"
		std::string modelName(argv[1]);
		std::string modelType(argv[2]);

		if (modelType == "--3do") {
			// CModelReader3DO m;
			// m.Load(modelName);
		}

		if (modelType == "--s3o") {
			CModelReaderS3O m;
			m.Load(modelName);
		}
	}

	return 0;
}
Beispiel #6
0
QDomElement ModelPlus::toXmlData(QDomDocument &doc)
{
    QDomElement root = doc.createElement(ModelPlus::className());

    // Project info
    QDomElement cBasic = doc.createElement( "Basic" );
    cBasic.setAttribute( "name", name() );
    cBasic.setAttribute( "modelName", modelName());
    cBasic.setAttribute( "modelType", modelType());
    root.appendChild(cBasic);

    // Infos
    QDomElement cInfos = doc.createElement( "Infos" );
    cInfos.setAttribute("text",infos());
    root.appendChild(cInfos);

    // Variables
    QDomElement cVariables = variables()->toXmlData(doc,"Variables");
    root.appendChild(cVariables);

    return root;
}
Beispiel #7
0
std::vector< std::string > LPO::modelTypes() const{
	std::vector< std::string > r;
	for( auto m: models_ )
		r.push_back( modelName(m) );
	return r;
}
Beispiel #8
0
int main( int argc,
          char* argv[] )
{
    osg::ArgumentParser arguments( &argc, argv );

    arguments.getApplicationUsage()->setApplicationName( arguments.getApplicationName() );
    arguments.getApplicationUsage()->setDescription( arguments.getApplicationName() + " shows a before and after image of the DecimatorOp module, using a default decimation of 0.6." );
    arguments.getApplicationUsage()->setCommandLineUsage( arguments.getApplicationName() + " [options] filename ..." );

    arguments.getApplicationUsage()->addCommandLineOption( "--reducer", "Use ReducerOp. (Use DecimatorOp if neither --reducer nor --shortEdge are specified.)" );
    arguments.getApplicationUsage()->addCommandLineOption( "--shortEdge", "Use ShortEdgeOp. (Use DecimatorOp if neither --reducer nor --shortEdge are specified.)" );
    arguments.getApplicationUsage()->addCommandLineOption( "--percent <n>", "Reduction percentage for DecimatorOp and ShortEdgeOp. <n> is the target percentage of triangles to remain, in the range 0.0 to 1.0. Default 0.6." );
    arguments.getApplicationUsage()->addCommandLineOption( "--maxError <n>", "Maximum error tolerance for DecimatorOp, ReducerOp. Geometry exceeding this tolerance is not reduced. <n> is in the range 0.0 to FLT_MAX. Default 10.0." );
    arguments.getApplicationUsage()->addCommandLineOption( "--respectBoundaries", "Prevents DecimatorOp and ShortEdgeOp from removing boundary edges and polygons. Default False." );
    arguments.getApplicationUsage()->addCommandLineOption( "--minPrimitives <n>", "Minimum primitives in a geometry for DecimatorOp and ShortEdgeOp to consider it for reduction. Default 1." );
    arguments.getApplicationUsage()->addCommandLineOption( "--maxFeature <n>", "Specifies the ShortEdgeOp largest feature size to be removed, measured in model units. Can be combined with --percent to limit the decimation using ShortEdgeOp. Default 0.1" );
    arguments.getApplicationUsage()->addCommandLineOption( "--grpThreshold <n>", "Specifies the ReducderOp group threshold, in degrees. Default is 10.0" );
    arguments.getApplicationUsage()->addCommandLineOption( "--attemptMerge", "Attempt to merge geometry drawables into one using osgUtil::Optimizer::MergeGeometryVisitor before using specified geometry reduction operator." );
    arguments.getApplicationUsage()->addCommandLineOption( "--save", "Attempt to merge geometry drawables into one using Optimizer::MergeGeometryVisitor before using specified geometry reduction operator." );

    if( arguments.read( "-h" ) || arguments.read( "--help" ) )
    {
        arguments.getApplicationUsage()->write( osg::notify( osg::ALWAYS ), osg::ApplicationUsage::COMMAND_LINE_OPTION );
        return 1;
    }


    bool useReducer( arguments.find( "--reducer" ) > 0 );
    bool useShortEdge( arguments.find( "--shortEdge" ) > 0 );
    bool useDecimator( !useReducer && !useShortEdge );

    float percent( .6f );
    arguments.read( "--percent", percent );

    float maxError( 10.f );
    arguments.read( "--maxError", maxError );

    const bool ignoreBoundaries( arguments.read( "--respectBoundaries" ) == 0 );

    int minPrim( 1 );
    arguments.read( "--minPrimitives", minPrim );

    float maxFeature( .1f );
    arguments.read( "--maxFeature", maxFeature );

    float grpThreshold( 10.f );
    arguments.read( "--grpThreshold", grpThreshold );

    bool attemptMerge( arguments.find( "--attemptMerge" ) > 0 );

    bool saveOutput( arguments.find( "--save" ) > 0 );

    osg::Node*  model = osgDB::readNodeFiles( arguments );
    if( model == NULL )
    {
        osg::notify( osg::ALWAYS ) << "Unable to load data file." << std::endl;
        arguments.getApplicationUsage()->write( osg::notify( osg::ALWAYS ), osg::ApplicationUsage::COMMAND_LINE_OPTION );
        return 1;
    }

    osg::ref_ptr<osg::Group> grporig = new osg::Group;
    grporig->addChild(model);
    osg::notify( osg::INFO ) << "geometryop: Loaded model(s)." << std::endl;


    osg::ref_ptr<osg::Group> grpcopy = new osg::Group( *grporig , osg::CopyOp::DEEP_COPY_ALL);
    grpcopy->setName("grpcopy"); // for ease of debugging

    osgwTools::GeometryOperation* reducer;
    if( useDecimator )
    {
        osgwTools::DecimatorOp* decimate = new osgwTools::DecimatorOp;
        decimate->setSampleRatio( percent );
        decimate->setMaximumError( maxError );
        decimate->setIgnoreBoundaries( ignoreBoundaries );
        decimate->setMinPrimitives( minPrim );
        reducer = decimate;
    }
    else if( useShortEdge )
    {
        osgwTools::ShortEdgeOp* seOp = new osgwTools::ShortEdgeOp( percent, maxFeature );
        seOp->setIgnoreBoundaries( ignoreBoundaries );
        seOp->setMinPrimitives( minPrim );
        reducer = seOp;
    }
    else if( useReducer )
    {
        osgwTools::ReducerOp* redOp = new osgwTools::ReducerOp;
        redOp->setGroupThreshold( grpThreshold );
        redOp->setMaxEdgeError( maxError );
        reducer = redOp;
    }

    if( reducer != NULL )
    {
        osgwTools::GeometryModifier modifier( reducer );
        modifier.setDrawableMerge( attemptMerge );
        grpcopy->accept( modifier );
        modifier.displayStatistics( osg::notify( osg::ALWAYS ) );
    }

    if( saveOutput )
    {
        std::string modelName( "reduced.osg" );
        osgDB::writeNodeFile( *grpcopy, modelName );
    }

    //
    // Viewer setup.
    osgViewer::CompositeViewer viewer(arguments);

    osg::GraphicsContext::WindowingSystemInterface* wsi = osg::GraphicsContext::getWindowingSystemInterface();
    if (!wsi)
    {
        osg::notify(osg::NOTICE)<<"Error, no WindowSystemInterface available, cannot create windows."<<std::endl;
        return 1;
    }
    unsigned int width( 800 ), height( 600 );
    const float aspect( (float)width/(float)(height * 2.f) );
    const osg::Matrix proj( osg::Matrix::perspective( 50., aspect, 1., 10. ) );

    // Shared event handlers and state sets.
    osg::ref_ptr< osgGA::TrackballManipulator > tb = new osgGA::TrackballManipulator;

    osg::ref_ptr< osg::StateSet > camSS;
    osg::ref_ptr<osgGA::StateSetManipulator> statesetManipulator = new osgGA::StateSetManipulator;

    osg::ref_ptr<osg::GraphicsContext> gc;

    // view one
    {
        osgViewer::View* view = new osgViewer::View;
        view->setUpViewInWindow( 10, 30, width, height );
        viewer.addView(view);
        view->setSceneData( grporig.get() );

        camSS = view->getCamera()->getOrCreateStateSet();
        statesetManipulator->setStateSet( camSS.get() );
        view->addEventHandler( statesetManipulator.get() );

        view->setCameraManipulator( tb.get() );

        viewer.realize();
        gc = view->getCamera()->getGraphicsContext();
        view->getCamera()->setViewport(new osg::Viewport(0,0, width/2, height));
        view->getCamera()->setProjectionMatrix( proj );
    }

    // view two
    {
        osgViewer::View* view = new osgViewer::View;
        viewer.addView(view);
        view->setSceneData( grpcopy.get() );

        view->getCamera()->setStateSet( camSS.get() );
        view->addEventHandler( statesetManipulator.get() );

        view->setCameraManipulator( tb.get() );

        view->getCamera()->setViewport(new osg::Viewport(width/2,0, width/2, height));
        view->getCamera()->setGraphicsContext(gc.get());
        view->getCamera()->setProjectionMatrix( proj );
    }

    return( viewer.run() );
}