MIRA
Geometry.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
47 #ifndef _MIRA_MODEL_GEOMETRY_H_
48 #define _MIRA_MODEL_GEOMETRY_H_
49 
50 #include <transform/Pose.h>
51 
52 #include <geometry/Rect.h>
53 #include <geometry/Polygon.h>
54 
55 namespace mira { namespace model {
56 
58 
64 class Geometry : public Object
65 {
67 public:
68 
69  virtual ~Geometry() {}
70 
71 public:
72 
80  virtual Polygon2f getFootprint(const RigidTransform3f& origin) const = 0;
81 
88  virtual Box3f getBoundingBox(const RigidTransform3f& origin) const = 0;
89 
90 };
91 
93 typedef boost::shared_ptr<Geometry> GeometryPtr;
94 
96 
101 class Box : public Geometry
102 {
104 public:
105 
106  EIGEN_MAKE_ALIGNED_OPERATOR_NEW
107 
108  template<typename Reflector>
109  void reflect(Reflector& r)
110  {
111  r.property("Size", size, "The size of the box");
112  }
113 
115  virtual Polygon2f getFootprint(const RigidTransform3f& origin) const;
117  virtual Box3f getBoundingBox(const RigidTransform3f& origin) const;
118 
120 };
121 
122 typedef boost::shared_ptr<Box> BoxPtr;
123 
125 
132 class Cone : public Geometry
133 {
135 public:
136  template<typename Reflector>
137  void reflect(Reflector& r)
138  {
139  r.property("Radius", radius, "The radius of the cone");
140  r.property("Length", length, "The length of the cone");
141  }
142 
144  virtual Polygon2f getFootprint(const RigidTransform3f& origin) const;
146  virtual Box3f getBoundingBox(const RigidTransform3f& origin) const;
147 
148  float radius;
149  float length;
150 };
151 
152 typedef boost::shared_ptr<Cone> ConePtr;
153 
155 
161 class Cylinder : public Geometry
162 {
164 public:
165  template<typename Reflector>
166  void reflect(Reflector& r)
167  {
168  r.property("Radius", radius, "The radius of the cylinder");
169  r.property("Length", length, "The length of the cylinder");
170  }
171 
173  virtual Polygon2f getFootprint(const RigidTransform3f& origin) const;
175  virtual Box3f getBoundingBox(const RigidTransform3f& origin) const;
176 
177  float radius;
178  float length;
179 };
180 
181 typedef boost::shared_ptr<Cylinder> CylinderPtr;
182 
184 
189 class Sphere : public Geometry
190 {
192 public:
193  template<typename Reflector>
194  void reflect(Reflector& r)
195  {
196  r.property("Radius", radius, "The radius of the sphere");
197  }
198 
200  virtual Polygon2f getFootprint(const RigidTransform3f& origin) const;
202  virtual Box3f getBoundingBox(const RigidTransform3f& origin) const;
203 
204  float radius;
205 };
206 
207 typedef boost::shared_ptr<Sphere> SpherePtr;
208 
210 
215 class Mesh : public Geometry
216 {
218 public:
219  template<typename Reflector>
220  void reflect(Reflector& r)
221  {
222  r.property("Filename", filename, "The filename of the mesh");
223  r.property("Scale", scale, "The scale factor of the mesh", 1.0f);
224  }
225 
227  virtual Polygon2f getFootprint(const RigidTransform3f& origin) const;
229  virtual Box3f getBoundingBox(const RigidTransform3f& origin) const;
230 
231  std::string filename;
232  float scale;
233 };
234 
235 typedef boost::shared_ptr<Mesh> MeshPtr;
236 
238 
243 class Polygon : public Geometry
244 {
246 public:
247  template<typename Reflector>
248  void reflect(Reflector& r)
249  {
250  r.member("Polygon", polygon, "The polygon geometry");
251  }
252 
254  virtual Polygon2f getFootprint(const RigidTransform3f& origin) const;
260  virtual Box3f getBoundingBox(const RigidTransform3f& origin) const;
261 
263 };
264 
265 typedef boost::shared_ptr<Polygon> PolygonPtr;
266 
268 
269 }}
270 
271 #endif
void reflect(Reflector &r)
Definition: Geometry.h:248
void reflect(Reflector &r)
Definition: Geometry.h:194
virtual Box3f getBoundingBox(const RigidTransform3f &origin) const
Implementation of Geometry::getBoundingBox.
virtual Box3f getBoundingBox(const RigidTransform3f &origin) const =0
Computes the axis aligned bounding box of the geometry primitive depending on the pose of the primiti...
Size3f size
The size of the box.
Definition: Geometry.h:119
boost::shared_ptr< Box > BoxPtr
Definition: Geometry.h:122
virtual Polygon2f getFootprint(const RigidTransform3f &origin) const
Implementation of Geometry::getFootprint.
Cone representation The origin of the cone is located at the center of its base circle.
Definition: Geometry.h:132
float length
The length of the cone.
Definition: Geometry.h:149
virtual Box3f getBoundingBox(const RigidTransform3f &origin) const
Implementation of Geometry::getBoundingBox.
virtual Box3f getBoundingBox(const RigidTransform3f &origin) const
Implementation of Geometry::getBoundingBox.
virtual ~Geometry()
Definition: Geometry.h:69
float radius
The radius of the cone.
Definition: Geometry.h:148
float radius
The radius of the cylinder.
Definition: Geometry.h:177
void reflect(Reflector &r)
Definition: Geometry.h:166
virtual Box3f getBoundingBox(const RigidTransform3f &origin) const
Implementation of Geometry::getBoundingBox.
virtual Box3f getBoundingBox(const RigidTransform3f &origin) const
The polygon is 2D, hence its bounding box would be 2D too, which is still empty in 3D...
virtual Polygon2f getFootprint(const RigidTransform3f &origin) const
Implementation of Geometry::getFootprint.
#define MIRA_ABSTRACT_OBJECT(classIdentifier)
virtual Box3f getBoundingBox(const RigidTransform3f &origin) const
Implementation of Geometry::getBoundingBox.
virtual Polygon2f getFootprint(const RigidTransform3f &origin) const
Implementation of Geometry::getFootprint.
Polygon representation The vertices of the polygon are given relative to its origin.
Definition: Geometry.h:243
Base class for all geometric representations of a rigid model part (link).
Definition: Geometry.h:64
virtual Polygon2f getFootprint(const RigidTransform3f &origin) const
Implementation of Geometry::getFootprint.
boost::shared_ptr< Cylinder > CylinderPtr
Definition: Geometry.h:181
Spherical representation The origin of the sphere is at its center.
Definition: Geometry.h:189
boost::shared_ptr< Polygon > PolygonPtr
Definition: Geometry.h:265
float scale
The scale factor of the mesh.
Definition: Geometry.h:232
boost::shared_ptr< Geometry > GeometryPtr
pointer to a geometric representation
Definition: Geometry.h:93
#define MIRA_OBJECT(classIdentifier)
float length
The length of the cylinder.
Definition: Geometry.h:178
boost::shared_ptr< Mesh > MeshPtr
Definition: Geometry.h:235
EIGEN_MAKE_ALIGNED_OPERATOR_NEW void reflect(Reflector &r)
Definition: Geometry.h:109
Cylinder representation The origin is in the center of the cylinder.
Definition: Geometry.h:161
void reflect(Reflector &r)
Definition: Geometry.h:137
boost::shared_ptr< Cone > ConePtr
Definition: Geometry.h:152
Polygon2f polygon
The polygon geometry.
Definition: Geometry.h:262
boost::shared_ptr< Sphere > SpherePtr
Definition: Geometry.h:207
boost::geometry::model::ring< Point2f > Polygon2f
void reflect(Reflector &r)
Definition: Geometry.h:220
Box representation The box is axis aligned and its origin is at the center of the box...
Definition: Geometry.h:101
Mesh representation The vertices of the mesh are given relative to its origin.
Definition: Geometry.h:215
std::string filename
The filename of the mesh.
Definition: Geometry.h:231
virtual Polygon2f getFootprint(const RigidTransform3f &origin) const
Implementation of Geometry::getFootprint.
virtual Polygon2f getFootprint(const RigidTransform3f &origin) const
Implementation of Geometry::getFootprint.
float radius
The radius of the sphere.
Definition: Geometry.h:204
virtual Polygon2f getFootprint(const RigidTransform3f &origin) const =0
Computes the footprint of the geometry primitive depending on the pose of the primitive that is speci...