Drake
Shape Class Reference

Detailed Description

The base interface for all shape specifications.

It has no public constructor and cannot be instantiated directly. The Shape class has two key properties:

  • it is cloneable, and
  • it can be "reified" (see ShapeReifier).

When you add a new subclass of Shape, you must:

  1. add a virtual function ImplementGeometry() for the new shape in ShapeReifier that invokes the ThrowUnsupportedGeometry method, and add to the test for it in shape_specification_test.cc.
  2. implement ImplementGeometry in derived ShapeReifiers to continue support if desired, otherwise ensure unimplemented functions are not hidden in new derivations of ShapeReifier with 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< ShapeClone () 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
 
Shapeoperator= (const Shape &)=default
 
 Shape (Shape &&)=default
 
Shapeoperator= (Shape &&)=default
 

Constructor & Destructor Documentation

◆ ~Shape()

virtual ~Shape ( )
virtual

◆ Shape() [1/3]

Shape ( const Shape )
protecteddefault

◆ Shape() [2/3]

Shape ( Shape &&  )
protecteddefault

◆ Shape() [3/3]

Shape ( ShapeTag< S >  tag)
explicitprotected

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

class MyShape final : public Shape {
public:
MyShape() : Shape(ShapeTag<MyShape>()) {}
...
};

The base class provides infrastructure for cloning and reification. To work and to maintain sanity, we place the following requirements on derived classes:

  1. they must have a public copy constructor,
  2. they must be marked as final, and
  3. their constructors must invoke the parent constructor with a ShapeTag instance (as noted above), and
  4. The ShapeReifier class must be extended to include an invocation of ShapeReifier::ImplementGeometry() on the derived Shape class.
Template Parameters
SThe derived shape class. It must derive from Shape.

Member Function Documentation

◆ Clone()

std::unique_ptr<Shape> Clone ( ) const

Creates a unique copy of this shape.

◆ operator=() [1/2]

Shape& operator= ( Shape &&  )
protecteddefault

◆ operator=() [2/2]

Shape& operator= ( const Shape )
protecteddefault

◆ Reify()

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.


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