PrecomputedConstraintCorrection.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SOFA_CORE_COMPONENTMODEL_COLLISION_CONTACTCORRECTION_H
00026 #define SOFA_CORE_COMPONENTMODEL_COLLISION_CONTACTCORRECTION_H
00027
00028 #include <sofa/core/componentmodel/behavior/BaseConstraintCorrection.h>
00029 #include <sofa/core/componentmodel/behavior/MechanicalState.h>
00030 #include <sofa/component/forcefield/TetrahedronFEMForceField.h>
00031
00032 #include <sofa/defaulttype/Mat.h>
00033 #include <sofa/defaulttype/Vec.h>
00034
00035 namespace sofa
00036 {
00037
00038 namespace component
00039 {
00040
00041 namespace constraint
00042 {
00043
00044 using namespace sofa::core;
00045 using namespace sofa::core::componentmodel;
00046 using namespace sofa::defaulttype;
00050 template<class TDataTypes>
00051 class PrecomputedConstraintCorrection : public componentmodel::behavior::BaseConstraintCorrection
00052 {
00053 public:
00054 typedef TDataTypes DataTypes;
00055 typedef typename componentmodel::behavior::BaseConstraintCorrection Inherit;
00056 typedef typename DataTypes::VecCoord VecCoord;
00057 typedef typename DataTypes::VecDeriv VecDeriv;
00058 typedef typename DataTypes::VecConst VecConst;
00059 typedef typename DataTypes::Coord Coord;
00060 typedef typename DataTypes::Deriv Deriv;
00061 typedef typename DataTypes::SparseVecDeriv Const;
00062
00064 typedef typename Coord::value_type Real;
00065 typedef MatNoInit<3, 3, Real> Transformation;
00066
00067 bool _rotations;
00068 DataPtr<bool> f_rotations;
00069 bool _restRotations;
00070 DataPtr<bool> f_restRotations;
00071
00072 PrecomputedConstraintCorrection(behavior::MechanicalState<DataTypes> *mm = NULL);
00073
00074 virtual ~PrecomputedConstraintCorrection();
00075
00076 virtual void init();
00077
00079 behavior::MechanicalState<DataTypes>* getMState() { return mstate; }
00080
00081 virtual void getCompliance(defaulttype::BaseMatrix* W);
00082 virtual void applyContactForce(const defaulttype::BaseVector *f);
00083
00084
00085 virtual void rotateConstraints();
00086 virtual void rotateResponse();
00087
00088
00089 virtual void resetContactForce();
00090
00093 template<class T>
00094 static bool canCreate(T*& obj, objectmodel::BaseContext* context, objectmodel::BaseObjectDescription* arg)
00095 {
00096 if (dynamic_cast<behavior::MechanicalState<DataTypes>*>(context->getMechanicalState()) == NULL)
00097 return false;
00098 return BaseObject::canCreate(obj, context, arg);
00099 }
00100
00101 virtual std::string getTemplateName() const
00102 {
00103 return templateName(this);
00104 }
00105
00106 static std::string templateName(const PrecomputedConstraintCorrection<DataTypes>* = NULL)
00107 {
00108 return DataTypes::Name();
00109 }
00110
00111 virtual void parse(core::objectmodel::BaseObjectDescription* arg);
00112
00113
00114 protected:
00115 behavior::MechanicalState<DataTypes> *mstate;
00116
00117 Real* appCompliance;
00118 unsigned int nbRows, nbCols, dof_on_node, nbNodes;
00119 int *_indexNodeSparseCompliance;
00120 std::vector<Deriv> _sparseCompliance;
00121 Real Fbuf[6], DXbuf;
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 };
00143
00144 }
00145
00146 }
00147
00148 }
00149
00150 #endif