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_IDENTITYMAPPING_H 00026 #define SOFA_COMPONENT_MAPPING_IDENTITYMAPPING_H 00027 00028 #include <sofa/core/componentmodel/behavior/MechanicalMapping.h> 00029 #include <sofa/core/componentmodel/behavior/MechanicalState.h> 00030 #include <vector> 00031 00032 namespace sofa 00033 { 00034 00035 namespace component 00036 { 00037 00038 namespace mapping 00039 { 00040 00041 template <class BasicMapping> 00042 class IdentityMapping : public BasicMapping 00043 { 00044 public: 00045 typedef BasicMapping Inherit; 00046 typedef typename Inherit::In In; 00047 typedef typename Inherit::Out Out; 00048 00049 typedef typename In::DataTypes InDataTypes; 00050 typedef typename InDataTypes::Real Real; 00051 typedef typename InDataTypes::VecCoord InVecCoord; 00052 typedef typename InDataTypes::VecDeriv InVecDeriv; 00053 typedef typename InDataTypes::Coord InCoord; 00054 typedef typename InDataTypes::Deriv InDeriv; 00055 00056 typedef typename Out::VecCoord VecCoord; 00057 typedef typename Out::VecDeriv VecDeriv; 00058 typedef typename Out::SparseDeriv OutSparseDeriv; 00059 typedef typename Out::Coord Coord; 00060 typedef typename Out::Deriv Deriv; 00061 typedef typename Out::DataTypes OutDataTypes; 00062 typedef typename OutDataTypes::Real OutReal; 00063 typedef typename OutDataTypes::VecCoord OutVecCoord; 00064 typedef typename OutDataTypes::VecDeriv OutVecDeriv; 00065 00066 //enum { N=((int)Deriv::static_size < (int)InDeriv::static_size ? (int)Deriv::static_size : (int)InDeriv::static_size) }; 00067 00068 IdentityMapping(In* from, Out* to) 00069 : Inherit(from, to) 00070 { 00071 } 00072 00073 virtual ~IdentityMapping() 00074 { 00075 } 00076 00081 virtual bool sameTopology() const { return true; } 00082 00083 void apply( typename Out::VecCoord& out, const typename In::VecCoord& in ); 00084 00085 void applyJ( typename Out::VecDeriv& out, const typename In::VecDeriv& in ); 00086 00087 void applyJT( typename In::VecDeriv& out, const typename Out::VecDeriv& in ); 00088 00089 void applyJT( typename In::VecConst& out, const typename Out::VecConst& in ); 00090 }; 00091 00092 } // namespace mapping 00093 00094 } // namespace component 00095 00096 } // namespace sofa 00097 00098 #endif
1.5.7.1