CurveMapping.h

Go to the documentation of this file.
00001 /******************************************************************************
00002 *       SOFA, Simulation Open-Framework Architecture, version 1.0 beta 3      *
00003 *                (c) 2006-2008 MGH, INRIA, USTL, UJF, CNRS                    *
00004 *                                                                             *
00005 * This library is free software; you can redistribute it and/or modify it     *
00006 * under the terms of the GNU Lesser General Public License as published by    *
00007 * the Free Software Foundation; either version 2.1 of the License, or (at     *
00008 * your option) any later version.                                             *
00009 *                                                                             *
00010 * This library is distributed in the hope that it will be useful, but WITHOUT *
00011 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       *
00012 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
00013 * for more details.                                                           *
00014 *                                                                             *
00015 * You should have received a copy of the GNU Lesser General Public License    *
00016 * along with this library; if not, write to the Free Software Foundation,     *
00017 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.          *
00018 *******************************************************************************
00019 *                               SOFA :: Modules                               *
00020 *                                                                             *
00021 * Authors: The SOFA Team and external contributors (see Authors.txt)          *
00022 *                                                                             *
00023 * Contact information: contact@sofa-framework.org                             *
00024 ******************************************************************************/
00025 //
00026 // C++ Interface: CurveMapping
00027 //
00028 // Description: 
00029 //
00030 //
00031 // Author: The SOFA team </www.sofa-framework.org>, (C) 2008
00032 //
00033 // Copyright: See COPYING file that comes with this distribution
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 } // namespace mapping
00126 
00127 } // namespace component
00128 
00129 } // namespace sofa
00130 
00131 #endif

Generated on Sun Nov 23 03:31:59 2008 for Sofa by  doxygen 1.5.7.1