Geometry.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2018 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef SDF_GEOMETRY_HH_
18 #define SDF_GEOMETRY_HH_
19 
20 #include <vector>
21 
22 #include <sdf/Error.hh>
23 #include <sdf/Element.hh>
24 #include <sdf/sdf_config.h>
25 
26 namespace sdf
27 {
28  // Inline bracket to help doxygen filtering.
29  inline namespace SDF_VERSION_NAMESPACE {
30  //
31 
32  // Forward declare private data class.
33  class GeometryPrivate;
34  class Box;
35  class Cylinder;
36  class Heightmap;
37  class Mesh;
38  class Plane;
39  class Polyline;
40  class Sphere;
41 
44  enum class GeometryType
45  {
47  EMPTY = 0,
48 
50  BOX = 1,
51 
53  CYLINDER = 2,
54 
56  PLANE = 3,
57 
59  SPHERE = 4,
60 
62  MESH = 5,
63 
65  HEIGHTMAP = 6,
66 
67  // Implemented from sdf10
68  // CAPSULE = 7,
69  // ELLIPSOID = 8,
70 
72  POLYLINE = 9,
73  };
74 
80  {
82  public: Geometry();
83 
86  public: Geometry(const Geometry &_geometry);
87 
90  public: Geometry(Geometry &&_geometry) noexcept;
91 
93  public: virtual ~Geometry();
94 
98  public: Geometry &operator=(const Geometry &_geometry);
99 
103  public: Geometry &operator=(Geometry &&_geometry);
104 
111  public: Errors Load(ElementPtr _sdf);
112 
115  public: GeometryType Type() const;
116 
119  public: void SetType(const GeometryType _type);
120 
126  public: const Box *BoxShape() const;
127 
130  public: void SetBoxShape(const Box &_box);
131 
137  public: const Cylinder *CylinderShape() const;
138 
141  public: void SetCylinderShape(const Cylinder &_cylinder);
142 
147  public: const std::vector<Polyline> &PolylineShape() const;
148 
151  public: void SetPolylineShape(const std::vector<Polyline> &_polyline);
152 
158  public: const Sphere *SphereShape() const;
159 
162  public: void SetSphereShape(const Sphere &_sphere);
163 
169  public: const Plane *PlaneShape() const;
170 
173  public: void SetPlaneShape(const Plane &_plane);
174 
180  public: const Mesh *MeshShape() const;
181 
184  public: void SetMeshShape(const Mesh &_mesh);
185 
191  public: const Heightmap *HeightmapShape() const;
192 
195  public: void SetHeightmapShape(const Heightmap &_heightmap);
196 
201  public: sdf::ElementPtr Element() const;
202 
204  private: GeometryPrivate *dataPtr;
205  };
206  }
207 }
208 #endif
sdf::v9::Geometry
Geometry provides access to a shape, such as a Box.
Definition: Geometry.hh:79
Error.hh
sdf::v9::GeometryType::EMPTY
@ EMPTY
Empty geometry. This means no shape has been defined.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:32
sdf::v9::GeometryType::HEIGHTMAP
@ HEIGHTMAP
A heightmap geometry.
sdf::v9::Cylinder
Cylinder represents a cylinder shape, and is usually accessed through a Geometry.
Definition: Cylinder.hh:36
sdf::v9::GeometryType::MESH
@ MESH
A mesh geometry.
sdf::v9::Plane
Plane represents a plane shape, and is usually accessed through a Geometry.
Definition: Plane.hh:38
sdf::v9::Sphere
Sphere represents a sphere shape, and is usually accessed through a Geometry.
Definition: Sphere.hh:37
sdf::v9::GeometryType
GeometryType
Definition: Geometry.hh:44
sdf::v9::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:89
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:48
sdf::v9::GeometryType::PLANE
@ PLANE
A plane geometry.
sdf::v9::Mesh
Mesh represents a mesh shape, and is usually accessed through a Geometry.
Definition: Mesh.hh:37
sdf::v9::GeometryType::POLYLINE
@ POLYLINE
A polyline geometry.
sdf::v9::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:53
sdf::v9::GeometryType::SPHERE
@ SPHERE
A sphere geometry.
sdf::v9::Box
Box represents a box shape, and is usually accessed through a Geometry.
Definition: Box.hh:36
sdf::v9::Heightmap
Heightmap represents a shape defined by a 2D field, and is usually accessed through a Geometry.
Definition: Heightmap.hh:167
sdf::v9::Element
class SDFORMAT_VISIBLE Element
Definition: Element.hh:49
sdf::v9::GeometryType::CYLINDER
@ CYLINDER
A cylinder geometry.
sdf::v9::GeometryType::BOX
@ BOX
A box geometry.
Element.hh