sofa::simulation::tree::Simulation Class Reference

Main controller of the scene. More...

#include <Simulation.h>

Inheritance diagram for sofa::simulation::tree::Simulation:

Inheritance graph
[legend]
Collaboration diagram for sofa::simulation::tree::Simulation:

Collaboration graph
[legend]

Public Member Functions

 Simulation ()
virtual ~Simulation ()
virtual void print (Node *root)
 Print all object in the graph.
virtual void printXML (Node *root, const char *fileName=0)
 Print all object in the graph in XML format.
virtual void init (Node *root)
 Initialize the objects.
void getInstruments (Node *node)
 Find the list of nodes called "Instrument" and keep it in the vector instuments.
virtual void animate (Node *root, double dt=0.0)
 Execute one timestep. If dt is 0, the dt parameter in the graph will be used.
virtual void reset (Node *root)
 Reset to initial state.
virtual void initTextures (Node *root)
 Initialize the textures.
virtual void updateContext (Node *root)
 Update contexts. Required before drawing the scene if root flags are modified.
virtual void updateVisualContext (Node *root, int FILTER=10)
 Update contexts. Required before drawing the scene if root flags are modified.
virtual void computeBBox (Node *root, SReal *minBBox, SReal *maxBBox)
 Compute the bounding box of the scene.
virtual void draw (Node *root)
 Render the scene.
virtual void drawShadows (Node *root)
 Render the scene - Shadows pass.
virtual void unload (GNode *root)
 Delete a scene from memory. After this call the pointer is invalid.
virtual void exportOBJ (Node *root, const char *filename, bool exportMTL=true)
 Export a scene to an OBJ 3D Scene.
virtual void exportXML (Node *root, const char *filename)
 Export a scene to XML.
virtual void dumpState (Node *root, std::ofstream &out)
 Dump the current state in the given stream.
virtual void initGnuplot (Node *root)
 Initialize gnuplot export (open files).
virtual void exportGnuplot (Node *root, double time)
 Dump the current state in gnuplot files.

Static Public Member Functions

static GNode * load (const char *filename)
 Load a scene from a file.

Data Fields

Data< unsigned > numMechSteps
 Number of mechanical steps within an animation step.
Data< std::string > gnuplotDirectory
helper::vector< Node * > instruments
Data< int > instrumentInUse

Static Private Member Functions

static GNode * loadFromMemory (const char *filename, const char *data, unsigned int size)
 load a scene from memory (typically : an xml into a string)
static GNode * loadFromFile (const char *filename)
 load a scene from a file
static GNode * processXML (xml::BaseElement *xml, const char *filename)
 generic function to process xml tree (after loading the xml structure from the 2 previous functions)

Detailed Description

Main controller of the scene.

Defines how the scene is inited at the beginning, and updated at each time step. Derives from BaseObject in order to model the parameters as Datas, which makes their edition easy in the GUI.

Definition at line 47 of file Simulation.h.


Constructor & Destructor Documentation

sofa::simulation::tree::Simulation::Simulation (  ) 

Definition at line 215 of file Simulation.cpp.

sofa::simulation::tree::Simulation::~Simulation (  )  [virtual]

Definition at line 221 of file Simulation.cpp.

References sofa::simulation::tree::setSimulation().


Member Function Documentation

void sofa::simulation::tree::Simulation::animate ( Node *  root,
double  dt = 0.0 
) [virtual]

void sofa::simulation::tree::Simulation::computeBBox ( Node *  root,
SReal *  minBBox,
SReal *  maxBBox 
) [virtual]

void sofa::simulation::tree::Simulation::draw ( Node *  root  )  [virtual]

void sofa::simulation::tree::Simulation::drawShadows ( Node *  root  )  [virtual]

void sofa::simulation::tree::Simulation::dumpState ( Node *  root,
std::ofstream &  out 
) [virtual]

Dump the current state in the given stream.

Definition at line 447 of file Simulation.cpp.

References sofa::core::objectmodel::Context::getTime().

Referenced by sofa::gui::qt::RealGUI::loadSimulation(), sofa::gui::qt::RealGUI::step(), and sofa::gui::glut::SimpleGUI::step().

void sofa::simulation::tree::Simulation::exportGnuplot ( Node *  root,
double  time 
) [virtual]

void sofa::simulation::tree::Simulation::exportOBJ ( Node *  root,
const char *  filename,
bool  exportMTL = true 
) [virtual]

Export a scene to an OBJ 3D Scene.

