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_CONSTRAINT_PARABOLICCONSTRAINT_H 00026 #define SOFA_COMPONENT_CONSTRAINT_PARABOLICCONSTRAINT_H 00027 00028 #include <sofa/core/componentmodel/behavior/Constraint.h> 00029 #include <sofa/core/componentmodel/behavior/MechanicalState.h> 00030 #include <sofa/helper/vector.h> 00031 #include <sofa/component/topology/PointSubset.h> 00032 00033 00034 namespace sofa 00035 { 00036 00037 namespace component 00038 { 00039 00040 namespace constraint 00041 { 00042 00043 using core::objectmodel::Data; 00044 using namespace sofa::core::objectmodel; 00045 using namespace sofa::defaulttype; 00046 00050 template <class DataTypes> 00051 class ParabolicConstraint : public core::componentmodel::behavior::Constraint<DataTypes>, public virtual core::objectmodel::BaseObject 00052 { 00053 public: 00054 typedef typename DataTypes::VecCoord VecCoord; 00055 typedef typename DataTypes::VecDeriv VecDeriv; 00056 typedef typename DataTypes::Coord Coord; 00057 typedef typename DataTypes::Deriv Deriv; 00058 typedef typename DataTypes::Real Real; 00059 typedef topology::PointSubset SetIndex; 00060 typedef helper::vector<unsigned int> SetIndexArray; 00061 typedef typename defaulttype::Vec<3, Real> Vec3R; 00062 typedef typename helper::Quater<Real> QuatR; 00063 00064 protected: 00066 Data<SetIndex> m_indices; 00067 00069 Data<Vec3R> m_P1; 00070 Data<Vec3R> m_P2; 00071 Data<Vec3R> m_P3; 00072 00074 Data<Real> m_tBegin; 00075 Data<Real> m_tEnd; 00076 00078 Vec3R m_locP1; 00079 Vec3R m_locP2; 00080 Vec3R m_locP3; 00081 00083 QuatR m_projection; 00084 00085 00086 00087 public: 00088 ParabolicConstraint(); 00089 00090 ParabolicConstraint(core::componentmodel::behavior::MechanicalState<DataTypes>* mstate); 00091 00092 ~ParabolicConstraint(); 00093 00094 void addConstraint(unsigned index ); 00095 00096 void setP1(const Vec3R &p) {m_P1.setValue(p);} 00097 void setP2(const Vec3R &p) {m_P2.setValue(p);} 00098 void setP3(const Vec3R &p) {m_P3.setValue(p);} 00099 00100 void setBeginTime(const Real &t){m_tBegin.setValue(t);} 00101 void setEndTime(const Real &t){m_tEnd.setValue(t);} 00102 00103 Vec3R getP1() {return m_P1.getValue();} 00104 Vec3R getP2() {return m_P2.getValue();} 00105 Vec3R getP3() {return m_P3.getValue();} 00106 00107 Real getBeginTime() {return m_tBegin.getValue();} 00108 Real getEndTime() {return m_tEnd.getValue();} 00109 00111 void init(); 00112 void reinit(); 00113 void projectResponse(VecDeriv& dx); 00114 virtual void projectVelocity(VecDeriv& dx); 00115 virtual void projectPosition(VecCoord& x); 00116 00117 void draw(); 00118 }; 00119 00120 } // namespace constraint 00121 00122 } // namespace component 00123 00124 } // namespace sofa 00125 00126 #endif
1.5.7.1