Drake
ShapeReifier Class Referenceabstract

The interface for converting shape descriptions to real shapes. More...

#include <geometry/shape_specification.h>

Inheritance diagram for ShapeReifier:
[legend]

Public Member Functions

virtual ~ShapeReifier ()
 
virtual void ImplementGeometry (const Sphere &sphere, void *user_data)=0
 
virtual void ImplementGeometry (const Cylinder &cylinder, void *user_data)=0
 
virtual void ImplementGeometry (const HalfSpace &half_space, void *user_data)=0
 
virtual void ImplementGeometry (const Box &box, void *user_data)=0
 
virtual void ImplementGeometry (const Mesh &mesh, void *user_data)=0
 

Detailed Description

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 a 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:

class SimpleReifier : public ShapeReifier {
void ProcessShape(const Shape& shape) {
// Requires no user data.
shape.Reify(this);
}
...
void ImplementGeometry(const Sphere& sphere, void*) override {
// Do work to create a sphere.
}
};

Or a complex reifier that requires user data would look like:

class ComplexReifier : public ShapeReifier {
void ProcessShape(const Shape& shape) {
ImportantData data{...};
shape.Reify(this, &data);
}
...
void ImplementGeometry(const Sphere& sphere, void* data) override {
DRAKE_ASSERT(data);
ImportantData& data = *reinterpret_cast<ImportantData*>(data);
// Do work to create a sphere using the provided user data.
}
};

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.

Constructor & Destructor Documentation

virtual ~ShapeReifier ( )
inlinevirtual

Member Function Documentation

virtual void ImplementGeometry ( const Sphere sphere,
void *  user_data 
)
pure virtual
virtual void ImplementGeometry ( const Cylinder cylinder,
void *  user_data 
)
pure virtual
virtual void ImplementGeometry ( const HalfSpace half_space,
void *  user_data 
)
pure virtual
virtual void ImplementGeometry ( const Box box,
void *  user_data 
)
pure virtual
virtual void ImplementGeometry ( const Mesh mesh,
void *  user_data 
)
pure virtual

The documentation for this class was generated from the following file: