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 // C++ Interface: EdgeSetController 00027 // 00028 // Description: 00029 // 00030 // 00031 // Author: Pierre-Jean Bensoussan, Digital Trainers (2008) 00032 // 00033 // Copyright: See COPYING file that comes with this distribution 00034 // 00035 // 00036 00037 #ifndef SOFA_COMPONENT_CONTROLLER_EDGESETCONTROLLER_H 00038 #define SOFA_COMPONENT_CONTROLLER_EDGESETCONTROLLER_H 00039 00040 #include <sofa/component/controller/MechanicalStateController.h> 00041 #include <sofa/component/topology/EdgeSetTopologyModifier.h> 00042 00043 00044 namespace sofa 00045 { 00046 00047 namespace component 00048 { 00049 namespace topology{ 00050 template <class T> 00051 class EdgeSetGeometryAlgorithms; 00052 00053 class EdgeSetTopologyModifier; 00054 } 00055 00056 namespace controller 00057 { 00058 00064 template<class DataTypes> 00065 class EdgeSetController : public MechanicalStateController<DataTypes> 00066 { 00067 public: 00068 typedef typename DataTypes::VecCoord VecCoord; 00069 typedef typename DataTypes::VecDeriv VecDeriv; 00070 typedef typename DataTypes::Coord Coord ; 00071 typedef typename DataTypes::Deriv Deriv ; 00072 typedef typename Coord::value_type Real ; 00073 00074 typedef MechanicalStateController<DataTypes> Inherit; 00075 00079 EdgeSetController(); 00080 00084 virtual ~EdgeSetController(){}; 00085 00089 void init(); 00090 00095 00099 void onMouseEvent(core::objectmodel::MouseEvent *); 00100 00101 void onKeyPressedEvent(core::objectmodel::KeypressedEvent *); 00102 00103 00107 void onBeginAnimationStep(); 00108 00110 00115 00116 00118 00122 void applyController(void); 00123 00127 void modifyTopology(void); 00128 00129 virtual std::string getTemplateName() const 00130 { 00131 return templateName(this); 00132 } 00133 00134 static std::string templateName(const EdgeSetController<DataTypes>* = NULL) 00135 { 00136 return DataTypes::Name(); 00137 } 00141 void draw(); 00142 00143 protected: 00144 Real step; 00145 00146 sofa::core::componentmodel::topology::BaseMeshTopology* _topology; 00147 sofa::component::topology::EdgeSetGeometryAlgorithms<DataTypes>* edgeGeo; 00148 sofa::component::topology::EdgeSetTopologyModifier* edgeMod; 00149 00150 00151 00152 Real edge0RestedLength; 00153 00154 }; 00155 00156 } // namespace controller 00157 00158 } // namespace component 00159 00160 } // namespace sofa 00161 00162 #endif // SOFA_COMPONENT_CONTROLLER_EDGESETCONTROLLER_H
1.5.7.1