27 #ifndef SIMULATOR_SIMULATORS_SOFA_SOFASIMULATOR_H
28 #define SIMULATOR_SIMULATORS_SOFA_SOFASIMULATOR_H
32 #include <sofa/simulation/tree/TreeSimulation.h>
33 #include <sofa/component/container/MechanicalObject.h>
34 #include <sofa/defaulttype/VecTypes.h>
35 #include <sofa/simulation/common/Node.h>
36 #include <sofa/simulation/tree/GNode.h>
39 #define SofaVector sofa::helper::vector
51 typedef map <unsigned int, MechanicalObjectDOFIndex>
AtomDOFMap;
83 void getForce(
int index,
double force[3]);
86 void createPml(
const char* inputFile,
const char* pmlFile);
93 sofa::simulation::Node* getGNode();
102 sofa::defaulttype::Vec3Types::Coord getDOFPosition(
unsigned int atomIndex);
105 sofa::defaulttype::Vec3Types::Coord getDOFPosition(
unsigned int mechObjectIndex,
unsigned int dofIndex);
108 sofa::defaulttype::Vec3Types::Deriv getDOFForce(
unsigned int atomIndex);
111 sofa::defaulttype::Vec3Types::Deriv getDOFForce(
unsigned int mechObjectIndex,
unsigned int dofIndex);
114 unsigned int getAtomIndex(
unsigned int mechObjectIndex,
unsigned int dofIndex);
117 sofa::component::container::MechanicalObject<sofa::defaulttype::Vec3Types>* getMechanicalObject(
unsigned int mechObjectIndex);
120 unsigned int getNumberOfMechanicalObjects();
123 sofa::defaulttype::Vec3Types::VecCoord getMechanicalObjectDOFPosition(
unsigned int mechObjectIndex);
126 sofa::defaulttype::Vec3Types::VecDeriv getMechanicalObjectDOFForce(
unsigned int mechObjectIndex);
132 void buildConstraints();
135 #if defined(SOFA_1_0_RC1) || defined(SOFA_SVN) || defined(SOFA_STABLE)
136 sofa::simulation::Node::SPtr groot;
139 #ifdef MML_SOFA_1_0_BETA4
140 sofa::simulation::Node* groot;
144 SofaVector<BaseMechanicalState*> mechanicalObjects;
150 std::vector<std::MechanicalObjectAtomDOFMap*> mechanicalObjectAtomDOFMap;
153 std::vector<std::MechanicalObjectDOFAtomMap*> mechanicalObjectDOFAtomMap;
156 std::vector<TranslationConstraint<sofa::defaulttype::Vec3Types> *> translations;
163 inline sofa::simulation::Node* SofaSimulator::getGNode() {
164 if (groot ==
nullptr) {
168 #if defined(SOFA_1_0_RC1) || defined(SOFA_SVN) || defined(SOFA_STABLE)
172 #ifdef MML_SOFA_1_0_BETA4
178 inline unsigned int SofaSimulator::getNumberOfMechanicalObjects() {
179 return mechanicalObjects.size();
184 return (*mechanicalObjectAtomDOFMap[mechObjectIndex]);
189 return (*mechanicalObjectDOFAtomMap[mechObjectIndex]);
193 inline sofa::defaulttype::Vec3Types::VecCoord SofaSimulator::getMechanicalObjectDOFPosition(
unsigned int mechObjectIndex) {
194 return (*getMechanicalObject(mechObjectIndex)->getX());
198 inline sofa::defaulttype::Vec3Types::VecDeriv SofaSimulator::getMechanicalObjectDOFForce(
unsigned int mechObjectIndex) {
199 return (*getMechanicalObject(mechObjectIndex)->getF());
pair< unsigned int, unsigned int > MechanicalObjectDOFIndex
definition of a couple (=STL pair) [unsigned int mecObjectIndex, unsigned int dofIndex]
Definition: SofaSimulator.h:47
map< unsigned int, unsigned int > MechanicalObjectAtomDOFMap
there is one MechanicalObjectAtomDOFMap per Mechanical Object: this is a map where first is the atom ...
Definition: SofaSimulator.h:55
map< unsigned int, unsigned int > MechanicalObjectDOFAtomMap
there is one MechanicalObjectDOFAtomMap per Mechanical Object: this is a map where first is the DOF i...
Definition: SofaSimulator.h:59
map< unsigned int, MechanicalObjectDOFIndex > AtomDOFMap
definition of the association set (=map in STL) AtomDOFMap AtomDOFMap associates an atom index with t...
Definition: SofaSimulator.h:51
An interactive simulator is a simulator that we can control step by step (ex: Sofa)
Definition: InteractiveSimulator.h:38
Manager of the benchmark tests.
Definition: MonitoringManager.h:50
MonitoringManager * monitoringManager
monitoring manager
Definition: Simulator.h:84
TODO Comment class here.
Definition: SofaSimulator.h:69
SofaSimulator(MonitoringManager *monitoringManager)
Definition: SofaSimulator.cpp:76
void createPml(const char *inputFile, const char *pmlFile)
Create a pml file from an imput file.
Definition: SofaSimulator.cpp:534
std::string getScnFile()
Definition: SofaSimulator.h:203
void getForce(int index, double force[3])
get current force for one atom
Definition: SofaSimulator.cpp:472
void end()
end simultor
Definition: SofaSimulator.h:84
virtual ~SofaSimulator()
Definition: SofaSimulator.cpp:282
void doMove(double dt)
ask the simulator do to one step of the simulation
Definition: SofaSimulator.cpp:440
void getPosition(int index, double position[3])
get current position for one atom
Definition: SofaSimulator.cpp:459
void init()
initialize the simulator
Definition: SofaSimulator.cpp:486