RigidRigidMapping.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_RIGIDRIGIDMAPPING_H
00026 #define SOFA_COMPONENT_MAPPING_RIGIDRIGIDMAPPING_H
00027
00028 #include <sofa/component/mapping/RigidMapping.h>
00029 #include <sofa/core/componentmodel/behavior/MechanicalMapping.h>
00030 #include <sofa/core/componentmodel/behavior/MechanicalState.h>
00031 #include <sofa/defaulttype/RigidTypes.h>
00032 #include <sofa/defaulttype/Vec.h>
00033 #include <vector>
00034
00035 using namespace sofa::defaulttype;
00036
00037 namespace sofa
00038 {
00039
00040 namespace component
00041 {
00042
00043 namespace mapping
00044 {
00045
00046 template <class BasicMapping>
00047 class RigidRigidMapping : public BasicMapping, public virtual core::objectmodel::BaseObject
00048 {
00049 public:
00050 typedef BasicMapping Inherit;
00051 typedef typename Inherit::In In;
00052 typedef typename Inherit::Out Out;
00053 typedef typename Out::VecCoord VecCoord;
00054 typedef typename Out::VecDeriv VecDeriv;
00055 typedef typename Out::Coord Coord;
00056 typedef typename Out::Deriv Deriv;
00057 typedef typename In::Coord InCoord;
00058 typedef typename In::Deriv InDeriv;
00059 typedef typename In::SparseDeriv InSparseDeriv;
00060 typedef typename Coord::value_type Real;
00061 enum { N=Coord::static_size };
00062 typedef defaulttype::Mat<N,N,Real> Mat;
00063 typedef Vec<N,Real> Vector ;
00064
00065 protected:
00066 Data < VecCoord > points;
00067 VecCoord pointsR0;
00068 Mat rotation;
00069 class Loader;
00070 void load(const char* filename);
00071 Data<sofa::helper::vector<unsigned int> > repartition;
00072
00073 public:
00074 Data<unsigned> index;
00075 Data< std::string > filename;
00076
00077 Data<double> axisLength;
00078
00079 RigidRigidMapping(In* from, Out* to)
00080 : Inherit(from, to),
00081 points(initData(&points, "initialPoints", "Initial position of the points")),
00082 repartition(initData(&repartition,"repartition","number of dest dofs per entry dof")),
00083 index(initData(&index,(unsigned)0,"index","input DOF index")),
00084 filename(initData(&filename,"filename","Filename")),
00085 axisLength(initData( &axisLength, 0.7, "axisLength", "axis length for display"))
00086 {
00087 }
00088
00089 virtual ~RigidRigidMapping()
00090 {
00091 }
00092
00093 void init();
00094
00095
00096
00097 void parse(core::objectmodel::BaseObjectDescription* arg)
00098 {
00099 if (!filename.getValue().empty())
00100 this->load(filename.getValue().c_str());
00101 this->Inherit::parse(arg);
00102 }
00103
00104 void apply( typename Out::VecCoord& out, const typename In::VecCoord& in );
00105
00106 void applyJ( typename Out::VecDeriv& out, const typename In::VecDeriv& in );
00107
00108 void applyJT( typename In::VecDeriv& out, const typename Out::VecDeriv& in );
00109
00110
00111
00112 void draw();
00113
00114 void clear();
00115
00116 sofa::helper::vector<unsigned int> getRepartition() {return repartition.getValue(); }
00117
00118 void setRepartition(unsigned int value);
00119 void setRepartition(sofa::helper::vector<unsigned int> values);
00120
00121 protected:
00122
00123 bool getShow(const core::objectmodel::BaseObject* m) const { return m->getContext()->getShowMappings(); }
00124
00125 bool getShow(const core::componentmodel::behavior::BaseMechanicalMapping* m) const { return m->getContext()->getShowMechanicalMappings(); }
00126 };
00127
00128 }
00129
00130 }
00131
00132 }
00133
00134 #endif