FixedConstraint.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/component/constraint/FixedConstraint.inl>
00026 #include <sofa/core/ObjectFactory.h>
00027 #include <sofa/defaulttype/Vec3Types.h>
00028 #include <sofa/defaulttype/RigidTypes.h>
00029 
00030 #include <sofa/simulation/tree/GNode.h>
00031 #include <sofa/component/mass/UniformMass.h>
00032 
00033 namespace sofa
00034 {
00035 
00036 namespace component
00037 {
00038 
00039 namespace constraint
00040 {
00041 
00042 using namespace sofa::defaulttype;
00043 using namespace sofa::helper;
00044 
00045 
00046 SOFA_DECL_CLASS(FixedConstraint)
00047 
00048 int FixedConstraintClass = core::RegisterObject("Attach given particles to their initial positions")
00049 #ifndef SOFA_FLOAT
00050 .add< FixedConstraint<Vec3dTypes> >()
00051 .add< FixedConstraint<Vec2dTypes> >()
00052 .add< FixedConstraint<Vec1dTypes> >()
00053 .add< FixedConstraint<Vec6dTypes> >()
00054 .add< FixedConstraint<Rigid3dTypes> >()
00055 .add< FixedConstraint<Rigid2dTypes> >()
00056 #endif
00057 #ifndef SOFA_DOUBLE
00058 .add< FixedConstraint<Vec3fTypes> >()
00059 .add< FixedConstraint<Vec2fTypes> >()
00060 .add< FixedConstraint<Vec1fTypes> >()
00061 .add< FixedConstraint<Vec6fTypes> >()
00062 .add< FixedConstraint<Rigid3fTypes> >()
00063 .add< FixedConstraint<Rigid2fTypes> >()
00064 #endif
00065 ;
00066 
00067 #ifndef SOFA_FLOAT
00068 template class FixedConstraint<Vec3dTypes>;
00069 template class FixedConstraint<Vec2dTypes>;
00070 template class FixedConstraint<Vec1dTypes>;
00071 template class FixedConstraint<Vec6dTypes>;
00072 template class FixedConstraint<Rigid3dTypes>;
00073 template class FixedConstraint<Rigid2dTypes>;
00074 #endif
00075 #ifndef SOFA_DOUBLE
00076 template class FixedConstraint<Vec3fTypes>;
00077 template class FixedConstraint<Vec2fTypes>;
00078 template class FixedConstraint<Vec1fTypes>;
00079 template class FixedConstraint<Vec6fTypes>;
00080 template class FixedConstraint<Rigid3fTypes>;
00081 template class FixedConstraint<Rigid2fTypes>;
00082 #endif 
00083 
00084 #ifndef SOFA_FLOAT
00085 template <>
00086 void FixedConstraint<Rigid3dTypes>::draw()
00087 {
00088     const SetIndexArray & indices = f_indices.getValue().getArray();
00089     if (!getContext()->getShowBehaviorModels()) return;
00090     VecCoord& x = *mstate->getX();
00091     glDisable (GL_LIGHTING);
00092     glPointSize(10);
00093     glColor4f (1,0.5,0.5,1);
00094     glBegin (GL_POINTS);
00095     if( f_fixAll.getValue()==true )
00096         for (unsigned i=0; i<x.size(); i++ )
00097         gl::glVertexT(x[i].getCenter());
00098     else
00099         for (SetIndex::const_iterator it = indices.begin(); it != indices.end(); ++it)
00100             gl::glVertexT(x[*it].getCenter());
00101     glEnd();
00102 }
00103 
00104 template <>
00105     void FixedConstraint<Rigid2dTypes>::draw()
00106 {
00107   const SetIndexArray & indices = f_indices.getValue().getArray();
00108   if (!getContext()->getShowBehaviorModels()) return;
00109   VecCoord& x = *mstate->getX();
00110   glDisable (GL_LIGHTING);
00111   glPointSize(10);
00112   glColor4f (1,0.5,0.5,1);
00113   glBegin (GL_POINTS);
00114   if( f_fixAll.getValue()==true )
00115     for (unsigned i=0; i<x.size(); i++ )
00116       gl::glVertexT(x[i].getCenter());
00117   else
00118     for (SetIndex::const_iterator it = indices.begin(); it != indices.end(); ++it)
00119       gl::glVertexT(x[*it].getCenter());
00120   glEnd();
00121 }
00122 #endif
00123 
00124 #ifndef SOFA_DOUBLE
00125 template <>
00126 void FixedConstraint<Rigid3fTypes>::draw()
00127 {
00128     const SetIndexArray & indices = f_indices.getValue().getArray();
00129     if (!getContext()->getShowBehaviorModels()) return;
00130     VecCoord& x = *mstate->getX();
00131     glDisable (GL_LIGHTING);
00132     glPointSize(10);
00133     glColor4f (1,0.5,0.5,1);
00134     glBegin (GL_POINTS);
00135     if( f_fixAll.getValue()==true )
00136         for (unsigned i=0; i<x.size(); i++ )
00137         gl::glVertexT(x[i].getCenter());
00138     else
00139         for (SetIndex::const_iterator it = indices.begin(); it != indices.end(); ++it)
00140         gl::glVertexT(x[*it].getCenter());
00141     glEnd();
00142 }
00143 
00144 template <>
00145     void FixedConstraint<Rigid2fTypes>::draw()
00146 {
00147   const SetIndexArray & indices = f_indices.getValue().getArray();
00148   if (!getContext()->getShowBehaviorModels()) return;
00149   VecCoord& x = *mstate->getX();
00150   glDisable (GL_LIGHTING);
00151   glPointSize(10);
00152   glColor4f (1,0.5,0.5,1);
00153   glBegin (GL_POINTS);
00154   if( f_fixAll.getValue()==true )
00155     for (unsigned i=0; i<x.size(); i++ )
00156       gl::glVertexT(x[i].getCenter());
00157   else
00158     for (SetIndex::const_iterator it = indices.begin(); it != indices.end(); ++it)
00159       gl::glVertexT(x[*it].getCenter());
00160   glEnd();
00161 }
00162 #endif
00163 
00164 
00165 
00166 } // namespace constraint
00167 
00168 } // namespace component
00169 
00170 } // namespace sofa
00171 

Generated on Sun Nov 23 02:39:13 2008 for Sofa by  doxygen 1.5.7.1