Definition at line 404 of file Simulation.cpp.

References sofa::simulation::Node::execute().

Referenced by sofa::gui::qt::RealGUI::exportOBJ(), sofa::gui::glut::SimpleGUI::exportOBJ(), and main().

void sofa::simulation::tree::Simulation::exportXML ( Node *  root,
const char *  filename 
) [virtual]

Export a scene to XML.

Definition at line 439 of file Simulation.cpp.

References sofa::simulation::Node::execute().

Referenced by main().

void sofa::simulation::tree::Simulation::getInstruments ( Node *  node  ) 

Find the list of nodes called "Instrument" and keep it in the vector instuments.

Definition at line 265 of file Simulation.cpp.

References sofa::simulation::Visitor::execute(), sofa::simulation::Node::execute(), sofa::simulation::InstrumentVisitor::getInstruments(), and instruments.

Referenced by init().

void sofa::simulation::tree::Simulation::init ( Node *  root  )  [virtual]

void sofa::simulation::tree::Simulation::initGnuplot ( Node *  root  )  [virtual]

Initialize gnuplot export (open files).

Initialize gnuplot file output.

Definition at line 455 of file Simulation.cpp.

References sofa::simulation::Node::execute(), sofa::core::objectmodel::Data< T >::getValue(), and gnuplotDirectory.

Referenced by sofa::gui::qt::RealGUI::setExportGnuplot(), and sofa::gui::glut::SimpleGUI::setExportGnuplot().

void sofa::simulation::tree::Simulation::initTextures ( Node *  root  )  [virtual]

GNode * sofa::simulation::tree::Simulation::load ( const char *  filename  )  [static]

Load a scene from a file.

Load a scene.

Static method because at this point, the Simulation component is not yet created. If a Simulation component is found in the graph, then it is used. Otherwise, a default Simulation will be created at the first call to method getSimulation() This file can be a xml file or a script file which will generate a xml tree.

Definition at line 165 of file Simulation.cpp.

References error, sofa::helper::system::PipeProcess::executeProcess(), sofa::helper::system::FileRepository::findFile(), sofa::helper::system::SetDirectory::GetExtension(), loadFromFile(), and loadFromMemory().

Referenced by sofa::gui::qt::RealGUI::fileOpen(), sofa::gui::glut::SimpleGUI::keyPressEvent(), and main().

GNode * sofa::simulation::tree::Simulation::loadFromFile ( const char *  filename  )  [static, private]

load a scene from a file

Load a scene from a file.

Definition at line 150 of file Simulation.cpp.

References processXML().

Referenced by load().

GNode * sofa::simulation::tree::Simulation::loadFromMemory ( const char *  filename,
const char *  data,
unsigned int  size 
) [static, private]

load a scene from memory (typically : an xml into a string)

Load from a string in memory.

Definition at line 134 of file Simulation.cpp.

References processXML().

Referenced by load().

void sofa::simulation::tree::Simulation::print ( Node *  root  )  [virtual]

Print all object in the graph.

Definition at line 226 of file Simulation.cpp.

References sofa::simulation::Node::execute().

Referenced by printXML().

void sofa::simulation::tree::Simulation::printXML ( Node *  root,
const char *  fileName = 0 
) [virtual]

GNode * sofa::simulation::tree::Simulation::processXML ( xml::BaseElement *  xml,
const char *  filename 
) [static, private]

void sofa::simulation::tree::Simulation::reset ( Node *  root  )  [virtual]

Reset to initial state.

Definition at line 321 of file Simulation.cpp.

References sofa::simulation::Node::execute().

Referenced by sofa::gui::qt::RealGUI::resetScene(), and sofa::gui::glut::SimpleGUI::resetScene().

void sofa::simulation::tree::Simulation::unload ( GNode *  root  )  [virtual]

void sofa::simulation::tree::Simulation::updateContext ( Node *  root  )  [virtual]

Update contexts. Required before drawing the scene if root flags are modified.

Definition at line 357 of file Simulation.cpp.

References sofa::simulation::Node::execute().

void sofa::simulation::tree::Simulation::updateVisualContext ( Node *  root,
int  FILTER = 10 
) [virtual]


Field Documentation

Number of mechanical steps within an animation step.

Definition at line 122 of file Simulation.h.

Referenced by animate().


The documentation for this class was generated from the following files:

Generated on Sun Nov 23 04:24:39 2008 for Sofa by  doxygen 1.5.7.1