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 :: Modules * 00020 * * 00021 * Authors: The SOFA Team and external contributors (see Authors.txt) * 00022 * * 00023 * Contact information: contact@sofa-framework.org * 00024 ******************************************************************************/ 00025 00026 /*************************************************************************** 00027 * * 00028 * This program is free software; you can redistribute it and/or modify * 00029 * it under the terms of the GNU General Public License as published by * 00030 * the Free Software Foundation; either version 2 of the License, or * 00031 * (at your option) any later version. * 00032 * * 00033 ***************************************************************************/ 00034 00035 //------------------------------------------------------------------------- 00036 // -- Description -- 00037 // LMLConstraint imports from a LML file (see LMLReader class) imposed displacements, 00038 // including translations and fixed points, and traduces it to sofa constraints. 00039 // It inherits from Constraint sofa core class. 00040 //------------------------------------------------------------------------- 00041 00042 #ifndef LMLCONSTRAINT_H 00043 #define LMLCONSTRAINT_H 00044 00045 00046 #include "sofa/core/componentmodel/behavior/Constraint.h" 00047 #include "sofa/core/componentmodel/behavior/MechanicalState.h" 00048 #include "sofa/core/VisualModel.h" 00049 00050 #include <vector> 00051 #include <map> 00052 00053 #include <Loads.h> 00054 00055 00056 namespace sofa 00057 { 00058 00059 namespace filemanager 00060 { 00061 00062 namespace pml 00063 { 00064 00065 using namespace sofa::core; 00066 using namespace sofa::core::componentmodel::behavior; 00067 using namespace std; 00068 00069 template<class DataTypes> 00070 class LMLConstraint : public Constraint<DataTypes>, public VisualModel 00071 { 00072 public : 00074 typedef typename DataTypes::VecCoord VecCoord; 00075 typedef typename DataTypes::VecDeriv VecDeriv; 00076 typedef typename DataTypes::VecCoord::iterator VecCoordIterator; 00077 typedef typename DataTypes::VecDeriv::iterator VecDerivIterator; 00078 typedef typename DataTypes::Coord Coord; 00079 typedef typename DataTypes::Deriv Deriv; 00080 00082 LMLConstraint(Loads* loadsList, const map<unsigned int, unsigned int> &atomIndexToDOFIndex, MechanicalState<DataTypes> *mm); 00083 00084 ~LMLConstraint(){ /*delete loads;*/} 00085 00087 std::vector<unsigned int> getTargets() {return targets;} 00088 00090 LMLConstraint<DataTypes>* addConstraint(unsigned int index, Deriv trans); 00091 LMLConstraint<DataTypes>* removeConstraint(int index); 00092 00094 void projectResponse(VecDeriv& dx); 00095 virtual void projectVelocity(VecDeriv& ){} 00096 virtual void projectPosition(VecCoord& x); 00097 00099 void draw(); 00100 void initTextures() { } 00101 void update() { } 00102 00103 private: 00104 00106 void fixDOF(int index, int axe); 00107 00108 MechanicalState<DataTypes> * mmodel; 00110 std::vector<unsigned int> targets; 00112 VecDeriv translations; 00114 VecDeriv directionsNULLs; 00115 VecDeriv initPos; 00116 00118 Loads * loads; 00120 map<unsigned int, unsigned int> atomToDOFIndexes; 00121 }; 00122 00123 } 00124 } 00125 } 00126 #endif //LMLCONSTRAINT_H
1.5.7.1