VoidMapping.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_VOIDMAPPING_H
00026 #define SOFA_COMPONENT_MAPPING_VOIDMAPPING_H
00027 
00028 #include <sofa/core/componentmodel/behavior/BaseMechanicalMapping.h>
00029 #include <sofa/core/componentmodel/behavior/BaseMechanicalState.h>
00030 #include <sofa/core/BaseMapping.h>
00031 #include <vector>
00032 
00033 namespace sofa
00034 {
00035 
00036 namespace component
00037 {
00038 
00039 namespace mapping
00040 {
00041 
00042 class VoidMapping : public sofa::core::componentmodel::behavior::BaseMechanicalMapping, public sofa::core::BaseMapping
00043 {
00044 public:
00045     typedef sofa::core::componentmodel::behavior::BaseMechanicalMapping Inherit;
00046     typedef sofa::core::componentmodel::behavior::BaseMechanicalState In;
00047     typedef sofa::core::componentmodel::behavior::BaseMechanicalState Out;
00048 
00049     Data<bool> f_isMechanical;
00050 
00051     VoidMapping()
00052     : f_isMechanical( initData( &f_isMechanical, true, "isMechanical", "set to false if this mapping should only be used as a regular mapping instead of a mechanical mapping" ) )
00053     , fromModel(NULL), toModel(NULL)
00054     {
00055     }
00056 
00057     virtual ~VoidMapping()
00058     {
00059     }
00060 
00061     void init()
00062     {
00063         fromModel = dynamic_cast<In*>(this->getContext()->getMechanicalState());
00064         toModel = dynamic_cast<Out*>(this->getContext()->getMechanicalState());
00065     }
00066 
00068     virtual void updateMapping()
00069     {
00070     }
00071 
00073     virtual sofa::core::objectmodel::BaseObject* getFrom()
00074     {
00075         return fromModel;
00076     }
00077 
00079     virtual sofa::core::objectmodel::BaseObject* getTo()
00080     {
00081         return toModel;
00082     }
00083 
00085     virtual void disable()
00086     {
00087     }
00088 
00090     virtual sofa::core::componentmodel::behavior::BaseMechanicalState* getMechFrom()
00091     {
00092     return fromModel;
00093     }
00094 
00096     virtual sofa::core::componentmodel::behavior::BaseMechanicalState* getMechTo()
00097     {
00098     return toModel;
00099     }
00100 
00102     bool isMechanical()
00103     {
00104     return this->f_isMechanical.getValue();
00105     }
00106 
00111     virtual void propagateX()
00112     {
00113     }
00114 
00116     virtual void propagateXfree()
00117     {
00118     }
00119 
00121     virtual void propagateV()
00122     {
00123     }
00124 
00125 protected:
00126     In* fromModel;
00127     Out* toModel;
00128 };
00129 
00130 } // namespace mapping
00131 
00132 } // namespace component
00133 
00134 } // namespace sofa
00135 
00136 #endif

Generated on Sun Nov 23 03:35:04 2008 for Sofa by  doxygen 1.5.7.1