MBSim

Project Page
contour1s_analytical.h
00001 /* Copyright (C) 2004-2009 MBSim Development Team
00002  *
00003  * This library is free software; you can redistribute it and/or 
00004  * modify it under the terms of the GNU Lesser General Public 
00005  * License as published by the Free Software Foundation; either 
00006  * version 2.1 of the License, or (at your option) any later version. 
00007  *  
00008  * This library is distributed in the hope that it will be useful, 
00009  * but WITHOUT ANY WARRANTY; without even the implied warranty of 
00010  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
00011  * Lesser General Public License for more details. 
00012  *  
00013  * You should have received a copy of the GNU Lesser General Public 
00014  * License along with this library; if not, write to the Free Software 
00015  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
00016  *
00017  * Contact: thschindler@users.berlios.de
00018  */
00019 
00020 #ifndef _CONTOUR1S_ANALYTICAL_H_
00021 #define _CONTOUR1S_ANALYTICAL_H_
00022 
00023 #include "mbsim/contours/contour1s.h"
00024 
00025 #ifdef HAVE_OPENMBVCPPINTERFACE
00026 #include <mbsim/utils/openmbv_utils.h>
00027 #endif
00028 
00029 namespace MBSim {
00030 
00031   class ContourFunction1s;
00032   class ContactKinematics;
00033 
00040   class Contour1sAnalytical : public Contour1s {
00041     public:
00046       Contour1sAnalytical(const std::string &name="") : Contour1s(name)
00047 # ifdef HAVE_OPENMBVCPPINTERFACE
00048                                                      , openMBVRigidBody(0)
00049 # endif
00050                                                      {}
00051 
00055       virtual ~Contour1sAnalytical();
00056 
00057       /* INHERITED INTERFACE OF ELEMENT */
00058       std::string getType() const { return "Contour1sAnalytical"; }
00059       virtual void plot(double t, double dt = 1);
00060       /***************************************************/
00061 
00062       /* INHERITED INTERFACE OF CONTOUR */
00063       virtual void updateKinematicsForFrame(ContourPointData &cp, Frame::Feature ff);
00064       virtual void updateJacobiansForFrame(ContourPointData &cp, int j=0);
00065       virtual void init(InitStage stage);
00066       virtual double computeCurvature(ContourPointData &cp);
00067       virtual double computeDistance(const double s, const int order=0);
00068       /***************************************************/
00069 
00070       /* INHERITED INTERFACE OF CONTOURCONTINUUM */
00071       virtual void computeRootFunctionPosition(ContourPointData &cp) { updateKinematicsForFrame(cp,Frame::position); }
00072       virtual void computeRootFunctionFirstTangent(ContourPointData &cp) { updateKinematicsForFrame(cp,Frame::firstTangent); }
00073       virtual void computeRootFunctionNormal(ContourPointData &cp) { updateKinematicsForFrame(cp,Frame::normal); }
00074       virtual void computeRootFunctionSecondTangent(ContourPointData &cp) { updateKinematicsForFrame(cp,Frame::secondTangent); }
00075       /***************************************************/
00076 
00077       /* GETTER / SETTER */
00078       void setContourFunction1s(ContourFunction1s* f) { funcCrPC = f; }
00079       ContourFunction1s* getContourFunction1s() { return funcCrPC; }
00080       /***************************************************/
00081 
00082 #ifdef HAVE_OPENMBVCPPINTERFACE
00083       BOOST_PARAMETER_MEMBER_FUNCTION( (void), enableOpenMBV, tag, (optional (diffuseColor,(const fmatvec::Vec3&),"[-1;1;1]")(transparency,(double),0))) { 
00084         OpenMBVExtrusion ombv(1,diffuseColor,transparency);
00085         openMBVRigidBody=ombv.createOpenMBV(); 
00086       }
00087 #endif
00088       
00089       virtual void initializeUsingXML(xercesc::DOMElement *element);
00090       virtual xercesc::DOMElement* writeXMLFile(xercesc::DOMNode *element);
00091 
00097       ContactKinematics * findContactPairingWith(std::string type0, std::string type1);
00098 
00099     protected:
00100       ContourFunction1s * funcCrPC;
00101 #ifdef HAVE_OPENMBVCPPINTERFACE
00102       OpenMBV::RigidBody *openMBVRigidBody;
00103 #endif
00104   };
00105 
00106 }
00107 
00108 #endif /* _CONTOUR1S_ANALYTICAL_H_ */
00109