ArticulatedSystemMapping.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
00026 #ifndef SOFA_COMPONENT_MAPPING_ARTICULATEDSYSTEMMAPPING_H
00027 #define SOFA_COMPONENT_MAPPING_ARTICULATEDSYSTEMMAPPING_H
00028
00029 #include <sofa/core/componentmodel/behavior/MechanicalMapping.h>
00030 #include <sofa/core/componentmodel/behavior/MechanicalState.h>
00031 #include <sofa/core/componentmodel/topology/BaseMeshTopology.h>
00032 #include <sofa/defaulttype/RigidTypes.h>
00033 #include <sofa/helper/gl/template.h>
00034 #include <sofa/helper/gl/Axis.h>
00035 #include <sofa/defaulttype/VecTypes.h>
00036 #include <vector>
00037 #include <sofa/component/container/ArticulatedHierarchyContainer.h>
00038 #include <sofa/simulation/tree/GNode.h>
00039
00040 namespace sofa
00041 {
00042
00043 namespace component
00044 {
00045
00046 namespace mapping
00047 {
00048
00049 using namespace sofa::defaulttype;
00050 using namespace sofa::component::container;
00051 using namespace sofa::simulation::tree;
00052
00053 template <class BasicMapping>
00054 class ArticulatedSystemMapping : public BasicMapping, public virtual core::objectmodel::BaseObject
00055 {
00056 public:
00057 typedef BasicMapping Inherit;
00058 typedef typename Inherit::In In;
00059 typedef typename Inherit::Out Out;
00060 typedef typename Out::VecCoord OutVecCoord;
00061 typedef typename Out::VecDeriv OutVecDeriv;
00062 typedef typename Out::Coord OutCoord;
00063 typedef typename Out::Deriv OutDeriv;
00064 typedef typename Out::SparseVecDeriv OutSparseVecDeriv;
00065 typedef typename Out::SparseDeriv OutSparseDeriv;
00066 typedef typename In::VecCoord InVecCoord;
00067 typedef typename In::VecDeriv InVecDeriv;
00068 typedef typename In::Coord InCoord;
00069 typedef typename In::Deriv InDeriv;
00070 typedef typename In::SparseVecDeriv InSparseVecDeriv;
00071 typedef typename In::SparseDeriv InSparseDeriv;
00072 typedef typename In::Real Real;
00073 typedef typename OutCoord::value_type OutReal;
00074
00075 typedef sofa::core::componentmodel::behavior::MechanicalState<typename Out::DataTypes> InRoot;
00076
00077 InRoot* rootModel;
00078
00079 ArticulatedSystemMapping(In* from, Out* to)
00080 : Inherit(from, to), rootModel(NULL), ahc(NULL)
00081 {
00082 }
00083
00084 virtual ~ArticulatedSystemMapping()
00085 {
00086 }
00087
00088 void init();
00089 void reset();
00090
00091
00092
00093
00094 void apply( typename Out::VecCoord& out, const typename In::VecCoord& in );
00095
00096 void applyJ( typename Out::VecDeriv& out, const typename In::VecDeriv& in, const typename InRoot::VecDeriv* inroot );
00097
00098 void applyJT( typename In::VecDeriv& out, const typename Out::VecDeriv& in, typename InRoot::VecDeriv* outroot );
00099
00100 void applyJT( typename In::VecConst& out, const typename Out::VecConst& in, typename InRoot::VecConst* outroot );
00101
00102
00103 void applyJ( typename Out::VecDeriv& out, const typename In::VecDeriv& in )
00104 {
00105 applyJ(out,in, NULL);
00106 }
00107
00108 void applyJT( typename In::VecDeriv& out, const typename Out::VecDeriv& in )
00109 {
00110 applyJT(out,in, NULL);
00111 }
00112
00113 void applyJT( typename In::VecConst& out, const typename Out::VecConst& in )
00114 {
00115 applyJT(out,in, NULL);
00116 }
00117
00122
00126 void propagateV();
00127
00131 void propagateDx();
00132
00136 void accumulateForce();
00137
00141 void accumulateDf();
00142
00146 void accumulateConstraint();
00147
00149
00150 void draw();
00151
00155 vector<ArticulatedHierarchyContainer::ArticulationCenter*> articulationCenters;
00156
00157 ArticulatedHierarchyContainer* ahc;
00158
00159 private:
00160 Vec<1,Quat> Buf_Rotation;
00161 std::vector< Vec<3,OutReal> > ArticulationAxis;
00162 std::vector< Vec<3,OutReal> > ArticulationPos;
00163 InVecCoord CoordinateBuf;
00164 InVecDeriv dxVec1Buf;
00165 OutVecDeriv dxRigidBuf;
00166 };
00167
00168
00169 }
00170
00171 }
00172
00173 }
00174
00175 #endif