MechanicalObject.cpp

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 #include <sofa/core/ObjectFactory.h>
00026 #include <sofa/defaulttype/LaparoscopicRigidTypes.h>
00027 #include <sofa/component/MechanicalObject.inl>
00028 
00029 
00030 namespace sofa
00031 {
00032 
00033 namespace component
00034 {
00035 
00036 using namespace core::componentmodel::behavior;
00037 using namespace defaulttype;
00038 
00039 SOFA_DECL_CLASS(MechanicalObject)
00040 
00041 int MechanicalObjectClass = core::RegisterObject("mechanical state vectors")    
00042 #ifdef SOFA_FLOAT
00043 .add< MechanicalObject<Vec3fTypes> >(true) // default template
00044 #else
00045 .add< MechanicalObject<Vec3dTypes> >(true) // default template    
00046 #ifndef SOFA_DOUBLE
00047 .add< MechanicalObject<Vec3fTypes> >() // default template
00048 #endif
00049 #endif
00050 #ifndef SOFA_FLOAT
00051 .add< MechanicalObject<Vec2dTypes> >()
00052 .add< MechanicalObject<Vec1dTypes> >()
00053 .add< MechanicalObject<Vec6dTypes> >()
00054 .add< MechanicalObject<Rigid3dTypes> >()
00055 .add< MechanicalObject<Rigid2dTypes> >()
00056 #endif
00057 #ifndef SOFA_DOUBLE
00058 .add< MechanicalObject<Vec2fTypes> >()
00059 .add< MechanicalObject<Vec1fTypes> >()
00060 .add< MechanicalObject<Vec6fTypes> >()
00061 .add< MechanicalObject<Rigid3fTypes> >()
00062 .add< MechanicalObject<Rigid2fTypes> >()
00063 #endif
00064 .add< MechanicalObject<LaparoscopicRigid3Types> >()
00065 ;
00066 
00067 // template specialization must be in the same namespace as original namespace for GCC 4.1
00068 // g++ 4.1 requires template instantiations to be declared on a parent namespace from the template class.
00069 #ifndef SOFA_FLOAT
00070 template class MechanicalObject<Vec3dTypes>;
00071 template class MechanicalObject<Vec2dTypes>;
00072 template class MechanicalObject<Vec1dTypes>;
00073 template class MechanicalObject<Vec6dTypes>;
00074 template class MechanicalObject<Rigid3dTypes>;
00075 template class MechanicalObject<Rigid2dTypes>;
00076 #endif
00077 #ifndef SOFA_DOUBLE
00078 template class MechanicalObject<Vec3fTypes>;
00079 template class MechanicalObject<Vec2fTypes>;
00080 template class MechanicalObject<Vec1fTypes>;
00081 template class MechanicalObject<Vec6fTypes>;
00082 template class MechanicalObject<Rigid3fTypes>;
00083 template class MechanicalObject<Rigid2fTypes>;
00084 #endif
00085 template class MechanicalObject<LaparoscopicRigid3Types>;
00086 
00087 
00088 
00089 #ifndef SOFA_FLOAT
00090 template<>
00091     void MechanicalObject<defaulttype::Rigid3dTypes>::applyRotation (const defaulttype::Quat q)
00092 {
00093     VecCoord& x = *this->getX();
00094     for (unsigned int i = 0; i < x.size(); i++)
00095     {
00096         x[i].getCenter() = q.rotate(x[i].getCenter());
00097         x[i].getOrientation() *= q;
00098     }
00099 }
00100 
00101 template <>
00102     bool MechanicalObject<Vec1dTypes>::addBBox(double* /*minBBox*/, double* /*maxBBox*/)
00103 {
00104     return false; // ignore 1D DOFs for 3D bbox
00105 }
00106 #endif
00107 
00108 #ifndef SOFA_DOUBLE
00109 template<>
00110 void MechanicalObject<defaulttype::Rigid3fTypes>::applyRotation (const defaulttype::Quat q)
00111 {
00112     VecCoord& x = *this->getX();
00113     for (unsigned int i = 0; i < x.size(); i++)
00114         {
00115         x[i].getCenter() = q.rotate(x[i].getCenter());
00116         x[i].getOrientation() *= q;
00117         }
00118 }
00119 
00120 template <>
00121     bool MechanicalObject<Vec1fTypes>::addBBox(double* /*minBBox*/, double* /*maxBBox*/)
00122 {
00123     return false; // ignore 1D DOFs for 3D bbox
00124 }
00125 #endif
00126 
00127 
00128 } // namespace component
00129 
00130 } // namespace sofa

Generated on Sun Nov 23 03:40:24 2008 for Sofa by  doxygen 1.5.7.1