MixedInteractionConstraint.inl

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 :: Framework                              *
00020 *                                                                             *
00021 * Authors: M. Adam, J. Allard, B. Andre, P-J. Bensoussan, S. Cotin, C. Duriez,*
00022 * H. Delingette, F. Falipou, F. Faure, S. Fonteneau, L. Heigeas, C. Mendoza,  *
00023 * M. Nesme, P. Neumann, J-P. de la Plata Alcade, F. Poyer and F. Roy          *
00024 *                                                                             *
00025 * Contact information: contact@sofa-framework.org                             *
00026 ******************************************************************************/
00027 #ifndef SOFA_CORE_COMPONENTMODEL_BEHAVIOR_MIXEDINTERACTIONCONSTRAINT_INL
00028 #define SOFA_CORE_COMPONENTMODEL_BEHAVIOR_MIXEDINTERACTIONCONSTRAINT_INL
00029 
00030 #include <sofa/core/objectmodel/DataPtr.h>
00031 #include "MixedInteractionConstraint.h"
00032 
00033 namespace sofa
00034 {
00035 
00036 namespace core
00037 {
00038 
00039 namespace componentmodel
00040 {
00041 
00042 namespace behavior
00043 {
00044 
00045 template<class DataTypes1, class DataTypes2>
00046 MixedInteractionConstraint<DataTypes1, DataTypes2>::MixedInteractionConstraint(MechanicalState<DataTypes1> *mm1, MechanicalState<DataTypes2> *mm2)
00047 : endTime( initData(&endTime,(double)-1,"endTime","The constraint stops acting after the given value.\nUse a negative value for infinite constraints") )
00048 , object1( initData(&object1, "object1", "First Object to Constraint"))
00049 , object2( initData(&object2, "object2", "Second Object to Constraint")) 
00050 , mstate1(mm1), mstate2(mm2)
00051 {
00052 }
00053 
00054 template<class DataTypes1, class DataTypes2>
00055 MixedInteractionConstraint<DataTypes1, DataTypes2>::~MixedInteractionConstraint()
00056 {
00057 }
00058 
00059 template<class DataTypes1, class DataTypes2>
00060 void MixedInteractionConstraint<DataTypes1, DataTypes2>::init()
00061 {
00062     InteractionConstraint::init();
00063 }
00064 
00065 template<class DataTypes1, class DataTypes2>
00066 bool MixedInteractionConstraint<DataTypes1, DataTypes2>::isActive() const
00067 {
00068     if( endTime.getValue()<0 ) return true;
00069     return endTime.getValue()>getContext()->getTime();
00070 }
00071 
00072 template<class DataTypes1, class DataTypes2>
00073 void MixedInteractionConstraint<DataTypes1, DataTypes2>::projectResponse()
00074 {
00075     if( !isActive() ) return;
00076     if (mstate1 && mstate2)
00077         projectResponse(*mstate1->getDx(), *mstate2->getDx());
00078 }
00079 
00080 template<class DataTypes1, class DataTypes2>
00081 void MixedInteractionConstraint<DataTypes1, DataTypes2>::projectVelocity()
00082 {
00083     if( !isActive() ) return;
00084     if (mstate1 && mstate2)
00085         projectVelocity(*mstate1->getV(), *mstate2->getV());
00086 }
00087 
00088 template<class DataTypes1, class DataTypes2>
00089 void MixedInteractionConstraint<DataTypes1, DataTypes2>::projectPosition()
00090 {
00091     if( !isActive() ) return;
00092     if (mstate1 && mstate2)
00093         projectPosition(*mstate1->getX(), *mstate2->getX());
00094 }
00095 
00096 template<class DataTypes1, class DataTypes2>
00097 void MixedInteractionConstraint<DataTypes1, DataTypes2>::projectFreeVelocity()
00098 {
00099     if( !isActive() ) return;
00100     if (mstate1 && mstate2)
00101         projectVelocity(*mstate1->getVfree(), *mstate2->getVfree());
00102 }
00103 
00104 template<class DataTypes1, class DataTypes2>
00105 void MixedInteractionConstraint<DataTypes1, DataTypes2>::projectFreePosition()
00106 {
00107     if( !isActive() ) return;
00108     if (mstate1 && mstate2)
00109         projectPosition(*mstate1->getXfree(), *mstate2->getXfree());
00110 }
00111 
00112 template<class DataTypes1, class DataTypes2>
00113 void MixedInteractionConstraint<DataTypes1, DataTypes2>::applyConstraint(unsigned int &contactId)
00114 {
00115     if( !isActive() ) return;
00116     if (mstate1 && mstate2)
00117         applyConstraint(*mstate1->getC(), *mstate2->getC(), contactId);
00118 }
00119 
00120 } // namespace behavior
00121 
00122 } // namespace componentmodel
00123 
00124 } // namespace core
00125 
00126 } // namespace sofa
00127 
00128 #endif

Generated on Sun Nov 23 02:29:11 2008 for Sofa by  doxygen 1.5.7.1