Hide menu
Loading...
Searching...
No Matches
cadex::ModelData::ShapeIterator Class Reference

Iterates over subshapes in a shape. More...

#include <cadex/ModelData/ShapeIterator.hxx>

Inheritance diagram for cadex::ModelData::ShapeIterator:
cadex::BaseObject

Public Member Functions

 ShapeIterator (const Body &theBody)
 
 ShapeIterator (const Shape &theShape)
 
 ShapeIterator (const Body &theBody, ShapeType theType)
 
 ShapeIterator (const Shape &theShape, ShapeType theType)
 
bool HasNext () const
 
const ShapeNext ()
 
- Public Member Functions inherited from cadex::BaseObject
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.
 

Additional Inherited Members

- Public Types inherited from cadex::BaseObject
typedef std::shared_ptr< internal::BaseObjectImpl > ImplType
 
- Protected Member Functions inherited from cadex::BaseObject
 BaseObject (const ImplType &theImpl)
 

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::ShapeIterator should be used as follows:

ModelData::Wire aWire = ...;
while (i.HasNext()) {
const ModelData::Shape& aChild = i.Next(); //edge
ModelData::ShapeType aType = aChild.Type();
assert (aType == ModelData::ShapeType::Edge);
}
Base class of topological shapes.
Definition Shape.hxx:32
ShapeType Type() const
Returns a shape type. For a null object returns Undefined.
Definition Shape.cxx:244
Iterates over subshapes in a shape.
Definition ShapeIterator.hxx:32
Defines a connected set of edges.
Definition Wire.hxx:32
ShapeType
Defines shape type.
Definition ShapeType.hxx:27

Exploration of particular types

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

ModelData::Solid aSolid = ...;
ModelData::ShapeIterator i (aSolid, ModelData::ShapeType_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
...
}
Defines an edge.
Definition Edge.hxx:33
Defines a topological solid.
Definition Solid.hxx:32

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
MTKConverter/Program.cs, MTKConverter/main.cxx, helpers/shape_processor.cs, helpers/shape_processor.hxx, machining/dfm_analyzer/Program.cs, machining/dfm_analyzer/main.cxx, machining/feature_recognizer/Program.cs, machining/feature_recognizer/main.cxx, molding/dfm_analyzer/Program.cs, molding/dfm_analyzer/main.cxx, molding/feature_recognizer/Program.cs, molding/feature_recognizer/main.cxx, sheet_metal/dfm_analyzer/Program.cs, sheet_metal/dfm_analyzer/main.cxx, sheet_metal/feature_recognizer/Program.cs, sheet_metal/feature_recognizer/main.cxx, sheet_metal/unfolder/Program.cs, and sheet_metal/unfolder/main.cxx.