Hide menu
cadex::ModelData_Shape::Iterator Class Reference

Iterates over subshapes in a shape. More...

Inherits cadex::internal::Base_NoCopy.

Public Member Functions

 Iterator (const ModelData_Shape &theShape)
 Constructor.
 
 Iterator (const ModelData_Shape &theShape, ModelData_ShapeType theType)
 Constructor.
 
 ~Iterator ()
 Destructor.
 
bool HasNext () const
 
ModelData_Shape Next ()
 

Detailed Description

Iterates over subshapes in a shape.

Iterator supports two usage scenario:

  • iteration over direct children;
  • iteration over subshapes of a specified type.

Exploration of Direct Children

To retrive direct children of a shape, ModelData_Shape::Iterator should be used as follows:

ModelData_Wire aWire = ...;
ModelData_Shape::Iterator i (aWire);
while (i.HasNext()) {
const ModelData_Shape& aChild = i.Next(); //edge
ModelData_Type aType = aChild.Type();
assert (aType == ModelData_ST_Edge);
}

Exploration of particular types

To retrive children of a particular type, ModelData_Shape::Iterator should be used by specifying a type of interest as follows:

ModelData_Solid aSolid = ...;
ModelData_Shape::Iterator i (aSolid, ModelData_ST_Edge); //iterate over edges in the solid
while (i.HasNext()) {
ModelData_Shape aChild = i.Next();
const ModelData_Edge& anEdge = static_cast<const ModelData_Edge&> (aChild); //edge
...
}

When using the latter approach exploration is done traversing the graph of subshapes in a depth-first manner. Each subshape will be found as many times as it is registered in the parent subshape. For instance, a seam-edge will be encountered twice, with forward and reversed orientations.

The order of returned subshapes is deterministic and corresponds to the order in which the subshapes were added during construction.

Examples
advgeom/brepsimplify/main.cxx, exploring/brepgeometry/main.cxx, exploring/breprepresentation/main.cxx, modeling/assembly/main.cxx, and modeling/metadata/main.cxx.
ModelData_Shape()
Constructor.
Definition: ModelData_Shape.cxx:275