MBSim

Project Page
circle.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 CIRCLE_H_
00021 #define CIRCLE_H_
00022 
00023 #include "fmatvec/fmatvec.h"
00024 #include "mbsim/contour.h"
00025 #include "mbsim/utils/eps.h"
00026 
00027 namespace MBSim {
00028 
00035   class Circle : public RigidContour {
00036     public:
00042       Circle(const std::string& name);
00043 
00049       Circle(const std::string& name, bool outCont_);
00050 
00057       Circle(const std::string& name, double r_, bool outCont_);
00058 
00062       virtual ~Circle();
00063 
00064       /* INHERITED INTERFACE OF ELEMENT */
00065       std::string getType() const { return "Circle"; }
00066       virtual void init(InitStage stage);
00067       /***************************************************/
00068 
00069       /* INHERITED INTERFACE OF CONTOUR */
00070       virtual double computeCurvature(ContourPointData &cp) { return curvature; }
00071       virtual fmatvec::Vec2 computeLagrangeParameter(const fmatvec::Vec3& WrPoint);
00072       /***************************************************/
00073 
00074       /* GETTER / SETTER */
00075       void setRadius(double r_);        
00076       void setOutCont(bool outCont_);
00077       double getRadius() const;
00078       bool getOutCont() const;
00079       /***************************************************/
00080 
00081 #ifdef HAVE_OPENMBVCPPINTERFACE
00082       void enableOpenMBV(bool enable=true);
00083 #endif
00084 
00085     virtual void initializeUsingXML(MBXMLUtils::TiXmlElement *element);
00086     virtual MBXMLUtils::TiXmlElement* writeXMLFile(MBXMLUtils::TiXmlNode *element);
00087 
00088     protected:
00092       double r;
00093 
00097       double curvature;
00098 
00099     private:
00103       bool outCont;     
00104   };
00105 
00106   inline void Circle::setRadius(double r_) { r = r_; outCont ? curvature = 1./r_ : curvature = -1./r_; }        
00107   inline void Circle::setOutCont(bool outCont_) { outCont = outCont_; if(fabs(r)>epsroot()) outCont ? curvature = 1./r : curvature = -1./r; }
00108   inline double Circle::getRadius() const { return r; }
00109   inline bool Circle::getOutCont() const { return outCont; }
00110 
00111 }
00112 
00113 #endif /* CIRCLE_H_ */
00114