MixedInteractionConstraint.inl
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
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 }
00121
00122 }
00123
00124 }
00125
00126 }
00127
00128 #endif