Base class of topological shapes. More...
#include <cadex/ModelData/Shape.hxx>
Public Member Functions | |
ShapeType | Type () const |
Returns a shape type. For a null object returns Undefined. | |
ShapeOrientation | Orientation () const |
Returns orientation flag. | |
Shape | Reversed () const |
Returns a shape that shares the same geometry and subshape graph but has opposite orientation. | |
Shape | Oriented (ShapeOrientation theOrientation) const |
Returns a shape that shares the same geometry and subshape graph and has specified orientation. | |
bool | IsEqual (const Shape &theOther) const |
Returns true if the shape shares the same geometry and subshape graph, and has equal orientation. | |
bool | IsSame (const Shape &theOther) const |
Returns true if the shape shares the same geometry and subshape graph. | |
void | SetName (const UTF16String &theName) |
UTF16String | Name () const |
![]() | |
size_t | Id () const |
Return unique identifier of public object. | |
internal::BaseObjectImpl * | Impl () const |
bool | IsNull () const |
operator bool () const | |
template<typename T > | |
bool | IsOfType () const |
template<typename T > | |
T * | Impl () const |
Reserved for internal use. | |
Static Public Member Functions | |
static bool | CompareType (const BaseObject &theObject) |
Check the type of object. Returns true if the specified object is this class type. | |
Protected Member Functions | |
Shape (const ImplType &theImpl) | |
![]() | |
BaseObject (const ImplType &theImpl) | |
Additional Inherited Members | |
![]() | |
typedef std::shared_ptr< internal::BaseObjectImpl > | ImplType |
Base class of topological shapes.
Topological shapes define boundaries of the geometrical entities (curves and surfaces) in B-Rep.
Some topological entities refer to geometrical entities (e.g. edge refers to curve and face refers to surface), whereas some only refer to child topological entities (e.g. wire refers to edges it consists of or shell refers to faces it consists of).
Refer to Shape Types for the list of supported shape types. Type() returns a type as enumeration value which can be used to downcast to a respective subclass type, for instance:
Each shape can have either forward or reversed orientation as returned by the Orientation() method. Meaning of orientation depends on the shape type:
A shape with the opposite orientation can be returned with the Reversed() method. A shape with a specified orientation can be returned with the Oriented() method. Both methods create a shallow copy of the original shape, which shares a subshape graph but has a distinct orientation flag.
Two shapes are considered equal if they share the same definition (i.e. geometry and subshape graph) and have equal orientations. The method IsEqual() and operator==() can be used to check equality.
Two shapes are considered same if they share the same definition (i.e. geometry and subshape graph). Orientations are not required to be same. The method IsSame() can be used to check this relationship. Obviously, the 'IsSame' relationship is less strict than 'IsEqual'.
The following code snippet demonstrates both relationships:
For example, a closed shell contains pairs of IsSame() edges but with opposite orientations.
Children subshapes can be retrieved using ModelData::ShapeIterator. Iterator supports two usage scenarios:
Refer to ModelData::ShapeIterator for detailed explanations of both scenarios.
Orientation of a returned subshape is product of own subshape orientation (stored inside a subshape) and of its parent. Thus, if the subshape and its parent both have the same orientation then the returned subshape will have forward orientation, if they have opposite orientations then the returned subshape will have reversed orientation.
When exploring nested subshapes the same rule applies at each level of the hierarchy:
Resulting_orientation = parent_orientation * subshape_orientation * subsubshape_orientation * ...
For instance, when exploring a forward face, which has a wire with reversed orientation, with an edge having forward orientation, exploring that edge will return an edge with reversed orientation.
ModelData::Shape has a single data member, a shared pointer pointing to internal implementation (i.e. follows a 'pimpl' design pattern). ModelData::Shape subclasses do not add any own data fields. Therefore it is safe to store objects (even of different subtypes) in containers by value:
Shapes can be stored in associative containers (such as std::unordered_map or std::unordered_set) as keys. Hash and equality functors required for such containers can be selected depending on desired behavior, whether the container must ensure uniquness defined in terms of equality or similarity relationships (see above):
Refer to Equality and similarity relationships for relationship definitions.
The following code snippet demonstrates usage of both approaches:
bool cadex::ModelData::Shape::IsEqual | ( | const Shape & | theOther | ) | const |
Returns true if the shape shares the same geometry and subshape graph, and has equal orientation.
bool cadex::ModelData::Shape::IsSame | ( | const Shape & | theOther | ) | const |
Returns true if the shape shares the same geometry and subshape graph.
ShapeOrientation cadex::ModelData::Shape::Orientation | ( | ) | const |
Returns orientation flag.
Shape cadex::ModelData::Shape::Oriented | ( | ShapeOrientation | theOrientation | ) | const |
Returns a shape that shares the same geometry and subshape graph and has specified orientation.
Shape cadex::ModelData::Shape::Reversed | ( | ) | const |
Returns a shape that shares the same geometry and subshape graph but has opposite orientation.