Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef GEOMETRIC_SHAPES_SHAPES_
00038 #define GEOMETRIC_SHAPES_SHAPES_
00039
00040 #include <cstdlib>
00041 #include <vector>
00042 #include <iostream>
00043 #include <boost/shared_ptr.hpp>
00044 #include <string>
00045
00046 namespace octomap
00047 {
00048 class OcTree;
00049 }
00050
00054 namespace shapes
00055 {
00056
00058 enum ShapeType { UNKNOWN_SHAPE, SPHERE, CYLINDER, CONE, BOX, PLANE, MESH, OCTREE };
00059
00060
00062 class Shape
00063 {
00064 public:
00065 Shape();
00066 virtual ~Shape();
00067
00069 virtual Shape* clone() const = 0;
00070
00072 virtual void print(std::ostream &out = std::cout) const;
00073
00075 void scale(double scale);
00076
00078 void padd(double padding);
00079
00081 virtual void scaleAndPadd(double scale, double padd) = 0;
00082
00084 virtual bool isFixed() const;
00085
00087 ShapeType type;
00088 };
00089
00091 class Sphere : public Shape
00092 {
00093 public:
00094 Sphere();
00095
00097 Sphere(double r);
00098
00100 static const std::string STRING_NAME;
00101
00102 virtual void scaleAndPadd(double scale, double padd);
00103 virtual Shape* clone() const;
00104 virtual void print(std::ostream &out = std::cout) const;
00105
00107 double radius;
00108 };
00109
00112 class Cylinder : public Shape
00113 {
00114 public:
00115 Cylinder();
00116
00118 Cylinder(double r, double l);
00119
00121 static const std::string STRING_NAME;
00122
00123 virtual void scaleAndPadd(double scale, double padd);
00124 virtual Shape* clone() const;
00125 virtual void print(std::ostream &out = std::cout) const;
00126
00128 double length;
00129
00131 double radius;
00132 };
00133
00137 class Cone : public Shape
00138 {
00139 public:
00140 Cone();
00141 Cone(double r, double l);
00142
00144 static const std::string STRING_NAME;
00145
00146 virtual void scaleAndPadd(double scale, double padd);
00147 virtual Shape* clone() const;
00148 virtual void print(std::ostream &out = std::cout) const;
00149
00151 double length;
00152
00154 double radius;
00155 };
00156
00159 class Box : public Shape
00160 {
00161 public:
00162 Box();
00163 Box(double x, double y, double z);
00164
00166 static const std::string STRING_NAME;
00167
00168 virtual void scaleAndPadd(double scale, double padd);
00169 virtual Shape* clone() const;
00170 virtual void print(std::ostream &out = std::cout) const;
00171
00173 double size[3];
00174 };
00175
00181 class Mesh : public Shape
00182 {
00183 public:
00184
00185 Mesh();
00186 Mesh(unsigned int v_count, unsigned int t_count);
00187 virtual ~Mesh();
00188
00190 static const std::string STRING_NAME;
00191
00192 virtual void scaleAndPadd(double scale, double padd);
00193 virtual Shape* clone() const;
00194 virtual void print(std::ostream &out = std::cout) const;
00195
00197 void computeTriangleNormals();
00198
00200 void computeVertexNormals();
00201
00203 void mergeVertices(double threshold);
00204
00206 unsigned int vertex_count;
00207
00210 double *vertices;
00211
00213 unsigned int triangle_count;
00214
00217 unsigned int *triangles;
00218
00221 double *triangle_normals;
00222
00225 double *vertex_normals;
00226 };
00227
00229 class Plane : public Shape
00230 {
00231 public:
00232
00233 Plane();
00234 Plane(double pa, double pb, double pc, double pd);
00235
00237 static const std::string STRING_NAME;
00238
00239 virtual Shape* clone() const;
00240 virtual void print(std::ostream &out = std::cout) const;
00241 virtual void scaleAndPadd(double scale, double padd);
00242 virtual bool isFixed() const;
00243
00245 double a, b, c, d;
00246 };
00247
00249 class OcTree : public Shape
00250 {
00251 public:
00252 OcTree();
00253 OcTree(const boost::shared_ptr<const octomap::OcTree> &t);
00254
00256 static const std::string STRING_NAME;
00257
00258 virtual Shape* clone() const;
00259 virtual void print(std::ostream &out = std::cout) const;
00260 virtual void scaleAndPadd(double scale, double padd);
00261 virtual bool isFixed() const;
00262
00263 boost::shared_ptr<const octomap::OcTree> octree;
00264 };
00265
00266
00268 typedef boost::shared_ptr<Shape> ShapePtr;
00269
00271 typedef boost::shared_ptr<const Shape> ShapeConstPtr;
00272
00273 }
00274
00275 #endif