void TwoDSceneXMLParser::loadSceneFromXML( const std::string& filename, TwoDScene& twodscene, SceneStepper** scenestepper, scalar& dt, scalar& max_t, scalar& maxfreq, std::vector<renderingutils::Color>& particle_colors, std::vector<renderingutils::Color>& edge_colors, std::vector<renderingutils::ParticlePath>& particle_paths, renderingutils::Color& bgcolor, std::string& description, std::string& scenetag, TwoDimensionalDisplayController& display) { assert( *scenestepper == NULL ); //std::cout << "Loading scene: " << filename << std::endl; // Load the xml document std::vector<char> xmlchars; rapidxml::xml_document<> doc; loadXMLFile( filename, xmlchars, doc ); // Attempt to locate the root node rapidxml::xml_node<>* node = doc.first_node("scene"); if( node == NULL ) { std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse xml scene file. Failed to locate root <scene> node. Exiting." << std::endl; exit(1); } // TODO: Clear old state // Camera loadCameraLocation(node, display); // Scene loadParticles( node, twodscene ); loadEdges( node, twodscene ); loadSceneTag( node, scenetag ); // Forces loadSpringForces( node, twodscene ); loadSimpleGravityForces( node, twodscene ); loadGravitationalForces( node, twodscene ); loadDragDampingForces( node, twodscene ); loadVorexForces( node, twodscene ); // Integrator/solver loadIntegrator( node, scenestepper, dt ); loadMaxTime( node, max_t ); // UI loadMaxSimFrequency( node, maxfreq ); // Rendering state particle_colors.resize(twodscene.getNumParticles(),renderingutils::Color(0.650980392156863,0.294117647058824,0.0)); loadParticleColors( node, particle_colors ); edge_colors.resize(twodscene.getNumEdges(),renderingutils::Color(0.0,0.388235294117647,0.388235294117647)); loadEdgeColors( node, edge_colors ); loadBackgroundColor( node, bgcolor ); loadParticlePaths( node, dt, particle_paths ); std::string description_string; loadSceneDescriptionString( node, description ); }
void StableFluidsSimXMLParser::loadExecutableSimulation( const std::string& file_name, scalar& max_time, int& velocity_pattern, std::string& description, std::string& scenetag, scalar &diff, scalar &visc ) { // Load the xml document std::vector<char> xmlchars; rapidxml::xml_document<> doc; loadXMLFile( file_name, xmlchars, doc ); // Attempt to locate the root node rapidxml::xml_node<>* node = doc.first_node("scene"); if( node == NULL ) { std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Failed to parse xml scene file. Failed to locate root <scene> node. Exiting." << std::endl; exit(1); } // Determine what simulation type this is (particle, rigid body, etc) std::string simtype; loadSimulationType( node, simtype ); // Parse common state loadMaxTime( node, max_time ); loadSceneDescriptionString( node, description ); loadSceneTag( node, scenetag ); // Parse the user-requested simulation type. The default is a particle simulation. if( simtype == "stable-fluids" ) { loadVelocityPattern( node, velocity_pattern ); loadDiffusion( node, diff ); loadViscosity( node, visc ); } else { std::cerr << "\033[31;1mERROR IN XMLSCENEPARSER:\033[m Invalid simtype '" << simtype << "' specified. Valid options are 'particle-system' and 'rigid-body'. Exiting." << std::endl; exit(1); } }