Mapping.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_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         //cerr<<"Mapping<In,Out>::updateMapping(), *this->fromModel->getX() = "<<*this->fromModel->getX()<<endl;
00105         //cerr<<"Mapping<In,Out>::updateMapping(), *this->toModel->getX() = "<<*this->toModel->getX()<<endl;
00106     }
00107     if (this->toModel->getV()!=NULL && this->fromModel->getV()!=NULL)
00108     {
00109         applyJ(*this->toModel->getV(), *this->fromModel->getV());
00110     }
00111 }
00112 
00113 } // namespace core
00114 
00115 } // namespace sofa
00116 
00117 #endif

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