Hide menu
Loading...
Searching...
No Matches

Base class of topological shapes. More...

Inheritance diagram for cadex.ModelData.Shape:
cadex.BaseObject cadex.ModelData.Edge cadex.ModelData.Face cadex.ModelData.Shell cadex.ModelData.Solid cadex.ModelData.Vertex cadex.ModelData.Wire

Public Member Functions

 Shape (global::System.IntPtr cPtr, bool cMemoryOwn)
 
override int GetHashCode ()
 
cadex.ModelData.ShapeType Type ()
 Returns a shape type. For a null object returns Undefined.
 
cadex.ModelData.ShapeOrientation Orientation ()
 Returns orientation flag.
 
cadex.ModelData.Shape Reversed ()
 Returns a shape that shares the same geometry and subshape graph but has opposite orientation.
 
cadex.ModelData.Shape Oriented (cadex.ModelData.ShapeOrientation theOrientation)
 Returns a shape that shares the same geometry and subshape graph and has specified orientation.
 
bool IsEqual (cadex.ModelData.Shape theOther)
 Returns true if the shape shares the same geometry and subshape graph, and has equal orientation.
 
bool IsSame (cadex.ModelData.Shape theOther)
 Returns true if the shape shares the same geometry and subshape graph.
 
void SetName (cadex.UTF16String theName)
 Sets the name.
 
cadex.UTF16String Name ()
 Returns the name.
 
void AddAssociatedPMI (cadex.PMI.Element theElement)
 Adds the PMI element.
 
void AddAssociatedPMI (cadex.Collections.PMIElementList theElements)
 Adds the PMI elements.
 
cadex.Collections.PMIElementList AssociatedPMI ()
 Returns the PMI elements.
 
override bool Equals (System.Object o)
 
- Public Member Functions inherited from cadex.BaseObject
 BaseObject (global::System.IntPtr cPtr, bool cMemoryOwn)
 
void Dispose ()
 
bool IsNull ()
 
ulong Id ()
 Return unique identifier of public object.
 
bool IsEqual (cadex.BaseObject theObj)
 
override int GetHashCode ()
 
override bool Equals (System.Object o)
 

Static Public Member Functions

static bool CompareType (cadex.BaseObject theObject)
 Check the type of object. Returns true if the specified object is this class type.
 
static cadex.ModelData.Shape Cast (cadex.BaseObject theBase)
 

Protected Member Functions

override void Dispose (bool disposing)
 

Detailed Description

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

Types

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:

ModelData::Shape aShape = ...;
if (aShape.Type() == ModelData::ShapeType::Face) {
const ModelData::Face& aFace = static_cast<const ModelData::Face&> (aShape);
ModelData::Surface aSurface = aFace.Surface();
...
}
Defines a topological face.
Definition Face.cs:120
cadex.Geom.Surface Surface()
Returns underlying surface.
Definition Face.cs:216
Base class of topological shapes.
Definition Shape.cs:178
cadex.ModelData.ShapeType Type()
Returns a shape type. For a null object returns Undefined.
Definition Shape.cs:222

Orientation

Each shape can have either forward or reversed orientation as returned by the Orientation() method. Meaning of orientation depends on the shape type:

  • For vertex, orientation has a meaning only in context of a parent edge where forward vertex corresponds to smaller parameter on the edge curve and reversed vertex to greater parameter.
  • For edge, orientation specifies whether edge direction is aligned or is opposite to underlying curve orientation.
  • For face, orientation specifies whether face normal is aligned or is opposite to underlying surface normal.
  • For wire, shell, solid, or body, orientation simply specifies whether subshapes should be considered with their own or opposite orientations. For instance, a reversed wire would be similar to a forward wire consisting of original edges taken with opposite orientations.

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.

Equality and similarity relationships

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:

