Computer Assited Medical Intervention Tool Kit  version 5.0
TranslationConstraint.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 SIMULATOR_SIMULATORS_SOFA_TRANSLATIONCONSTRAINT_H
27 #define SIMULATOR_SIMULATORS_SOFA_TRANSLATIONCONSTRAINT_H
28 
29 
30 #include "sofa/core/behavior/ProjectiveConstraintSet.h"
31 #include "sofa/core/behavior/MechanicalState.h"
32 //#include "sofa/core/VisualModel.h"
33 
34 #include <vector>
35 #include <map>
36 
37 #include <Loads.h>
38 
39 template<class DataTypes>
40 
48 class TranslationConstraint : public sofa::core::behavior::ProjectiveConstraintSet<DataTypes> { //, public VisualModel
49 public :
51  typedef typename DataTypes::VecCoord VecCoord;
52  typedef typename DataTypes::VecDeriv VecDeriv;
53  typedef typename DataTypes::VecCoord::iterator VecCoordIterator;
54  typedef typename DataTypes::VecDeriv::iterator VecDerivIterator;
55  typedef typename DataTypes::Coord Coord;
56  typedef typename DataTypes::Deriv Deriv;
57 
58  typedef typename DataTypes::MatrixDeriv::RowType MatrixDerivRowType;
59 
61  TranslationConstraint(Loads* loadsList, const std::map<unsigned int, unsigned int>& atomIndexToDOFIndex, sofa::core::behavior::MechanicalState<DataTypes>* mm);
62 
64 
66  std::vector<unsigned int> getTargets() {
67  return targets;
68  }
69 
71  TranslationConstraint<DataTypes>* addConstraint(unsigned int index, Deriv trans);
73 
76  virtual void projectVelocity(VecDeriv& v);
77  virtual void projectPosition(VecCoord& x);
78 
80 
82  void draw();
83  void initTextures() { }
84  void update() { }
85 
87  void setInitTime(double time);
88 
89  //TODO need to define which getclass to choose because of double inherance...
90  //sofa::core::objectmodel::BaseClass* getClass() const {return nullptr;}
91 
92 private:
93 
95  void fixDOF(int index, int axe);
97  sofa::core::behavior::MechanicalState<DataTypes>* mmodel;
99  std::vector<unsigned int> targets;
107  double initTime;
109  std::vector<Load*> loads;
111  std::map<unsigned int, unsigned int> atomToDOFIndexes;
112 };
113 
114 #endif // SIMULATOR_SIMULATORS_SOFA_TRANSLATIONCONSTRAINT_H
TranslationConstraint::~TranslationConstraint
~TranslationConstraint()
Definition: TranslationConstraint.h:86
Loads.h
TranslationConstraint::Coord
DataTypes::Coord Coord
Definition: TranslationConstraint.h:78
TranslationConstraint::draw
void draw()
– VisualModel interface
TranslationConstraint::loads
std::vector< Load * > loads
the lml loads
Definition: TranslationConstraint.h:132
TranslationConstraint::directionsNULLs
VecDeriv directionsNULLs
list of fixed directions
Definition: TranslationConstraint.h:126
TranslationConstraint::projectVelocity
virtual void projectVelocity(VecDeriv &v)
project dx to constrained space (dx models a velocity)
TranslationConstraint::VecCoord
DataTypes::VecCoord VecCoord
template types
Definition: TranslationConstraint.h:74
TranslationConstraint::VecCoordIterator
DataTypes::VecCoord::iterator VecCoordIterator
Definition: TranslationConstraint.h:76
TranslationConstraint::VecDerivIterator
DataTypes::VecDeriv::iterator VecDerivIterator
Definition: TranslationConstraint.h:77
TranslationConstraint::removeConstraint
TranslationConstraint< DataTypes > * removeConstraint(int index)
TranslationConstraint::mmodel
sofa::core::behavior::MechanicalState< DataTypes > * mmodel
the mechanical model
Definition: TranslationConstraint.h:120
TranslationConstraint::initTextures
void initTextures()
Definition: TranslationConstraint.h:106
TranslationConstraint::projectPosition
virtual void projectPosition(VecCoord &x)
project x to constrained space (x models a position)
TranslationConstraint::initTime
double initTime
initial time
Definition: TranslationConstraint.h:130
TranslationConstraint::translations
VecDeriv translations
list of translations
Definition: TranslationConstraint.h:124
Loads
This class makes it possible to manage a list of "Load". Remember that Load is an abstract class (con...
Definition: Loads.h:71
TranslationConstraint::VecDeriv
DataTypes::VecDeriv VecDeriv
Definition: TranslationConstraint.h:75
TranslationConstraint::targets
std::vector< unsigned int > targets
the set of vertex targets
Definition: TranslationConstraint.h:122
TranslationConstraint
TODO Comment class here.
Definition: TranslationConstraint.h:48
TranslationConstraint::setInitTime
void setInitTime(double time)
set initial time (context->getTime() remind the same when simulation is rewind)
TranslationConstraint::addConstraint
TranslationConstraint< DataTypes > * addConstraint(unsigned int index, Deriv trans)
fix or translate a point
TranslationConstraint::initPos
VecDeriv initPos
initial positions
Definition: TranslationConstraint.h:128
TranslationConstraint::fixDOF
void fixDOF(int index, int axe)
fix a point on the axe specified (0=x, 1=y, 2=z)
TranslationConstraint::getTargets
std::vector< unsigned int > getTargets()
return the targets list
Definition: TranslationConstraint.h:89
TranslationConstraint::atomToDOFIndexes
std::map< unsigned int, unsigned int > atomToDOFIndexes
link between PML object indexes and sofa Dofs Indexes
Definition: TranslationConstraint.h:134
TranslationConstraint::MatrixDerivRowType
DataTypes::MatrixDeriv::RowType MatrixDerivRowType
Definition: TranslationConstraint.h:81
TranslationConstraint::Deriv
DataTypes::Deriv Deriv
Definition: TranslationConstraint.h:79
TranslationConstraint::projectResponse
void projectResponse(VecDeriv &dx)
Constraint inherits.
TranslationConstraint::TranslationConstraint
TranslationConstraint(Loads *loadsList, const std::map< unsigned int, unsigned int > &atomIndexToDOFIndex, sofa::core::behavior::MechanicalState< DataTypes > *mm)
constructor
TranslationConstraint::update
void update()
Definition: TranslationConstraint.h:107