LinearMovementConstraint.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_CONSTRAINT_LINEARMOVEMENTCONSTRAINT_H
00026 #define SOFA_COMPONENT_CONSTRAINT_LINEARMOVEMENTCONSTRAINT_H
00027 
00028 #include <sofa/core/componentmodel/behavior/Constraint.h>
00029 #include <sofa/core/componentmodel/behavior/MechanicalState.h>
00030 #include <sofa/core/componentmodel/topology/BaseMeshTopology.h>
00031 #include <sofa/core/objectmodel/Event.h>
00032 #include <sofa/defaulttype/BaseMatrix.h>
00033 #include <sofa/defaulttype/BaseVector.h>
00034 #include <sofa/helper/vector.h>
00035 #include <sofa/component/topology/PointSubset.h>
00036 #include <set>
00037 
00038 namespace sofa
00039 {
00040 
00041 namespace component
00042 {
00043 
00044 namespace constraint
00045 {
00046 
00047 using helper::vector;
00048 using core::objectmodel::Data;
00049 using namespace sofa::core::objectmodel;
00050 using namespace sofa::defaulttype;
00051 
00055 template <class DataTypes>
00056 class LinearMovementConstraint : public core::componentmodel::behavior::Constraint<DataTypes>, public virtual core::objectmodel::BaseObject
00057 {
00058 public:
00059     typedef typename DataTypes::VecCoord VecCoord;
00060     typedef typename DataTypes::VecDeriv VecDeriv;
00061     typedef typename DataTypes::Coord Coord;
00062     typedef typename DataTypes::Deriv Deriv;
00063     typedef typename DataTypes::Real Real;
00064     typedef topology::PointSubset SetIndex;
00065     typedef helper::vector<unsigned int> SetIndexArray;
00066 
00067 public :
00069     Data<SetIndex> m_indices;
00071     Data<helper::vector<Real> > m_keyTimes;
00073     Data<VecDeriv > m_keyMovements;
00074 
00076     Real prevT, nextT;
00078     Deriv prevM, nextM;
00080     VecCoord x0;
00081 
00082     LinearMovementConstraint();
00083 
00084     virtual ~LinearMovementConstraint();
00085 
00087     void clearIndices();
00088     void addIndex(unsigned int index);
00089     void removeIndex(unsigned int index);
00090     void clearKeyMovements();
00096     void addKeyMovement(Real time, Deriv movement);
00097 
00098 
00100     void init();
00101     void projectResponse(VecDeriv& dx);
00102     virtual void projectVelocity(VecDeriv& dx); 
00103     virtual void projectPosition(VecCoord& x); 
00104 
00106     virtual void handleTopologyChange();
00107 
00108     virtual void draw();
00109 
00111     bool isHolonomic() {return true;}
00112 
00113 protected:
00114 
00115     sofa::core::componentmodel::topology::BaseMeshTopology* topology;
00116     
00118     static bool FCTestNewPointFunction(int, void*, const sofa::helper::vector< unsigned int > &, const sofa::helper::vector< double >& );
00119 
00121     static void FCRemovalFunction ( int , void*);
00122 
00123 };
00124 
00125 } // namespace constraint
00126 
00127 } // namespace component
00128 
00129 } // namespace sofa
00130 
00131 
00132 #endif
00133 

Generated on Sun Nov 23 02:41:14 2008 for Sofa by  doxygen 1.5.7.1