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 <gz/utils/ImplPtr.hh>
23 #include <sdf/Error.hh>
24 #include <sdf/Element.hh>
25 #include <sdf/sdf_config.h>
26 
27 namespace sdf
28 {
29  // Inline bracket to help doxygen filtering.
30  inline namespace SDF_VERSION_NAMESPACE {
31  //
32 
33  // Forward declare private data class.
34  class Box;
35  class Capsule;
36  class Cylinder;
37  class Ellipsoid;
38  class Heightmap;
39  class Mesh;
40  class ParserConfig;
41  class Plane;
42  class Polyline;
43  class Sphere;
44 
47  enum class GeometryType
48  {
50  EMPTY = 0,
51 
53  BOX = 1,
54 
56  CYLINDER = 2,
57 
59  PLANE = 3,
60 
62  SPHERE = 4,
63 
65  MESH = 5,
66 
68  HEIGHTMAP = 6,
69 
71  CAPSULE = 7,
72 
74  ELLIPSOID = 8,
75 
77  POLYLINE = 9,
78  };
79 
85  {
87  public: Geometry();
88 
95  public: Errors Load(ElementPtr _sdf);
96 
104  public: Errors Load(sdf::ElementPtr _sdf, const ParserConfig &_config);
105 
108  public: GeometryType Type() const;
109 
112  public: void SetType(const GeometryType _type);
113 
119  public: const Box *BoxShape() const;
120 
123  public: void SetBoxShape(const Box &_box);
124 
130  public: const Capsule *CapsuleShape() const;
131 
134  public: void SetCapsuleShape(const Capsule &_capsule);
135 
141  public: const Cylinder *CylinderShape() const;
142 
145  public: void SetCylinderShape(const Cylinder &_cylinder);
146 
152  public: const Ellipsoid *EllipsoidShape() const;
153 
156  public: void SetEllipsoidShape(const Ellipsoid &_ellipsoid);
157 
163  public: const Sphere *SphereShape() const;
164 
167  public: void SetSphereShape(const Sphere &_sphere);
168 
173  public: const std::vector<Polyline> &PolylineShape() const;
174 
177  public: void SetPolylineShape(const std::vector<Polyline> &_polyline);
178 
184  public: const Plane *PlaneShape() const;
185 
188  public: void SetPlaneShape(const Plane &_plane);
189 
195  public: const Mesh *MeshShape() const;
196 
199  public: void SetMeshShape(const Mesh &_mesh);
200 
206  public: const Heightmap *HeightmapShape() const;
207 
210  public: void SetHeightmapShape(const Heightmap &_heightmap);
211 
216  public: sdf::ElementPtr Element() const;
217 
223  public: sdf::ElementPtr ToElement() const;
224 
226  GZ_UTILS_IMPL_PTR(dataPtr)
227  };
228  }
229 }
230 #endif
sdf::SDF_VERSION_NAMESPACE::Heightmap
Heightmap represents a shape defined by a 2D field, and is usually accessed through a Geometry.
Definition: Heightmap.hh:133
Error.hh
sdf::SDF_VERSION_NAMESPACE::GeometryType::CYLINDER
@ CYLINDER
A cylinder geometry.
sdf
namespace for Simulation Description Format parser
Definition: Actor.hh:34
sdf::SDF_VERSION_NAMESPACE::GeometryType::PLANE
@ PLANE
A plane geometry.
sdf::SDF_VERSION_NAMESPACE::Cylinder
Cylinder represents a cylinder shape, and is usually accessed through a Geometry.
Definition: Cylinder.hh:32
sdf::SDF_VERSION_NAMESPACE::Ellipsoid
Ellipsoid represents a ellipsoid shape, and is usually accessed through a Geometry.
Definition: Ellipsoid.hh:32
sdf::SDF_VERSION_NAMESPACE::GeometryType::POLYLINE
@ POLYLINE
A polyline geometry.
sdf::SDF_VERSION_NAMESPACE::Plane
Plane represents a plane shape, and is usually accessed through a Geometry.
Definition: Plane.hh:36
sdf_config.h
SDFORMAT_VISIBLE
#define SDFORMAT_VISIBLE
Definition: system_util.hh:25
sdf::SDF_VERSION_NAMESPACE::Geometry
Geometry provides access to a shape, such as a Box.
Definition: Geometry.hh:84
sdf::SDF_VERSION_NAMESPACE::GeometryType::BOX
@ BOX
A box geometry.
sdf::SDF_VERSION_NAMESPACE::GeometryType
GeometryType
Definition: Geometry.hh:47
sdf::SDF_VERSION_NAMESPACE::ParserConfig
This class contains configuration options for the libsdformat parser.
Definition: ParserConfig.hh:84
sdf::SDF_VERSION_NAMESPACE::Box
Box represents a box shape, and is usually accessed through a Geometry.
Definition: Box.hh:33
sdf::SDF_VERSION_NAMESPACE::Capsule
Capsule represents a capsule shape, and is usually accessed through a Geometry.
Definition: Capsule.hh:32
sdf::SDF_VERSION_NAMESPACE::GeometryType::MESH
@ MESH
A mesh geometry.
sdf::SDF_VERSION_NAMESPACE::Element
class GZ_SDFORMAT_VISIBLE Element
Definition: Element.hh:50
sdf::SDF_VERSION_NAMESPACE::GeometryType::SPHERE
@ SPHERE
A sphere geometry.
sdf::SDF_VERSION_NAMESPACE::Errors
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:80
sdf::SDF_VERSION_NAMESPACE::GeometryType::CAPSULE
@ CAPSULE
A capsule geometry.
sdf::SDF_VERSION_NAMESPACE::GeometryType::HEIGHTMAP
@ HEIGHTMAP
A heightmap geometry.
sdf::SDF_VERSION_NAMESPACE::Mesh
Mesh represents a mesh shape, and is usually accessed through a Geometry.
Definition: Mesh.hh:38
sdf::SDF_VERSION_NAMESPACE::GeometryType::ELLIPSOID
@ ELLIPSOID
An ellipsoid geometry.
sdf::SDF_VERSION_NAMESPACE::Sphere
Sphere represents a sphere shape, and is usually accessed through a Geometry.
Definition: Sphere.hh:33
sdf::SDF_VERSION_NAMESPACE::GeometryType::EMPTY
@ EMPTY
Empty geometry. This means no shape has been defined.
sdf::SDF_VERSION_NAMESPACE::ElementPtr
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
Element.hh