BeamLinearMapping.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 #ifndef SOFA_COMPONENT_MAPPING_BEAMLINEARMAPPING_H
00026 #define SOFA_COMPONENT_MAPPING_BEAMLINEARMAPPING_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 
00042 template <class BasicMapping>
00043 class BeamLinearMapping : public BasicMapping, public virtual core::objectmodel::BaseObject
00044 {
00045 public:
00046     typedef BasicMapping Inherit;
00047     typedef typename Inherit::In In;
00048     typedef typename Inherit::Out Out;
00049     typedef typename Out::VecCoord VecCoord;
00050     typedef typename Out::VecDeriv VecDeriv;
00051     typedef typename Out::Coord Coord;
00052     typedef typename Out::Deriv Deriv;
00053     typedef typename In::Deriv InDeriv;
00054     typedef typename In::SparseDeriv InSparseDeriv;
00055     typedef typename Coord::value_type Real;
00056     enum { N=Coord::static_size };
00057     typedef defaulttype::Mat<N,N,Real> Mat;
00058     
00059 protected:
00060     sofa::helper::vector<Coord> points;
00061     //Coord translation;
00062     //Real orientation[4];
00063     //Mat rotation;
00064     sofa::helper::vector<Real> beamLength;
00065     sofa::helper::vector<Coord> rotatedPoints0;
00066     sofa::helper::vector<Coord> rotatedPoints1;
00067 public:
00068     //Data<unsigned> index;
00069     Data<bool> localCoord;
00070     
00071     BeamLinearMapping(In* from, Out* to)
00072     : Inherit(from, to)
00073     //, index(initData(&index,(unsigned)0,"index","input DOF index"))
00074     , localCoord(initData(&localCoord,true,"localCoord","true if initial coordinates are in the beam local coordinate system (i.e. a point at (10,0,0) is on the DOF number 10, whereas if this is false it is at whatever position on the beam where the distance from the initial DOF is 10)"))
00075     {
00076     }
00077     
00078     virtual ~BeamLinearMapping()
00079     {
00080     }
00081     
00082     void init();
00083     
00084     void apply( typename Out::VecCoord& out, const typename In::VecCoord& in );
00085     
00086     void applyJ( typename Out::VecDeriv& out, const typename In::VecDeriv& in );
00087     
00088     void applyJT( typename In::VecDeriv& out, const typename Out::VecDeriv& in );
00089 
00090     void applyJT( typename In::VecConst& out, const typename Out::VecConst& in );
00091 
00092     void draw();
00093 
00094 };
00095 
00096 } // namespace mapping
00097 
00098 } // namespace component
00099 
00100 } // namespace sofa
00101 
00102 #endif

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