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_SUBSETMAPPING_H 00026 #define SOFA_COMPONENT_MAPPING_SUBSETMAPPING_H 00027 00028 #include <sofa/core/componentmodel/behavior/MechanicalMapping.h> 00029 #include <sofa/core/componentmodel/behavior/MechanicalState.h> 00030 #include <sofa/helper/vector.h> 00031 00032 namespace sofa 00033 { 00034 00035 namespace component 00036 { 00037 00038 namespace mapping 00039 { 00040 00042 template<class InDataTypes, class OutDataTypes> 00043 class SubsetMappingInternalData 00044 { 00045 public: 00046 }; 00047 00052 template <class BasicMapping> 00053 class SubsetMapping : public BasicMapping, public virtual core::objectmodel::BaseObject 00054 { 00055 public: 00056 typedef BasicMapping Inherit; 00057 typedef typename Inherit::In In; 00058 typedef typename Inherit::Out Out; 00059 typedef typename Out::VecCoord OutVecCoord; 00060 typedef typename Out::VecDeriv OutVecDeriv; 00061 typedef typename Out::Coord OutCoord; 00062 typedef typename Out::Deriv OutDeriv; 00063 typedef typename In::VecCoord InVecCoord; 00064 typedef typename In::VecDeriv InVecDeriv; 00065 typedef typename In::Coord InCoord; 00066 typedef typename In::Deriv InDeriv; 00067 typedef typename InCoord::value_type Real; 00068 00070 typedef helper::vector<unsigned int> IndexArray; 00071 Data < IndexArray > f_indices; 00072 Data < int > f_first; 00073 Data < int > f_last; 00074 Data < Real > f_radius; 00075 SubsetMappingInternalData<typename In::DataTypes, typename Out::DataTypes> data; 00076 void postInit(); 00077 00078 SubsetMapping(In* from, Out* to); 00079 00080 void clear(int reserve); 00081 00082 int addPoint(int index); 00083 00084 void init(); 00085 00086 virtual ~SubsetMapping(); 00087 00088 void apply( typename Out::VecCoord& out, const typename In::VecCoord& in ); 00089 00090 void applyJ( typename Out::VecDeriv& out, const typename In::VecDeriv& in ); 00091 00092 void applyJT( typename In::VecDeriv& out, const typename Out::VecDeriv& in ); 00093 00094 void applyJT( typename In::VecConst& out, const typename Out::VecConst& in ); 00095 }; 00096 00097 } // namespace mapping 00098 00099 } // namespace component 00100 00101 } // namespace sofa 00102 00103 #endif
1.5.7.1