PMLStiffSpringForceField.h

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 :: 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 //  PMLStiffSpringForceField translate an FEM object from Physical Model structure 
00038 //  to sofa structure, using StiffSpringForceField. 
00039 //  It inherits from PMLBody abstract class.
00040 //-------------------------------------------------------------------------
00041 
00042 
00043 #ifndef PMLSTIFFSPRINGFORCEFIELD_H
00044 #define PMLSTIFFSPRINGFORCEFIELD_H
00045 
00046 #include "PMLBody.h"
00047 
00048 #include <StructuralComponent.h>
00049 #include <sofa/core/componentmodel/topology/BaseMeshTopology.h>
00050 #include <sofa/component/topology/MeshTopology.h>
00051 #include <sofa/component/collision/TriangleModel.h>
00052 #include <sofa/component/forcefield/MeshSpringForceField.h>
00053 
00054 
00055 #include <map>
00056 
00057 
00058 namespace sofa
00059 {
00060 
00061 namespace filemanager
00062 {
00063 
00064 namespace pml
00065 {
00066 
00067 using namespace sofa::component::topology;
00068 using namespace sofa::component::collision;
00069 using namespace sofa::component::forcefield;
00070 using namespace std;
00071 
00072 class PMLStiffSpringForceField: public PMLBody
00073 {
00074 public :
00075 
00076     PMLStiffSpringForceField(StructuralComponent* body, GNode * parent);
00077 
00078     ~PMLStiffSpringForceField();
00079 
00080     string isTypeOf() { return "StiffSpring"; }
00081 
00083     TriangleModel * getTriangleModel() { return tmodel; }
00084     //LineModel * getLineModel() { return lmodel; }
00085     //PointModel * getPointModel() { return pmodel; }
00086 
00088     bool FusionBody(PMLBody*);
00089 
00090     Vector3 getDOF(unsigned int index);
00091     GNode* getPointsNode() {return parentNode;}
00092 
00093 private :
00094 
00096     void createMechanicalState(StructuralComponent* body);
00097     void createTopology(StructuralComponent* body);
00098     void createMass(StructuralComponent* body);
00099     void createVisualModel(StructuralComponent* body);
00100     void createForceField();
00101     void createCollisionModel();
00102 
00103     // extract edges to a list of lines
00104     BaseMeshTopology::Line * hexaToLines(Cell* pCell);
00105     BaseMeshTopology::Line * tetraToLines(Cell* pCell);
00106     BaseMeshTopology::Line * triangleToLines(Cell* pCell);
00107     BaseMeshTopology::Line * quadToLines(Cell* pCell);
00108 
00109     //initialization of properties
00110     void initMass(string m);
00111     void initDensity(string m);
00112 
00113     //structure
00114     MeshSpringForceField<Vec3Types> *Sforcefield;
00115     TriangleModel * tmodel;
00116     //LineModel * lmodel;
00117     //PointModel * pmodel;
00118 
00119     //members for the mass (only one of the 2 vectors is filled)
00120     std::vector<SReal> massList;
00121     std::vector<SReal> density;
00122 
00123     //properties
00124     SReal  ks;          // spring stiffness
00125     SReal  kd;          // damping factor
00126 
00127 };
00128 
00129 }
00130 }
00131 }
00132 
00133 #endif
00134 

Generated on Sun Nov 23 03:56:17 2008 for Sofa by  doxygen 1.5.7.1