29 #include "application.h"
36 #include <tclap/CmdLine.h>
41 bool Application::init(
const int argc,
char** argv )
43 const eq::Strings& models = _parseArguments( argc, argv );
51 bool Application::run()
67 co::Object* Application::createObject(
const uint32_t type )
75 return seq::Application::createObject( type );
81 static bool _isPlyfile(
const std::string& filename )
83 const size_t size = filename.length();
87 if( filename[size-4] !=
'.' || filename[size-3] !=
'p' ||
88 filename[size-2] !=
'l' || filename[size-1] !=
'y' )
96 eq::Strings Application::_parseArguments(
const int argc,
char** argv )
98 TCLAP::CmdLine command(
"seqPly - Sequel polygonal rendering example",
' ',
100 TCLAP::ValueArg<std::string> modelArg(
"m",
"model",
"ply model file name",
101 false,
"",
"string", command );
102 TCLAP::UnlabeledMultiArg< std::string >
103 ignoreArgs(
"ignore",
"Ignored unlabeled arguments",
false,
"any",
106 #ifdef TCPLAP_HAS_IGNOREUNMATCHED
107 command.ignoreUnmatched(
true );
109 command.parse( argc, argv );
111 eq::Strings filenames;
113 # ifdef _WIN32 // final INSTALL_DIR is not known at compile time
114 filenames.push_back(
"../share/Equalizer/data" );
116 filenames.push_back( std::string( EQ_INSTALL_DIR ) +
117 std::string(
"share/Equalizer/data" ));
118 filenames.push_back( std::string(
"/usr/share/Equalizer/data" ));
121 filenames.push_back( std::string( EQ_SOURCE_DIR ) +
122 std::string(
"examples/eqPly" ));
125 if( modelArg.isSet( ))
128 filenames.push_back( modelArg.getValue( ));
133 void Application::_loadModel(
const eq::Strings& models )
135 eq::Strings files = models;
136 while( !files.empty( ))
138 const std::string filename = files.back();
141 if( _isPlyfile( filename ))
144 if( _model->readFromFile( filename.c_str( )))
146 _modelDist =
new ModelDist( _model );
147 _modelDist->registerTree(
this );
148 _frameData.setModelID( _modelDist->getID( ));
156 const std::string basename = lunchbox::getFilename( filename );
157 if( basename ==
"." || basename ==
".." )
161 const eq::Strings subFiles = lunchbox::searchDirectory( filename,
163 for(eq::StringsCIter i = subFiles.begin(); i != subFiles.end(); ++i)
164 files.push_back( filename +
'/' + *i );
169 void Application::_unloadModel()
174 _modelDist->deregisterTree();
182 const Model* Application::getModel(
const eq::uint128_t& modelID )
188 lunchbox::memoryBarrier();
191 lunchbox::ScopedMutex<> mutex( _modelLock );
195 LBASSERT( !_modelDist );
196 _modelDist =
new ModelDist;
197 Model* model = _modelDist->loadModel(
getMasterNode(),
this, modelID );
virtual bool exit()
Exit this application instance.
virtual bool init(const int argc, char **argv, co::Object *initData)
Initialize the application instance.
static std::string getString()
co::NodePtr getMasterNode()
virtual bool exit()
Exit this application instance.
virtual bool run(co::Object *frameData)
Run the application main loop.
virtual seq::Renderer * createRenderer()
Create a new renderer instance.
The object passed to Application::run()