PrecomputedConstraintCorrection.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_CORE_COMPONENTMODEL_COLLISION_CONTACTCORRECTION_H
00026 #define SOFA_CORE_COMPONENTMODEL_COLLISION_CONTACTCORRECTION_H
00027 
00028 #include <sofa/core/componentmodel/behavior/BaseConstraintCorrection.h>
00029 #include <sofa/core/componentmodel/behavior/MechanicalState.h>
00030 #include <sofa/component/forcefield/TetrahedronFEMForceField.h>
00031 
00032 #include <sofa/defaulttype/Mat.h>
00033 #include <sofa/defaulttype/Vec.h>
00034 
00035 namespace sofa
00036 {
00037 
00038 namespace component
00039 {
00040 
00041 namespace constraint
00042 {
00043 
00044 using namespace sofa::core;
00045 using namespace sofa::core::componentmodel;
00046 using namespace sofa::defaulttype;
00050 template<class TDataTypes>
00051 class PrecomputedConstraintCorrection : public componentmodel::behavior::BaseConstraintCorrection
00052 {
00053 public:
00054     typedef TDataTypes DataTypes;
00055     typedef typename componentmodel::behavior::BaseConstraintCorrection Inherit;
00056     typedef typename DataTypes::VecCoord VecCoord;
00057     typedef typename DataTypes::VecDeriv VecDeriv;
00058     typedef typename DataTypes::VecConst VecConst;
00059     typedef typename DataTypes::Coord Coord;
00060     typedef typename DataTypes::Deriv Deriv;
00061     typedef typename DataTypes::SparseVecDeriv Const;
00062 
00064     typedef typename Coord::value_type Real;
00065     typedef MatNoInit<3, 3, Real> Transformation;
00066 
00067     bool   _rotations;
00068     DataPtr<bool> f_rotations;
00069     bool   _restRotations;
00070     DataPtr<bool> f_restRotations;
00071 
00072     PrecomputedConstraintCorrection(behavior::MechanicalState<DataTypes> *mm = NULL);
00073 
00074     virtual ~PrecomputedConstraintCorrection();
00075 
00076     virtual void init();
00077 
00079     behavior::MechanicalState<DataTypes>* getMState() { return mstate; }
00080 
00081     virtual void getCompliance(defaulttype::BaseMatrix* W);
00082     virtual void applyContactForce(const defaulttype::BaseVector *f);
00083 
00084 
00085     virtual void rotateConstraints();
00086     virtual void rotateResponse();
00087 
00088 
00089     virtual void resetContactForce();
00090 
00093     template<class T>
00094     static bool canCreate(T*& obj, objectmodel::BaseContext* context, objectmodel::BaseObjectDescription* arg)
00095     {
00096         if (dynamic_cast<behavior::MechanicalState<DataTypes>*>(context->getMechanicalState()) == NULL)
00097             return false;
00098         return BaseObject::canCreate(obj, context, arg);
00099     }
00100 
00101     virtual std::string getTemplateName() const
00102     {
00103         return templateName(this);
00104     }
00105 
00106     static std::string templateName(const PrecomputedConstraintCorrection<DataTypes>* = NULL)
00107     {
00108         return DataTypes::Name();
00109     }
00110 
00111    virtual void parse(core::objectmodel::BaseObjectDescription* arg);
00112 
00113 
00114 protected:
00115     behavior::MechanicalState<DataTypes> *mstate;
00116     //Vec3DTypes specific menber !
00117     Real* appCompliance;
00118     unsigned int nbRows, nbCols, dof_on_node, nbNodes;
00119     int *_indexNodeSparseCompliance;
00120     std::vector<Deriv> _sparseCompliance;
00121     Real Fbuf[6], DXbuf;
00122 
00123 
00124 /* optimization : buf of result = Compliance * VecConst on a sparse structure
00125     typedef struct {
00126         Deriv Cn;
00127         int nodeId;
00128         int constraintId;
00129     }SparseCompliance;
00130 
00131     SparseCompliance _sparseCompliance[10000];
00132     */
00133 
00134     //Deriv **_sparseCompliance;
00135 
00136 
00137 
00138     
00139 
00140 
00141 
00142 };
00143 
00144 } // namespace collision
00145 
00146 } // namespace component
00147 
00148 } // namespace sofa
00149 
00150 #endif

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