RigidMapping.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_COMPONENT_MAPPING_RIGIDMAPPING_H
00026 #define SOFA_COMPONENT_MAPPING_RIGIDMAPPING_H
00027
00028 #include <sofa/core/componentmodel/behavior/MechanicalMapping.h>
00029 #include <sofa/core/componentmodel/behavior/MechanicalState.h>
00030 #include <sofa/defaulttype/RigidTypes.h>
00031 #include <vector>
00032
00033 namespace sofa
00034 {
00035
00036 namespace component
00037 {
00038
00039 namespace mapping
00040 {
00041
00043 template<class InDataTypes, class OutDataTypes>
00044 class RigidMappingInternalData
00045 {
00046 public:
00047 };
00048
00049
00050 template <class BasicMapping>
00051 class RigidMapping : public BasicMapping, public virtual core::objectmodel::BaseObject
00052 {
00053 public:
00054 typedef BasicMapping Inherit;
00055 typedef typename Inherit::In In;
00056 typedef typename Inherit::Out Out;
00057 typedef typename Out::VecCoord VecCoord;
00058 typedef typename Out::VecDeriv VecDeriv;
00059 typedef typename Out::Coord Coord;
00060 typedef typename Out::Deriv Deriv;
00061 typedef typename In::Deriv InDeriv;
00062 typedef typename In::SparseDeriv InSparseDeriv;
00063 typedef typename Coord::value_type Real;
00064 enum { N=Coord::static_size };
00065 typedef defaulttype::Mat<N,N,Real> Mat;
00066
00067 Data< VecCoord > points;
00068 VecCoord rotatedPoints;
00069 RigidMappingInternalData<typename In::DataTypes, typename Out::DataTypes> data;
00070 Data<unsigned int> index;
00071 Data< std::string > filename;
00072 Data< bool > useX0;
00073
00074 RigidMapping ( In* from, Out* to )
00075 : Inherit ( from, to ),
00076 points ( initData ( &points,"initialPoints", "Local Coordinates of the points" ) ),
00077 index ( initData ( &index, ( unsigned ) 0,"index","input DOF index" ) ),
00078 filename ( initData ( &filename,"filename","Filename" ) ),
00079 useX0( initData ( &useX0,false,"useX0","Use x0 instead of local copy of initial positions (to support topo changes)") ),
00080 repartition ( initData ( &repartition,"repartition","number of dest dofs per entry dof" ) )
00081 {
00082 }
00083
00084 virtual ~RigidMapping()
00085 {}
00086
00087 int addPoint ( const Coord& c );
00088 int addPoint ( const Coord& c, int indexFrom );
00089
00090 void init();
00091
00092
00093
00094 void parse ( core::objectmodel::BaseObjectDescription* arg )
00095 {
00096 if ( !filename.getValue().empty() ) this->load ( filename.getValue().c_str() );
00097 this->Inherit::parse ( arg );
00098 }
00099
00100 virtual void apply ( typename Out::VecCoord& out, const typename In::VecCoord& in );
00101
00102 virtual void applyJ ( typename Out::VecDeriv& out, const typename In::VecDeriv& in );
00103
00104 virtual void applyJT ( typename In::VecDeriv& out, const typename Out::VecDeriv& in );
00105
00106 void applyJT ( typename In::VecConst& out, const typename Out::VecConst& in );
00107
00108 void draw();
00109
00110 void clear ( int reserve=0 );
00111
00112 void setRepartition ( unsigned int value );
00113 void setRepartition ( sofa::helper::vector<unsigned int> values );
00114
00115 protected:
00116 class Loader;
00117 void load ( const char* filename );
00118 Data<sofa::helper::vector<unsigned int> > repartition;
00119 const VecCoord& getPoints();
00120 };
00121
00122 }
00123
00124 }
00125
00126 }
00127
00128 #endif