ModelData::Shape aShape1 = ...;
//shapes with equal orientations are IsSame() and are equal
ModelData::Shape aShape2 = aShape1;
assert (aShape2 == aShape1);
assert (aShape2.IsSame (aShape1));
//shapes with opposite orientations are IsSame() but are not equal
ModelData::Shape aShape3 = aShape1.Reversed();
assert (aShape3.IsSame (aShape1));
assert (aShape3 != aShape1);
bool IsSame(cadex.ModelData.Shape theOther)
Returns true if the shape shares the same geometry and subshape graph.
Definition Shape.cs:266
cadex.ModelData.Shape Reversed()
Returns a shape that shares the same geometry and subshape graph but has opposite orientation.
Definition Shape.cs:237

For example, a closed shell contains pairs of IsSame() edges but with opposite orientations.

Exploration of Subshapes

Children subshapes can be retrieved using ModelData.ShapeIterator. Iterator supports two usage scenarios:

  • iteration over direct children (e.g. faces of a shell);
  • iteration over subshapes of a specified type (e.g. all edges inside a shell).

Refer to ModelData.ShapeIterator for detailed explanations of both scenarios.

Resulting orientation

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.

Storing Shapes in Containers

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:

std::list<ModelData::Shape> aShapeList;
ModelData::Shape::Iterator anIt (aShape);
while (anIt.HasNext()) {
aShapeList.push_back (anIt.Next());
}

Storing Shapes in Associative Containers

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:

typedef std::unordered_map<ModelData::Shape,
int,
ModelData::OrientedShapeEqual> OrientedShapeMap;
typedef std::unordered_set<ModelData::Shape,
ModelData::UnorientedShapeEqual> UnorientedShapeSet;
// Returns true if the shell is open, i.e. has edges belonging to single face only.
static bool HasFreeBoundaries (const ModelData::Shell& theShell)
{
UnorientedShapeSet aSet;
ModelData::ShapeIterator i (theShell, ModelData::SapeType::Edge);
while (i.HasNext()) {
const auto& aShape = i.Next();
auto r = aSet.insert (aShape);
if (!r.second) { //if the same edge was already encountered then remove it
aSet.erase (r.first);
}
}
return !aSet.empty();
}
Compares shapes using 'IsEqual' relationship.
Definition OrientedShapeEqual.cs:19
Hasher for Shape using 'IsEqual' relationship.
Definition OrientedShapeHash.cs:19
Iterates over subshapes in a shape.
Definition ShapeIterator.cs:58
Defines a connected set of faces.
Definition Shell.cs:29
Compares shapes using 'IsSame' relationship.
Definition UnorientedShapeEqual.cs:19
Hasher for Shape using 'IsSame' relationship.
Definition UnorientedShapeHash.cs:19
Examples
exploring/brep_geometry/Program.cs, exploring/brep_geometry/main.cxx, exploring/brep_topology/Program.cs, and exploring/brep_topology/main.cxx.

Member Function Documentation

◆ Dispose()

override void cadex.ModelData.Shape.Dispose ( bool disposing)
inlineprotectedvirtual

Reimplemented from cadex.BaseObject.

◆ IsEqual()

bool cadex.ModelData.Shape.IsEqual ( cadex.ModelData.Shape theOther)
inline

Returns true if the shape shares the same geometry and subshape graph, and has equal orientation.

See also
Equality and similarity relationships, IsSame().

◆ IsSame()

bool cadex.ModelData.Shape.IsSame ( cadex.ModelData.Shape theOther)
inline

Returns true if the shape shares the same geometry and subshape graph.

See also
Equality and similarity relationships, IsEqual().

◆ Orientation()

◆ Oriented()

cadex.ModelData.Shape cadex.ModelData.Shape.Oriented ( cadex.ModelData.ShapeOrientation theOrientation)
inline

Returns a shape that shares the same geometry and subshape graph and has specified orientation.

See also
IsSame(), Reversed().

◆ Reversed()

cadex.ModelData.Shape cadex.ModelData.Shape.Reversed ( )
inline

Returns a shape that shares the same geometry and subshape graph but has opposite orientation.

See also
IsSame(), Oriented().