MBSim

Project Page
planewithfrustum.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: mschneider@users.berlios.de
18  */
19 
20 #ifndef _PLANEWITHFRUSTUM_H_
21 #define _PLANEWITHFRUSTUM_H_
22 
23 #include "fmatvec.h"
24 #include "mbsim/contour.h"
25 
26 namespace MBSim {
27 
35  class PlaneWithFrustum : public RigidContour {
36  public:
45  PlaneWithFrustum(const std::string &name) : RigidContour(name), rFrustumOnPlane(0), rFrustumOnTop(0), hFrustum(0), rho(0) {
46  }
47 
48  PlaneWithFrustum(const std::string &name, double rFrustumOnPlane_, double rFrustumOnTop_, double hFrustum_, double rho_) : RigidContour(name), rFrustumOnPlane(rFrustumOnPlane_), rFrustumOnTop(rFrustumOnTop_), hFrustum(hFrustum_), rho(rho_) {
49  checkInput();
50  }
51 
52  /* INHERITED INTERFACE OF ELEMENT */
53  std::string getType() const { return "PlaneWithFrustum"; }
54  /***************************************************/
55 
56  /* GETTER / SETTER */
57  double getFrustumRadiusOnPlane() {return rFrustumOnPlane; }
58  double getFrustumRadiusOnTop() {return rFrustumOnTop; }
59  double getFrustumHeight() {return hFrustum; }
60  double getRoundingRadius() {return rho; }
61  /***************************************************/
62 
63 #ifdef HAVE_OPENMBVCPPINTERFACE
64  void enableOpenMBV(bool enable=true);
65 #endif
66 
67  virtual void initializeUsingXML(TiXmlElement *element);
68 
69  private:
70  double rFrustumOnPlane;
71  double rFrustumOnTop;
72  double hFrustum;
73  double rho;
74 
75  void checkInput() {
76  assert(rFrustumOnTop<rFrustumOnPlane); //TODO
77  assert(rFrustumOnTop>1e-6); //TODO
78  assert(rho>1e-6);
79  assert(rho<fabs(hFrustum));
80  assert(rho<rFrustumOnTop);
81  }
82  };
83 }
84 
85 #endif /* _PLANEWITHFRUSTUM_H_ */