Mapping.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_MAPPING_INL
00028 #define SOFA_CORE_MAPPING_INL
00029
00030 #include <sofa/core/Mapping.h>
00031 #include <iostream>
00032 using std::cerr;
00033 using std::endl;
00034
00035 namespace sofa
00036 {
00037
00038 namespace core
00039 {
00040
00041 template <class In, class Out>
00042 Mapping<In,Out>::Mapping(In* from, Out* to)
00043 : fromModel(from), toModel(to),
00044 object1(initData(&object1, std::string("../.."), "object1", "First object to map")),
00045 object2(initData(&object2, std::string(".."), "object2", "Second object to map"))
00046 {
00047 }
00048
00049 template <class In, class Out>
00050 Mapping<In,Out>::~Mapping()
00051 {
00052 }
00053
00054 template <class In, class Out>
00055 In* Mapping<In,Out>::getFromModel()
00056 {
00057 return this->fromModel;
00058 }
00059
00060 template <class In, class Out>
00061 Out* Mapping<In,Out>::getToModel()
00062 {
00063 return this->toModel;
00064 }
00065
00066 template <class In, class Out>
00067 objectmodel::BaseObject* Mapping<In,Out>::getFrom()
00068 {
00069 return this->fromModel;
00070 }
00071
00072 template <class In, class Out>
00073 objectmodel::BaseObject* Mapping<In,Out>::getTo()
00074 {
00075 return this->toModel;
00076 }
00077
00078 template <class In, class Out>
00079 void Mapping<In,Out>::init()
00080 {
00081 this->updateMapping();
00082 }
00083
00084 template <class In, class Out>
00085 void Mapping<In,Out>::disable()
00086 {
00087 }
00088
00089 template <class In, class Out>
00090 void Mapping<In,Out>::setModels(In* from, Out* to){
00091 this->fromModel = from;
00092 this->toModel = to;
00093 }
00094
00095 template <class In, class Out>
00096 void Mapping<In,Out>::updateMapping()
00097 {
00098 if (this->toModel == NULL || this->fromModel == NULL)
00099 return;
00100
00101 if (this->toModel->getX()!=NULL && this->fromModel->getX()!=NULL)
00102 {
00103 apply(*this->toModel->getX(), *this->fromModel->getX());
00104
00105
00106 }
00107 if (this->toModel->getV()!=NULL && this->fromModel->getV()!=NULL)
00108 {
00109 applyJ(*this->toModel->getV(), *this->fromModel->getV());
00110 }
00111 }
00112
00113 }
00114
00115 }
00116
00117 #endif