MechanicalMapping.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_MECHANICALMAPPING_INL
00028 #define SOFA_CORE_COMPONENTMODEL_BEHAVIOR_MECHANICALMAPPING_INL
00029
00030 #include <sofa/core/Mapping.h>
00031 #include <sofa/core/Mapping.inl>
00032 #include <sofa/core/componentmodel/behavior/MechanicalMapping.h>
00033 #include <iostream>
00034
00035 using std::cerr;
00036 using std::endl;
00037
00038 namespace sofa
00039 {
00040
00041 namespace core
00042 {
00043
00044 namespace componentmodel
00045 {
00046
00047 namespace behavior
00048 {
00049
00050 template <class In, class Out>
00051 MechanicalMapping<In,Out>::MechanicalMapping(In* from, Out* to)
00052 : Mapping<In,Out>(from, to)
00053 , f_isMechanical( initData( &f_isMechanical, true, "isMechanical", "set to false if this mapping should only be used as a regular mapping instead of a mechanical mapping" ) )
00054 {
00055 }
00056
00057 template <class In, class Out>
00058 MechanicalMapping<In,Out>::~MechanicalMapping()
00059 {
00060 }
00061
00062 template <class In, class Out>
00063 BaseMechanicalState* MechanicalMapping<In,Out>::getMechFrom()
00064 {
00065 return this->fromModel;
00066 }
00067
00068 template <class In, class Out>
00069 BaseMechanicalState* MechanicalMapping<In,Out>::getMechTo()
00070 {
00071 return this->toModel;
00072 }
00073
00074 template <class In, class Out>
00075 bool MechanicalMapping<In,Out>::isMechanical()
00076 {
00077 return this->f_isMechanical.getValue();
00078 }
00079
00080 template <class In, class Out>
00081 void MechanicalMapping<In,Out>::init()
00082 {
00083 this->updateMapping();
00084 propagateXfree();
00085 }
00086
00087 template <class In, class Out>
00088 void MechanicalMapping<In,Out>::propagateX()
00089 {
00090 if (this->fromModel!=NULL && this->toModel->getX()!=NULL && this->fromModel->getX()!=NULL)
00091 apply(*this->toModel->getX(), *this->fromModel->getX());
00092 }
00093
00094 template <class In, class Out>
00095 void MechanicalMapping<In,Out>::propagateV()
00096 {
00097 if (this->fromModel!=NULL && this->toModel->getV()!=NULL && this->fromModel->getV()!=NULL)
00098 applyJ(*this->toModel->getV(), *this->fromModel->getV());
00099 }
00100
00101 template <class In, class Out>
00102 void MechanicalMapping<In,Out>::propagateDx()
00103 {
00104 if (this->fromModel!=NULL && this->toModel->getDx()!=NULL && this->fromModel->getDx()!=NULL)
00105 applyJ(*this->toModel->getDx(), *this->fromModel->getDx());
00106 }
00107
00108 template <class In, class Out>
00109 void MechanicalMapping<In,Out>::propagateXfree()
00110 {
00111 if (this->fromModel!=NULL && this->toModel->getXfree()!=NULL && this->fromModel->getXfree()!=NULL)
00112 apply(*this->toModel->getXfree(), *this->fromModel->getXfree());
00113 }
00114
00115
00116 template <class In, class Out>
00117 void MechanicalMapping<In,Out>::accumulateForce()
00118 {
00119
00120
00121
00122 if (this->fromModel!=NULL && this->toModel->getF()!=NULL && this->fromModel->getF()!=NULL)
00123 applyJT(*this->fromModel->getF(), *this->toModel->getF());
00124 }
00125
00126 template <class In, class Out>
00127 void MechanicalMapping<In,Out>::accumulateDf()
00128 {
00129 if (this->fromModel!=NULL && this->toModel->getF()!=NULL && this->fromModel->getF()!=NULL)
00130 applyJT(*this->fromModel->getF(), *this->toModel->getF());
00131 }
00132
00133 template <class In, class Out>
00134 void MechanicalMapping<In,Out>::accumulateConstraint()
00135 {
00136 if (this->fromModel!=NULL && this->toModel->getC()!=NULL && this->fromModel->getC()!=NULL)
00137 {
00138 applyJT(*this->fromModel->getC(), *this->toModel->getC());
00139
00140
00141 std::vector<unsigned int>::iterator it = this->toModel->getConstraintId().begin();
00142 std::vector<unsigned int>::iterator itEnd = this->toModel->getConstraintId().end();
00143
00144 while (it != itEnd)
00145 {
00146 this->fromModel->setConstraintId(*it);
00147 it++;
00148 }
00149 }
00150 }
00151
00152 }
00153
00154 }
00155
00156 }
00157
00158 }
00159
00160 #endif