forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
shape_to_string.h
47 lines (38 loc) · 1.49 KB
/
shape_to_string.h
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
#pragma once
#include <string>
#include "drake/geometry/shape_specification.h"
namespace drake {
namespace geometry {
/** Class that turns a Shape into a std::string representation. This reifier has
a string() member that gets updated for each shape reified. The expected
workflow would be:
```c++
ShapeToString reifier;
SceneGraphInspector inspector = ...; // Get the inspector from somewhere.
for (GeometryId id : inspector.GetAllGeometryIds()) {
inspector.Reify(id, reifier);
std::cout << reifier.string() << "\n";
}
```
This will write out a string representation of every geometry registered to
SceneGraph. */
class ShapeToString final : public ShapeReifier {
public:
/** @name Implementation of ShapeReifier interface */
//@{
using ShapeReifier::ImplementGeometry;
void ImplementGeometry(const Sphere& sphere, void* user_data) final;
void ImplementGeometry(const Cylinder& cylinder, void* user_data) final;
void ImplementGeometry(const HalfSpace& half_space, void* user_data) final;
void ImplementGeometry(const Box& box, void* user_data) final;
void ImplementGeometry(const Capsule& capsule, void* user_data) final;
void ImplementGeometry(const Ellipsoid& ellipsoid, void* user_data) final;
void ImplementGeometry(const Mesh& mesh, void* user_data) final;
void ImplementGeometry(const Convex& convex, void* user_data) final;
//@}
const std::string& string() const { return string_; }
private:
std::string string_;
};
} // namespace geometry
} // namespace drake