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
27namespace 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 Plane;
41 class Polyline;
42 class Sphere;
43
46 enum class GeometryType
47 {
49 EMPTY = 0,
50
52 BOX = 1,
53
55 CYLINDER = 2,
56
58 PLANE = 3,
59
61 SPHERE = 4,
62
64 MESH = 5,
65
67 HEIGHTMAP = 6,
68
70 CAPSULE = 7,
71
73 ELLIPSOID = 8,
74
76 POLYLINE = 9,
77 };
78
84 {
86 public: Geometry();
87
94 public: Errors Load(ElementPtr _sdf);
95
98 public: GeometryType Type() const;
99
102 public: void SetType(const GeometryType _type);
103
109 public: const Box *BoxShape() const;
110
113 public: void SetBoxShape(const Box &_box);
114
120 public: const Capsule *CapsuleShape() const;
121
124 public: void SetCapsuleShape(const Capsule &_capsule);
125
131 public: const Cylinder *CylinderShape() const;
132
135 public: void SetCylinderShape(const Cylinder &_cylinder);
136
142 public: const Ellipsoid *EllipsoidShape() const;
143
146 public: void SetEllipsoidShape(const Ellipsoid &_ellipsoid);
147
153 public: const Sphere *SphereShape() const;
154
157 public: void SetSphereShape(const Sphere &_sphere);
158
163 public: const std::vector<Polyline> &PolylineShape() const;
164
167 public: void SetPolylineShape(const std::vector<Polyline> &_polyline);
168
174 public: const Plane *PlaneShape() const;
175
178 public: void SetPlaneShape(const Plane &_plane);
179
185 public: const Mesh *MeshShape() const;
186
189 public: void SetMeshShape(const Mesh &_mesh);
190
196 public: const Heightmap *HeightmapShape() const;
197
200 public: void SetHeightmapShape(const Heightmap &_heightmap);
201
206 public: sdf::ElementPtr Element() const;
207
213 public: sdf::ElementPtr ToElement() const;
214
216 IGN_UTILS_IMPL_PTR(dataPtr)
217 };
218 }
219}
220#endif
Box represents a box shape, and is usually accessed through a Geometry.
Definition: Box.hh:34
Capsule represents a capsule shape, and is usually accessed through a Geometry.
Definition: Capsule.hh:33
Cylinder represents a cylinder shape, and is usually accessed through a Geometry.
Definition: Cylinder.hh:33
Ellipsoid represents a ellipsoid shape, and is usually accessed through a Geometry.
Definition: Ellipsoid.hh:33
Geometry provides access to a shape, such as a Box.
Definition: Geometry.hh:84
sdf::ElementPtr Element() const
Get a pointer to the SDF element that was used during load.
sdf::ElementPtr ToElement() const
Create and return an SDF element filled with data from this geometry.
void SetEllipsoidShape(const Ellipsoid &_ellipsoid)
Set the ellipsoid shape.
GeometryType Type() const
Get the type of geometry.
const Mesh * MeshShape() const
Get the mesh geometry, or nullptr if the contained geometry is not a mesh.
const Cylinder * CylinderShape() const
Get the cylinder geometry, or nullptr if the contained geometry is not a cylinder.
void SetPolylineShape(const std::vector< Polyline > &_polyline)
Set the polyline shape.
void SetSphereShape(const Sphere &_sphere)
Set the sphere shape.
const Capsule * CapsuleShape() const
Get the capsule geometry, or nullptr if the contained geometry is not a capsule.
const Heightmap * HeightmapShape() const
Get the heightmap geometry, or nullptr if the contained geometry is not a heightmap.
const Ellipsoid * EllipsoidShape() const
Get the ellipsoid geometry, or nullptr if the contained geometry is not an ellipsoid.
void SetCapsuleShape(const Capsule &_capsule)
Set the capsule shape.
Errors Load(ElementPtr _sdf)
Load the geometry based on a element pointer.
void SetHeightmapShape(const Heightmap &_heightmap)
Set the heightmap shape.
const std::vector< Polyline > & PolylineShape() const
Get the polyline geometry.
void SetPlaneShape(const Plane &_plane)
Set the plane shape.
const Plane * PlaneShape() const
Get the plane geometry, or nullptr if the contained geometry is not a plane.
void SetCylinderShape(const Cylinder &_cylinder)
Set the cylinder shape.
const Sphere * SphereShape() const
Get the sphere geometry, or nullptr if the contained geometry is not a sphere.
void SetMeshShape(const Mesh &_mesh)
Set the mesh shape.
const Box * BoxShape() const
Get the box geometry, or nullptr if the contained geometry is not a box.
void SetType(const GeometryType _type)
Set the type of geometry.
void SetBoxShape(const Box &_box)
Set the box shape.
Heightmap represents a shape defined by a 2D field, and is usually accessed through a Geometry.
Definition: Heightmap.hh:120
Mesh represents a mesh shape, and is usually accessed through a Geometry.
Definition: Mesh.hh:36
Plane represents a plane shape, and is usually accessed through a Geometry.
Definition: Plane.hh:37
Sphere represents a sphere shape, and is usually accessed through a Geometry.
Definition: Sphere.hh:34
GeometryType
The set of geometry types.
Definition: Geometry.hh:47
std::vector< Error > Errors
A vector of Error.
Definition: Types.hh:106
std::shared_ptr< Element > ElementPtr
Definition: Element.hh:54
namespace for Simulation Description Format parser
Definition: Actor.hh:35
#define SDFORMAT_VISIBLE
Use to represent "symbol visible" if supported.
Definition: system_util.hh:25