All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
openmbv_utils.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: martin.o.foerg@googlemail.com
18  */
19 
20 #ifndef _OPENMBV_UTILS_H_
21 #define _OPENMBV_UTILS_H_
22 
23 #include <fmatvec/fmatvec.h>
24 #include <openmbvcppinterface/arrow.h>
25 #include <openmbvcppinterface/frame.h>
26 #include <openmbvcppinterface/sphere.h>
27 #include <openmbvcppinterface/cuboid.h>
28 #include <openmbvcppinterface/frustum.h>
29 #include <openmbvcppinterface/extrusion.h>
30 #include <openmbvcppinterface/coilspring.h>
31 #include <openmbvcppinterface/indexedfaceset.h>
32 
33 namespace MBSim {
34 
35  class OpenMBVBody {
36  protected:
37  std::string id;
38  public:
39  OpenMBVBody() { }
40  void initializeObject(const std::shared_ptr<OpenMBV::Body> &object);
41  void initializeUsingXML(xercesc::DOMElement *element);
42  };
43 
45  protected:
46  fmatvec::Vec3 dc;
47  double tp;
48  public:
49  OpenMBVDynamicColoredBody(const fmatvec::Vec3 &dc_="[-1;1;1]", double tp_=0) : dc(dc_), tp(tp_) { }
50  void initializeObject(const std::shared_ptr<OpenMBV::DynamicColoredBody> &object);
51  void initializeUsingXML(xercesc::DOMElement *element);
52  };
53 
55  protected:
56  OpenMBV::Arrow::Type type;
57  OpenMBV::Arrow::ReferencePoint refPoint;
58  double sL, sS;
59  public:
60  OpenMBVArrow(const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0, const OpenMBV::Arrow::Type &type_=OpenMBV::Arrow::toHead, const OpenMBV::Arrow::ReferencePoint &refPoint_=OpenMBV::Arrow::fromPoint, double sL_=1, double sS_=1, double minCol_=0, double maxCol_=1) : OpenMBVDynamicColoredBody(dc,tp), type(type_), refPoint(refPoint_), sL(sL_), sS(sS_) { }
61  void initializeUsingXML(xercesc::DOMElement *element);
62  void initializeObject(const std::shared_ptr<OpenMBV::Arrow> &object);
63  std::shared_ptr<OpenMBV::Arrow> createOpenMBV(xercesc::DOMElement* e=0);
64  };
65 
67  protected:
68  double size, offset;
69  public:
70  OpenMBVFrame(double size_=1, double offset_=1, const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0) : OpenMBVDynamicColoredBody(dc,tp), size(size_), offset(offset_) { }
71  void initializeUsingXML(xercesc::DOMElement *element);
72  void initializeObject(const std::shared_ptr<OpenMBV::Frame> &object);
73  std::shared_ptr<OpenMBV::Frame> createOpenMBV(xercesc::DOMElement* e=0);
74  };
75 
77  protected:
78  double r;
79  std::string xml;
80  public:
81  OpenMBVSphere(double r_=1, const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0, std::string xml_="radius") : OpenMBVDynamicColoredBody(dc,tp), r(r_), xml(xml_) { }
82  void initializeUsingXML(xercesc::DOMElement *element);
83  void initializeObject(const std::shared_ptr<OpenMBV::Sphere> &object);
84  std::shared_ptr<OpenMBV::Sphere> createOpenMBV(xercesc::DOMElement* e=0);
85  };
86 
88  protected:
89  double l;
90  public:
91  OpenMBVLine(double l_=1, const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0) : OpenMBVDynamicColoredBody(dc,tp), l(l_) { }
92  void initializeUsingXML(xercesc::DOMElement *element);
93  void initializeObject(const std::shared_ptr<OpenMBV::Cuboid> &object);
94  std::shared_ptr<OpenMBV::Cuboid> createOpenMBV(xercesc::DOMElement* e=0);
95  };
96 
98  protected:
99  fmatvec::Vec2 l;
100  public:
101  OpenMBVPlane(const fmatvec::Vec2 &l_=fmatvec::Vec2(fmatvec::INIT,1.), const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0) : OpenMBVDynamicColoredBody(dc,tp), l(l_) { }
102  void initializeUsingXML(xercesc::DOMElement *element);
103  void initializeObject(const std::shared_ptr<OpenMBV::Cuboid> &object);
104  std::shared_ptr<OpenMBV::Cuboid> createOpenMBV(xercesc::DOMElement* e=0);
105  };
106 
108  protected:
109  fmatvec::Vec3 l;
110  public:
111  OpenMBVCuboid(const fmatvec::Vec3 &l_=fmatvec::Vec3(fmatvec::INIT,1.), const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0) : OpenMBVDynamicColoredBody(dc,tp), l(l_) { }
112  void initializeUsingXML(xercesc::DOMElement *element);
113  void initializeObject(const std::shared_ptr<OpenMBV::Cuboid> &object);
114  std::shared_ptr<OpenMBV::Cuboid> createOpenMBV(xercesc::DOMElement* e=0);
115  };
116 
118  protected:
119  double r;
120  public:
121  OpenMBVCircle(double r_=1, const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0) : OpenMBVDynamicColoredBody(dc,tp), r(r_) { }
122  void initializeUsingXML(xercesc::DOMElement *element);
123  void initializeObject(const std::shared_ptr<OpenMBV::Frustum> &object);
124  std::shared_ptr<OpenMBV::Frustum> createOpenMBV(xercesc::DOMElement* e=0);
125  };
126 
128  protected:
129  double t, b, h;
130  public:
131  OpenMBVFrustum(double t_=1, double b_=1, double h_=1, const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0) : OpenMBVDynamicColoredBody(dc,tp), t(t_), b(b_), h(h_) { }
132  void initializeUsingXML(xercesc::DOMElement *element);
133  void initializeObject(const std::shared_ptr<OpenMBV::Frustum> &object);
134  std::shared_ptr<OpenMBV::Frustum> createOpenMBV(xercesc::DOMElement* e=0);
135  };
136 
138  protected:
139  double h;
140  public:
141  OpenMBVExtrusion(double h_=1, const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0) : OpenMBVDynamicColoredBody(dc,tp), h(h_) { }
142  void initializeUsingXML(xercesc::DOMElement *element);
143  void initializeObject(const std::shared_ptr<OpenMBV::Extrusion> &object);
144  std::shared_ptr<OpenMBV::Extrusion> createOpenMBV(xercesc::DOMElement* e=0);
145  };
146 
148  protected:
149  double r, cr, sf, n, l, minCol, maxCol;
150  OpenMBV::CoilSpring::Type type;
151  public:
152  OpenMBVCoilSpring(double r_=1, double cr_=-1, double sf_=1, double n_=3, double l_=-1, OpenMBV::CoilSpring::Type type_=OpenMBV::CoilSpring::tube, const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0, double minCol_=0, double maxCol_=1) : OpenMBVDynamicColoredBody(dc,tp), r(r_), cr(cr_), sf(sf_), n(n_), l(l_), minCol(minCol_), maxCol(maxCol_), type(type_) { }
153  void initializeUsingXML(xercesc::DOMElement *element);
154  void initializeObject(const std::shared_ptr<OpenMBV::CoilSpring> &object);
155  std::shared_ptr<OpenMBV::CoilSpring> createOpenMBV(xercesc::DOMElement* e=0);
156  };
157 
159  public:
160  OpenMBVIndexedFaceSet(const fmatvec::Vec3 &dc="[-1;1;1]", double tp=0) : OpenMBVDynamicColoredBody(dc,tp) { }
161  std::shared_ptr<OpenMBV::IndexedFaceSet> createOpenMBV(xercesc::DOMElement* e=0);
162  };
163 
164 }
165 
166 #endif
Definition: openmbv_utils.h:147
Definition: openmbv_utils.h:87
Definition: openmbv_utils.h:97
Definition: openmbv_utils.h:54
Definition: openmbv_utils.h:76
Definition: openmbv_utils.h:107
Definition: openmbv_utils.h:66
Definition: openmbv_utils.h:44
Definition: openmbv_utils.h:137
Definition: openmbv_utils.h:158
Definition: openmbv_utils.h:127
Definition: openmbv_utils.h:117
Definition: openmbv_utils.h:35

Impressum / Disclaimer / Datenschutz Generated by doxygen 1.8.5 Valid HTML