CurveMapping.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
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #ifndef SOFA_COMPONENT_MAPPING_CURVEMAPPING_H
00037 #define SOFA_COMPONENT_MAPPING_CURVEMAPPING_H
00038
00039 #include <sofa/core/componentmodel/behavior/MechanicalMapping.h>
00040 #include <sofa/core/componentmodel/behavior/MechanicalState.h>
00041 #include <sofa/defaulttype/Quat.h>
00042 #include <sofa/core/objectmodel/Event.h>
00043
00044 namespace sofa
00045 {
00046
00047 namespace component
00048 {
00049
00050 namespace mapping
00051 {
00052
00053 template <class BasicMapping>
00054 class CurveMapping : 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 VecCoord;
00061 typedef typename In::VecCoord InVecCoord;
00062 typedef typename Out::VecDeriv VecDeriv;
00063 typedef typename Out::SparseDeriv OutSparseDeriv;
00064 typedef typename In::Coord InCoord;
00065 typedef typename Out::Coord Coord;
00066 typedef typename Out::Deriv Deriv;
00067 typedef typename Out::Real Real;
00068
00069 Data < helper::vector<Real> > abscissa;
00070 Data < helper::vector<Real> > angle;
00071 Data < Real > step;
00072 Data < Real > angularStep;
00073 Data < int > numNodes;
00074 Data < Real > stepNode;
00075 Data < Real > distNode;
00076 Data < Real > velocity;
00077
00078 helper::vector<int> old_integer;
00079 helper::vector<double> old_angle;
00080 helper::vector<Real> lengthElements;
00081 helper::vector<defaulttype::Quat> quatElements;
00082 helper::vector<defaulttype::Quat> rotatedQuatElements;
00083 helper::vector<defaulttype::Quat> quatInitNodes;
00084
00085 helper::vector<Real> reset_abscissa;
00086
00087 CurveMapping(In* from, Out* to)
00088 : Inherit(from, to),
00089 abscissa( initData(&abscissa, "abscissa", "")),
00090 angle( initData(&angle, "angle", "")),
00091 step( initData(&step, (Real) 10.0, "step", "")),
00092 angularStep( initData(&angularStep, (Real) 0.0, "angularStep", "")),
00093 numNodes( initData(&numNodes, (int)5, "numNodes", "")),
00094 stepNode( initData(&stepNode, (Real) 0.0, "stepNode", "")),
00095 distNode( initData(&distNode, (Real) 0.0, "distNode", "")),
00096 velocity( initData(&velocity, (Real) 0.0, "velocity", ""))
00097 {
00098 }
00099
00100 virtual ~CurveMapping()
00101 {
00102 }
00103
00104 void init();
00105 void reinit();
00106 void storeResetState();
00107 void reset();
00108
00109 void apply( typename Out::VecCoord& out, const typename In::VecCoord& in );
00110
00111 void applyJ( typename Out::VecDeriv& out, const typename In::VecDeriv& in );
00112
00113 void applyJT( typename In::VecDeriv& out, const typename Out::VecDeriv& in );
00114
00115 void applyJT( typename In::VecConst& out, const typename Out::VecConst& in );
00116
00117 void handleEvent(sofa::core::objectmodel::Event* event);
00118
00119 void draw();
00120
00121 Real advanceAbscissa(Real ab, Real dist);
00122 void rotateElements();
00123 };
00124
00125 }
00126
00127 }
00128
00129 }
00130
00131 #endif