The interface for converting shape descriptions to real shapes.
Any entity that consumes shape descriptions must implement this interface.
This class explicitly enumerates all concrete shapes in its methods. The addition of a new concrete shape class requires the addition of a new corresponding method. There should never be an ImplementGeometry method that accepts the Shape base class as an argument; it should only operate on concrete derived classes.
The expected workflow is for a class that needs to turn shape specifications into concrete geometry instances to implement the ShapeReifier interface and invoke the Shape::Reify() method. For example, a simple reifier that requires no user data would look like:
Or a complex reifier that requires user data would look like:
Implementing a particular shape may require more data than is strictly encapsulated in the Shape. The Implement* interface supports passing user data through a type-erased void*
. Because a single class invoked Shape::Reify() it is in a position to provide exactly the data the shape implementations require.
#include <drake/geometry/shape_specification.h>
Public Member Functions | |
virtual | ~ShapeReifier () |
virtual void | ImplementGeometry (const Box &box, void *user_data) |
virtual void | ImplementGeometry (const Capsule &capsule, void *user_data) |
virtual void | ImplementGeometry (const Convex &convex, void *user_data) |
virtual void | ImplementGeometry (const Cylinder &cylinder, void *user_data) |
virtual void | ImplementGeometry (const Ellipsoid &ellipsoid, void *user_data) |
virtual void | ImplementGeometry (const HalfSpace &half_space, void *user_data) |
virtual void | ImplementGeometry (const Mesh &mesh, void *user_data) |
virtual void | ImplementGeometry (const MeshcatCone &cone, void *user_data) |
virtual void | ImplementGeometry (const Sphere &sphere, void *user_data) |
Protected Member Functions | |
ShapeReifier ()=default | |
virtual void | DefaultImplementGeometry (const Shape &shape) |
The default implementation of ImplementGeometry(): it throws an exception using ThrowUnsupportedGeometry(). More... | |
virtual void | ThrowUnsupportedGeometry (const std::string &shape_name) |
Derived ShapeReifiers can replace the default message for unsupported geometries by overriding this method. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
ShapeReifier (const ShapeReifier &)=default | |
ShapeReifier & | operator= (const ShapeReifier &)=default |
ShapeReifier (ShapeReifier &&)=default | |
ShapeReifier & | operator= (ShapeReifier &&)=default |
|
virtual |
|
protecteddefault |
|
protecteddefault |
|
protecteddefault |
|
protectedvirtual |
The default implementation of ImplementGeometry(): it throws an exception using ThrowUnsupportedGeometry().
The purpose of this function is to facilitate reifiers that would call the same API on all shapes (e.g., call an API with a Shape& parameter). This reduces the implementation boilerplate.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
protecteddefault |
|
protecteddefault |
|
protectedvirtual |
Derived ShapeReifiers can replace the default message for unsupported geometries by overriding this method.
The name of the unsupported shape type is given as the single parameter.