The base interface for all shape specifications.
It has no public constructor and cannot be instantiated directly. The Shape class has two key properties:
When you add a new subclass of Shape, you must:
using
, for example, using ShapeReifier::ImplementGeometry
. Existing subclasses should already have this.Otherwise, you might get a runtime error. We do not have an automatic way to enforce them at compile time.
#include <drake/geometry/shape_specification.h>
Public Member Functions | |
virtual | ~Shape () |
void | Reify (ShapeReifier *reifier, void *user_data=nullptr) const |
Causes this description to be reified in the given reifier . More... | |
std::unique_ptr< Shape > | Clone () const |
Creates a unique copy of this shape. More... | |
Protected Member Functions | |
template<typename S > | |
Shape (ShapeTag< S > tag) | |
Constructor available for derived class construction. More... | |
Implements CopyConstructible, CopyAssignable, MoveConstructible, MoveAssignable | |
Shape (const Shape &)=default | |
Shape & | operator= (const Shape &)=default |
Shape (Shape &&)=default | |
Shape & | operator= (Shape &&)=default |
|
virtual |
Constructor available for derived class construction.
A derived class should invoke this in its initialization list, passing a ShapeTag instantiated on its derived type, e.g.:
The base class provides infrastructure for cloning and reification. To work and to maintain sanity, we place the following requirements on derived classes:
S | The derived shape class. It must derive from Shape. |
std::unique_ptr<Shape> Clone | ( | ) | const |
Creates a unique copy of this shape.
void Reify | ( | ShapeReifier * | reifier, |
void * | user_data = nullptr |
||
) | const |
Causes this description to be reified in the given reifier
.
Each concrete subclass must invoke the single, matching method on the reifier. Provides optional user-data (cast as a void*) for the reifier to consume.