FixedConstraint.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_FIXEDCONSTRAINT_H
00026 #define SOFA_COMPONENT_CONSTRAINT_FIXEDCONSTRAINT_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 
00052 template <class DataTypes>
00053 class FixedConstraintInternalData
00054 {
00055 };
00056 
00059 template <class DataTypes>
00060 class FixedConstraint : public core::componentmodel::behavior::Constraint<DataTypes>, public virtual core::objectmodel::BaseObject
00061 {
00062 public:
00063         typedef typename DataTypes::VecCoord VecCoord;
00064         typedef typename DataTypes::VecDeriv VecDeriv;
00065     typedef typename DataTypes::Coord Coord;
00066     typedef typename DataTypes::Deriv Deriv;
00067     typedef topology::PointSubset SetIndex;
00068     typedef helper::vector<unsigned int> SetIndexArray;
00069 
00070 
00071 protected:
00072     FixedConstraintInternalData<DataTypes> data;
00073     friend class FixedConstraintInternalData<DataTypes>;
00074     
00075 public:
00076     Data<SetIndex> f_indices;
00077     Data<bool> f_fixAll;
00078 
00079     FixedConstraint();
00080 
00081     virtual ~FixedConstraint();
00082 
00083     void clearConstraints();
00084     void addConstraint(unsigned int index);
00085     void removeConstraint(unsigned int index);
00086 
00087     // -- Constraint interface
00088     void init();
00089     void projectResponse(VecDeriv& dx);
00090     virtual void projectVelocity(VecDeriv& /*dx*/){} 
00091     virtual void projectPosition(VecCoord& /*x*/){} 
00092 
00093     void applyConstraint(defaulttype::BaseMatrix *mat, unsigned int &offset);
00094     void applyConstraint(defaulttype::BaseVector *vect, unsigned int &offset);
00095     
00096     // Handle topological changes
00097     virtual void handleTopologyChange();
00098 
00099     virtual void draw();
00100         
00102     bool isHolonomic() {return true;}
00103 
00104 protected :
00105 
00106     sofa::core::componentmodel::topology::BaseMeshTopology* topology;
00107     
00108     // Define TestNewPointFunction
00109     static bool FCTestNewPointFunction(int, void*, const sofa::helper::vector< unsigned int > &, const sofa::helper::vector< double >& );
00110 
00111     // Define RemovalFunction
00112     static void FCRemovalFunction ( int , void*);
00113 
00114 };
00115 
00116 } // namespace constraint
00117 
00118 } // namespace component
00119 
00120 } // namespace sofa
00121 
00122 
00123 #endif

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