File: Geometry.hh

package info (click to toggle)
sdformat 9.3.0%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 5,708 kB
  • sloc: cpp: 42,166; python: 1,618; javascript: 704; ruby: 368; sh: 81; ansic: 37; makefile: 16
file content (173 lines) | stat: -rw-r--r-- 5,620 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/*
 * Copyright 2018 Open Source Robotics Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
#ifndef SDF_GEOMETRY_HH_
#define SDF_GEOMETRY_HH_

#include <sdf/Error.hh>
#include <sdf/Element.hh>
#include <sdf/sdf_config.h>

namespace sdf
{
  // Inline bracket to help doxygen filtering.
  inline namespace SDF_VERSION_NAMESPACE {
  //

  // Forward declare private data class.
  class GeometryPrivate;
  class Box;
  class Cylinder;
  class Mesh;
  class Plane;
  class Sphere;

  /// \enum GeometryType
  /// \brief The set of geometry types.
  enum class GeometryType
  {
    /// \brief Empty geometry. This means no shape has been defined.
    EMPTY = 0,

    /// \brief A box geometry.
    BOX = 1,

    /// \brief A cylinder geometry.
    CYLINDER = 2,

    /// \brief A plane geometry.
    PLANE = 3,

    /// \brief A sphere geometry.
    SPHERE = 4,

    /// \brief A mesh geometry.
    MESH = 5,
  };

  /// \brief Geometry provides access to a shape, such as a Box. Use the
  /// Type function to determine the type of shape contained within a
  /// Geometry. Access to shape data, such as a box's size, is achieved
  /// through the shape accessors, such as const Box *BoxShape() const.
  class SDFORMAT_VISIBLE Geometry
  {
    /// \brief Default constructor
    public: Geometry();

    /// \brief Copy constructor
    /// \param[in] _geometry Geometry to copy.
    public: Geometry(const Geometry &_geometry);

    /// \brief Move constructor
    /// \param[in] _geometry Geometry to move.
    public: Geometry(Geometry &&_geometry) noexcept;

    /// \brief Destructor
    public: virtual ~Geometry();

    /// \brief Assignment operator.
    /// \param[in] _geometry The geometry to set values from.
    /// \return *this
    public: Geometry &operator=(const Geometry &_geometry);

    /// \brief Move assignment operator.
    /// \param[in] _geometry The geometry to move from.
    /// \return *this
    public: Geometry &operator=(Geometry &&_geometry);

    /// \brief Load the geometry based on a element pointer. This is *not* the
    /// usual entry point. Typical usage of the SDF DOM is through the Root
    /// object.
    /// \param[in] _sdf The SDF Element pointer
    /// \return Errors, which is a vector of Error objects. Each Error includes
    /// an error code and message. An empty vector indicates no error.
    public: Errors Load(ElementPtr _sdf);

    /// \brief Get the type of geometry.
    /// \return The geometry type.
    public: GeometryType Type() const;

    /// \brief Set the type of geometry.
    /// \param[in] _type The geometry type.
    public: void SetType(const GeometryType _type);

    /// \brief Get the box geometry, or nullptr if the contained geometry is
    /// not a box.
    /// \return Pointer to the visual's box geometry, or nullptr if the
    /// geometry is not a box.
    /// \sa GeometryType Type() const
    public: const Box *BoxShape() const;

    /// \brief Set the box shape.
    /// \param[in] _box The box shape.
    public: void SetBoxShape(const Box &_box);

    /// \brief Get the cylinder geometry, or nullptr if the contained
    /// geometry is not a cylinder.
    /// \return Pointer to the visual's cylinder geometry, or nullptr if the
    /// geometry is not a cylinder.
    /// \sa GeometryType Type() const
    public: const Cylinder *CylinderShape() const;

    /// \brief Set the cylinder shape.
    /// \param[in] _cylinder The cylinder shape.
    public: void SetCylinderShape(const Cylinder &_cylinder);

    /// \brief Get the sphere geometry, or nullptr if the contained geometry is
    /// not a sphere.
    /// \return Pointer to the visual's sphere geometry, or nullptr if the
    /// geometry is not a sphere.
    /// \sa GeometryType Type() const
    public: const Sphere *SphereShape() const;

    /// \brief Set the sphere shape.
    /// \param[in] _sphere The sphere shape.
    public: void SetSphereShape(const Sphere &_sphere);

    /// \brief Get the plane geometry, or nullptr if the contained geometry is
    /// not a plane.
    /// \return Pointer to the visual's plane geometry, or nullptr if the
    /// geometry is not a plane.
    /// \sa GeometryType Type() const
    public: const Plane *PlaneShape() const;

    /// \brief Set the plane shape.
    /// \param[in] _plane The plane shape.
    public: void SetPlaneShape(const Plane &_plane);

    /// \brief Get the mesh geometry, or nullptr if the contained geometry is
    /// not a mesh.
    /// \return Pointer to the visual's mesh geometry, or nullptr if the
    /// geometry is not a mesh.
    /// \sa GeometryType Type() const
    public: const Mesh *MeshShape() const;

    /// \brief Set the mesh shape.
    /// \param[in] _mesh The mesh shape.
    public: void SetMeshShape(const Mesh &_mesh);

    /// \brief Get a pointer to the SDF element that was used during
    /// load.
    /// \return SDF element pointer. The value will be nullptr if Load has
    /// not been called.
    public: sdf::ElementPtr Element() const;

    /// \brief Private data pointer.
    private: GeometryPrivate *dataPtr;
  };
  }
}
#endif