MBSim

Project Page
circle.h
1 /* Copyright (C) 2004-2009 MBSim Development Team
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  * Contact: thschindler@users.berlios.de
18  */
19 
20 #ifndef CIRCLE_H_
21 #define CIRCLE_H_
22 
23 #include "fmatvec.h"
24 #include "mbsim/contour.h"
25 #include "mbsim/utils/eps.h"
26 
27 namespace MBSim {
28 
35  class Circle : public RigidContour {
36  public:
42  Circle(const std::string& name);
43 
49  Circle(const std::string& name, bool outCont_);
50 
57  Circle(const std::string& name, double r_, bool outCont_);
58 
62  virtual ~Circle();
63 
64  /* INHERITED INTERFACE OF ELEMENT */
65  std::string getType() const { return "Circle"; }
66  virtual void init(InitStage stage);
67  /***************************************************/
68 
69  /* INHERITED INTERFACE OF CONTOUR */
70  virtual double computeCurvature(ContourPointData &cp) { return curvature; }
71  virtual fmatvec::Vec computeLagrangeParameter(const fmatvec::Vec& WrPoint);
72  /***************************************************/
73 
74  /* GETTER / SETTER */
75  void setRadius(double r_);
76  void setOutCont(bool outCont_);
77  double getRadius() const;
78  bool getOutCont() const;
79  /***************************************************/
80 
81 #ifdef HAVE_OPENMBVCPPINTERFACE
82  void enableOpenMBV(bool enable=true);
83 #endif
84 
85  virtual void initializeUsingXML(TiXmlElement *element);
86 
87  protected:
91  double r;
92 
96  double curvature;
97 
98  private:
102  bool outCont;
103  };
104 
105  inline void Circle::setRadius(double r_) { r = r_; outCont ? curvature = 1./r_ : curvature = -1./r_; }
106  inline void Circle::setOutCont(bool outCont_) { outCont = outCont_; if(fabs(r)>epsroot()) outCont ? curvature = 1./r : curvature = -1./r; }
107  inline double Circle::getRadius() const { return r; }
108  inline bool Circle::getOutCont() const { return outCont; }
109 
110 }
111 
112 #endif /* CIRCLE_H_ */
113