29 #include "application.h"
33 #pragma warning( disable: 4275 )
34 #include <boost/program_options.hpp>
35 #pragma warning( default: 4275 )
41 namespace po = boost::program_options;
45 bool Application::init(
const int argc,
char** argv )
47 const eq::Strings& models = _parseArguments( argc, argv );
55 bool Application::run()
71 co::Object* Application::createObject(
const uint32_t type )
79 return seq::Application::createObject( type );
85 static bool _isPlyfile(
const std::string& filename )
87 const size_t size = filename.length();
91 if( filename[size-4] !=
'.' || filename[size-3] !=
'p' ||
92 filename[size-2] !=
'l' || filename[size-1] !=
'y' )
100 eq::Strings Application::_parseArguments(
const int argc,
char** argv )
102 std::string userDefinedModelPath(
"");
106 po::options_description options(
107 std::string(
"seqPly - Sequel polygonal rendering example ")
109 bool showHelp(
false);
111 options.add_options()
112 (
"help,h", po::bool_switch(&showHelp)->default_value(
false),
113 "produce help message" )
114 (
"model,m", po::value<std::string>(&userDefinedModelPath),
115 "ply model file name" );
118 po::variables_map variableMap;
119 po::store( po::command_line_parser( argc, argv ).options(
120 options ).allow_unregistered().run(),
122 po::notify( variableMap );
127 LBWARN << options << std::endl;
131 catch( std::exception& exception )
133 LBERROR <<
"Error parsing command line: " << exception.what()
138 eq::Strings filenames;
139 filenames.push_back( lunchbox::getExecutablePath() +
140 "/../share/Equalizer/data" );
142 if( !userDefinedModelPath.empty( ))
145 filenames.push_back( userDefinedModelPath );
150 void Application::_loadModel(
const eq::Strings& models )
152 eq::Strings files = models;
153 while( !files.empty( ))
155 const std::string filename = files.back();
158 if( _isPlyfile( filename ))
161 if( _model->readFromFile( filename.c_str( )))
163 _modelDist =
new ModelDist( _model );
164 _modelDist->registerTree(
this );
165 _frameData.setModelID( _modelDist->getID( ));
173 const std::string basename = lunchbox::getFilename( filename );
174 if( basename ==
"." || basename ==
".." )
178 const eq::Strings subFiles = lunchbox::searchDirectory( filename,
180 for(eq::StringsCIter i = subFiles.begin(); i != subFiles.end(); ++i)
181 files.push_back( filename +
'/' + *i );
186 void Application::_unloadModel()
191 _modelDist->deregisterTree();
199 const Model* Application::getModel(
const eq::uint128_t& modelID )
205 lunchbox::memoryBarrier();
208 lunchbox::ScopedMutex<> mutex( _modelLock );
212 LBASSERT( !_modelDist );
213 _modelDist =
new ModelDist;
214 Model* model = _modelDist->loadModel(
getMasterNode(),
this, modelID );
virtual SEQ_API bool exit()
Exit this application instance.
virtual SEQ_API bool run(co::Object *frameData)
Run the application main loop.
static std::string getString()
virtual seq::Renderer * createRenderer()
Create a new renderer instance.
The object passed to Application::run()
SEQ_API co::NodePtr getMasterNode()
virtual bool exit()
Exit this application instance.
virtual SEQ_API bool init(const int argc, char **argv, co::Object *initData)
Initialize the application instance.