FixedConstraint.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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 }
00167
00168 }
00169
00170 }
00171