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 // LMLForce imports from a LML file (see LMLReader class) the forces 00038 // applied on DOFs, and traduces it to sofa Forcefield. 00039 // It inherits from ForceField sofa core class. 00040 //------------------------------------------------------------------------- 00041 00042 #ifndef LMLFORCE_H 00043 #define LMLFORCE_H 00044 00045 #include <Loads.h> 00046 00047 #include "sofa/core/componentmodel/behavior/ForceField.h" 00048 #include "sofa/core/componentmodel/behavior/MechanicalState.h" 00049 #include "sofa/core/VisualModel.h" 00050 00051 #include <map> 00052 00053 00054 namespace sofa 00055 { 00056 00057 namespace filemanager 00058 { 00059 00060 namespace pml 00061 { 00062 00063 using namespace sofa::core; 00064 using namespace sofa::core::componentmodel::behavior; 00065 using namespace std; 00066 00067 template<class DataTypes> 00068 class LMLForce : public ForceField<DataTypes>, public VisualModel 00069 { 00070 public : 00072 typedef typename DataTypes::VecCoord VecCoord; 00073 typedef typename DataTypes::VecDeriv VecDeriv; 00074 typedef typename DataTypes::VecCoord::iterator VecCoordIterator; 00075 typedef typename DataTypes::VecDeriv::iterator VecDerivIterator; 00076 typedef typename DataTypes::Coord Coord; 00077 typedef typename DataTypes::Deriv Deriv; 00078 00080 LMLForce(MechanicalState<DataTypes> *mm = NULL) 00081 : ForceField<DataTypes>(mm) 00082 {} 00083 LMLForce(Loads* loadsList, const map<unsigned int, unsigned int> &atomIndexToDOFIndex, MechanicalState<DataTypes> *mm); 00084 00085 ~LMLForce(){ /*delete loads;*/} 00086 00088 std::vector<unsigned int> getTargets() {return targets;} 00089 00091 void addTarget(unsigned int i) { targets.push_back(i); forces.push_back(Deriv() ); } 00092 00094 virtual void addForce (VecDeriv& f, const VecCoord& x, const VecDeriv& v); 00095 virtual void addDForce (VecDeriv& , const VecDeriv& ){} 00096 virtual double getPotentialEnergy(const VecCoord& ){return 0;} 00097 00099 void draw(); 00100 void initTextures() { } 00101 void update() { } 00102 00103 protected: 00104 00105 MechanicalState<DataTypes> * mmodel; 00107 std::vector<unsigned int> targets; 00109 VecDeriv forces; 00111 Loads* loads; 00113 map<unsigned int, unsigned int> atomToDOFIndexes; 00114 00115 }; 00116 00117 } 00118 } 00119 } 00120 #endif 00121
1.5.7.1