Computer Assited Medical Intervention Tool Kit  version 5.0
MonitoringManager.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2021 Univ. Grenoble Alpes, CNRS, Grenoble INP, TIMC, 38000 Grenoble, France
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 #ifndef MANAGER_MONITORINGMANAGER_H
27 #define MANAGER_MONITORINGMANAGER_H
28 
29 #include <memory> // std::auto_ptr
30 #include <vector>
31 
32 #include <PhysicalModel.h>
33 #include <Loads.h>
34 
35 #include <MonitorIn.hxx>
36 #include <MonitorOut.hxx>
37 
38 class Monitor;
39 class Simulator;
40 
41 #include "MMLAPI.h"
51 public:
52 
58  MonitoringManager(const char* mml);
59 
61  virtual ~MonitoringManager();
62 
66  virtual bool init() = 0;
68  virtual void end() = 0;
69 
71  void simulate();
73  virtual void doMove() = 0;
75  virtual bool checkStop() = 0;
77  void rewind();
81  void reload(bool delPml = true);
82 
84  void saveMonitors();
86  void writeOutput(const char* fileName);
88  void writeCsv(const char* fileName);
90  void saveMmlIn(const char* fileName);
91 
94  double getDt();
95  double getRefresh();
96  double getCurrentTime();
97  double getCurrentStep();
98  double getStepComputingTime();
99  double getComputingTime();
100  PhysicalModel* getInitPml();
101  PhysicalModel* getPml();
107  PhysicalModel* takePml();
108  Loads* getLml();
114  Loads* takeLml();
115  std::string getPmlFileName();
116  std::string getLmlFileName();
117  std::string getMmlFileName();
118  std::string getmmlFileFolder();
119  Simulator* getSimulator();
121  void getOldPosition(double pos[3], unsigned int index);
123 
125  void setCurrentTime(double time);
126 
128  void storeOldPositions();
130  void updateCurrentTime();
132  void updateComputingTime();
134  void incStep();
135 
137  void setDt(double dt);
139  void setRefresh(double refresh);
141  void setPmlFileName(const char* file);
143  void setLmlFileName(const char* file);
144 
145  //accessors and mutators for monitors
147  void addMonitor(Monitor* monitor);
149  Monitor* getMonitor(const unsigned int i) const;
151  void deleteMonitor(const unsigned int i);
153  unsigned int numberOfMonitor() const;
154 
156  bool isPmlPresent();
158  bool isLmlPresent();
159 
160 protected:
161 
163  std::unique_ptr<mml::MonitoringIn> mmlIn;
165  std::vector<Monitor*> monitors;
167  std::vector<mml::TimeStep*> times;
168 
170  double dt;
172  double refresh;
174  std::string simulatorName;
175 
177  int step;
179  double currentTime;
186 
187 private:
188 
190  void buildMonitors();
192  void buildLoads();
196  void buildPmlAndSimulator(bool delPml = true);
198  void buildPmlAndSimulatorfromPml();
200  void buildPmlAndSimulatorfromSimulator();
201 
205  bool ownPml;
213  bool ownLml;
215  std::string pmlFileName;
217  std::string lmlFileName;
219  std::string mmlFileName;
221  std::string mmlFileFolder;
222 
223 };
224 
225 #endif // MANAGER_MONITORINGMANAGERF_H
MonitoringManager::getMmlFileName
std::string getMmlFileName()
Definition: MonitoringManager.cpp:295
timeParameter2double
double timeParameter2double(mml::TimeParameter &t)
convert a TimeParameter (from xsd-cxx generetaed file) to double
Definition: Tools.cpp:69
MonitoringManager::buildPmlAndSimulator
void buildPmlAndSimulator(bool delPml=true)
build physical model and simulator
Definition: MonitoringManager.cpp:522
MonitoringManager::step
int step
current step
Definition: MonitoringManager.h:177
MonitoringManager::setRefresh
void setRefresh(double refresh)
change refresh and save modification into mmlIn
Definition: MonitoringManager.cpp:399
MonitoringManager::oldPositionPointer
double * oldPositionPointer
old position pointer
Definition: MonitoringManager.h:207
MonitoringManager::pmlFileName
std::string pmlFileName
name of the pml file (complete path from working directory)
Definition: MonitoringManager.h:215
MonitoringManager::takePml
PhysicalModel * takePml()
This is nearly the same as getPml(), but it also transfers ownership of the pointer.
Definition: MonitoringManager.cpp:268
Loads.h
MonitoringManager::getOldPosition
void getOldPosition(double pos[3], unsigned int index)
get atom position for precedent step
Definition: MonitoringManager.cpp:335
MonitoringManager::simulate
void simulate()
perform simulation loop, make tests and save monitors' data into output file
Definition: MonitoringManager.cpp:428
MonitoringManager::times
std::vector< mml::TimeStep * > times
Vector that contains information saved by saveMonitors method.
Definition: MonitoringManager.h:167
Atom
An atom has an unique index in the physical model object, a 3D position, and different basic properti...
Definition: Atom.h:49
MonitoringManager::addMonitor
void addMonitor(Monitor *monitor)
add a monitor to the list
Definition: MonitoringManager.cpp:366
MonitoringManager::MonitoringManager
MonitoringManager(const char *mml)
constructor
Definition: MonitoringManager.cpp:44
MonitoringManager::initPml
PhysicalModel * initPml
initial pml
Definition: MonitoringManager.h:209
MonitoringManager::ownLml
bool ownLml
is the lml "own" by this is instance, which is the normal case when there are not visual representati...
Definition: MonitoringManager.h:213
a
#define a
MonitoringManager::getPml
PhysicalModel * getPml()
Definition: MonitoringManager.cpp:263
MonitoringManager.h
MonitoringManager::setDt
void setDt(double dt)
change dt and save modification into mmlIn
Definition: MonitoringManager.cpp:393
MonitoringManager::setLmlFileName
void setLmlFileName(const char *file)
change lml file name and save modification into mmlIn
Definition: MonitoringManager.cpp:405
MonitoringManager::~MonitoringManager
virtual ~MonitoringManager()
destructor
Definition: MonitoringManager.cpp:111
MonitoringManager::dt
double dt
integration step
Definition: MonitoringManager.h:170
MonitoringManager::getDt
double getDt()
Definition: MonitoringManager.cpp:227
MonitoringManager::getCurrentStep
double getCurrentStep()
Definition: MonitoringManager.cpp:242
MonitoringManager::lml
Loads * lml
Loads applied to pml.
Definition: MonitoringManager.h:211
Chrono.h
MML_API
#define MML_API
Definition: MMLAPI.h:43
SimulatorFactory::getInstance
static SimulatorFactory * getInstance()
return the unique instance of the factory
Definition: SimulatorFactory.cpp:56
MonitoringManager::saveMonitors
void saveMonitors()
Save save monitors' state for the current time.
Definition: MonitoringManager.cpp:200
MonitoringManager::updateComputingTime
void updateComputingTime()
add step computing time to total computing time
Definition: MonitoringManager.cpp:325
MonitoringManager::getComputingTime
double getComputingTime()
Definition: MonitoringManager.cpp:253
MonitoringManager::getLmlFileName
std::string getLmlFileName()
Definition: MonitoringManager.cpp:290
MonitoringManager::getMonitor
Monitor * getMonitor(const unsigned int i) const
get a monitor by its index in the list
Definition: MonitoringManager.cpp:378
Simulator
A simulator engine is used to compute the displacements of all atoms of the model.
Definition: Simulator.h:46
MonitoringManager::setCurrentTime
void setCurrentTime(double time)
mutators for simulation parameters
Definition: MonitoringManager.cpp:313
MonitoringManager::mmlFileName
std::string mmlFileName
name of the mml in file (complete path from working directory)
Definition: MonitoringManager.h:219
MonitoringManager::buildMonitors
void buildMonitors()
build monitors
Definition: MonitoringManager.cpp:510
MonitoringManager::buildPmlAndSimulatorfromPml
void buildPmlAndSimulatorfromPml()
build physical model and simulator from a pml file
Definition: MonitoringManager.cpp:552
MonitoringManager::currentTime
double currentTime
time at current moment
Definition: MonitoringManager.h:179
MonitoringManager::writeOutput
void writeOutput(const char *fileName)
Write all saved monitors' states into mmlOut file.
Definition: MonitoringManager.cpp:137
MonitoringManager::getPmlFileName
std::string getPmlFileName()
Definition: MonitoringManager.cpp:285
MonitoringManager::isLmlPresent
bool isLmlPresent()
check if a lml is present
Definition: MonitoringManager.cpp:486
MonitoringManager::getmmlFileFolder
std::string getmmlFileFolder()
Definition: MonitoringManager.cpp:300
Simulator::createPml
virtual void createPml(const char *inputFile, const char *pmlFile)=0
Create a pml file from a simulator specific imput file.
MonitoringManager::ownPml
bool ownPml
is the pml "own" by this instance, which is the normal case when there are no visual representation....
Definition: MonitoringManager.h:205
PhysicalModel
This is the main class of this project. Following a nice concept, a physical model is able to represe...
Definition: PhysicalModel.h:86
MonitoringManager::lmlFileName
std::string lmlFileName
name of the lml file (complete path from working directory)
Definition: MonitoringManager.h:217
MonitoringManager::buildLoads
void buildLoads()
build the loads if lml file was given
Definition: MonitoringManager.cpp:491
MonitoringManager::saveMmlIn
void saveMmlIn(const char *fileName)
save current version of mml in
Definition: MonitoringManager.cpp:417
MonitoringManager::storeOldPositions
void storeOldPositions()
store old positions before next step
Definition: MonitoringManager.cpp:361
MonitoringManager::mmlFileFolder
std::string mmlFileFolder
folder of mml file (complete path from working directory)
Definition: MonitoringManager.h:221
MonitoringManager::getLml
Loads * getLml()
Definition: MonitoringManager.cpp:274
MonitoringManager::numberOfMonitor
unsigned int numberOfMonitor() const
get the number of monitors stored in the list
Definition: MonitoringManager.cpp:388
MonitoringManager::monitors
std::vector< Monitor * > monitors
Vector that contains all monitors.
Definition: MonitoringManager.h:165
MonitoringManager::getSimulator
Simulator * getSimulator()
Definition: MonitoringManager.cpp:306
MonitoringManager::rewind
void rewind()
Rewind simulation.
Definition: MonitoringManager.cpp:445
MonitorFactory::createMonitor
static Monitor * createMonitor(mml::Monitor *m, MonitoringManager *monitoringManager)
create a monitor according to the xsdcxx object monitor
Definition: MonitorFactory.cpp:37
SimulatorFactory.h
MonitorFactory.h
MonitoringManager::setPmlFileName
void setPmlFileName(const char *file)
change pml file name and save modification into mmlIn
Definition: MonitoringManager.cpp:411
MonitoringManager::getRefresh
double getRefresh()
Definition: MonitoringManager.cpp:232
MonitoringManager::pml
PhysicalModel * pml
pml at current moment
Definition: MonitoringManager.h:203
MonitoringManager::deleteMonitor
void deleteMonitor(const unsigned int i)
delete a monitor and remove it from the list using its index
Definition: MonitoringManager.cpp:371
MMLAPI.h
MonitoringManager::mmlIn
std::unique_ptr< mml::MonitoringIn > mmlIn
Object representing manager in the file generated by xsdcxx, can be used for serialization.
Definition: MonitoringManager.h:163
MonitoringManager
Manager of the benchmark tests. Do simulation loop and tests.
Definition: MonitoringManager.h:50
MonitoringManager::simul
Simulator * simul
the simulator used for simualtion
Definition: MonitoringManager.h:185
Loads
This class makes it possible to manage a list of "Load". Remember that Load is an abstract class (con...
Definition: Loads.h:71
MonitoringManager::simulatorName
std::string simulatorName
name of the simulator
Definition: MonitoringManager.h:174
SimulatorFactory::createSimulator
Simulator * createSimulator(std::string id, MonitoringManager *monitoringManager)
Creates a Simulator based on its string id or return nullptr if there is no id in the map.
Definition: SimulatorFactory.cpp:37
MonitoringManager::writeCsv
void writeCsv(const char *fileName)
Write all saved monitors'state into csv file.
Definition: MonitoringManager.cpp:168
MonitoringManager::updateCurrentTime
void updateCurrentTime()
add dt to current time
Definition: MonitoringManager.cpp:319
MonitoringManager::buildPmlAndSimulatorfromSimulator
void buildPmlAndSimulatorfromSimulator()
build physical model and simulator from a specific simulator file
Definition: MonitoringManager.cpp:561
PhysicalModel.h
MonitoringManager::takeLml
Loads * takeLml()
This is nearly the same as getLml(), but it also transfers ownership of the pointer.
Definition: MonitoringManager.cpp:279
MonitoringManager::getCurrentTime
double getCurrentTime()
Definition: MonitoringManager.cpp:237
MonitoringManager::getInitPml
PhysicalModel * getInitPml()
Definition: MonitoringManager.cpp:258
camitk::refresh
void refresh()
refresh the display
MonitoringManager::reload
void reload(bool delPml=true)
reload simulation with current parameters
Definition: MonitoringManager.cpp:462
Monitor
A monitor calculate and store followed data (ex:calculation between current position and references) ...
Definition: Monitor.h:49
MonitoringManager::refresh
double refresh
refreshing step
Definition: MonitoringManager.h:172
MonitoringManager::incStep
void incStep()
increment step by one
Definition: MonitoringManager.cpp:330
Tools.h
MonitoringManager::computingTime
double computingTime
total computing time at current moment
Definition: MonitoringManager.h:183
MonitoringManager::stepComputingTime
double stepComputingTime
computing time of last step
Definition: MonitoringManager.h:181
MonitoringManager::getStepComputingTime
double getStepComputingTime()
Definition: MonitoringManager.cpp:247
MonitoringManager::isPmlPresent
bool isPmlPresent()
check if a scn is present instead of pmlFileName
Definition: MonitoringManager.cpp:481