NDEVR
API Documentation
ModelIterator

A base class for easily traversing a model hierarchy, applying an overridden function at each level or for each object. More...

Inheritance diagram for ModelIterator:
[legend]
Collaboration diagram for ModelIterator:
[legend]

Public Types

enum  ParseResult { e_continue_parsing , e_do_not_parse_children , e_finish_parsing }
 The result returned by process functions to control iteration flow. More...

Public Member Functions

 ModelIterator ()
 Default constructor.
 ModelIterator (Buffer< Model > models)
 Constructs an iterator initialized with multiple root models.
 ModelIterator (const Model &model)
 Constructs an iterator initialized with a single root model.
void addToStack (const Model &model)
 Adds a model to the internal traversal stack without starting iteration.
Model currentModel () const
 Returns the model currently at the top of the traversal stack.
void parseAll ()
 Parses all models currently on the internal stack and their descendants.
void parseAll (const Model &model)
 Parses the given model and all of its descendants.
void parseAllChildren (const Model &parent)
 Parses all children of the given parent model, but not the parent itself.
void parseAllModels (const Buffer< Model > &models)
 Parses all models in the given buffer and their descendants.
ParseResult parseNext ()
 Parses the next model on the stack, processing it and optionally its geometry and material.

Public Attributes

bool depth_first = true
 Whether to traverse depth-first (true) or breadth-first (false).
std::function< bool(const Model &, const Geometry &)> geo_filter
 Optional filter predicate for geometry processing. Returns true to include.
bool is_recursive = true
 Whether to recurse into child models.
std::function< bool(const Model &, const Material &)> material_filter
 Optional filter predicate for material processing. Returns true to include.
std::function< bool(const Model &)> model_filter
 Optional filter predicate for model processing. Returns true to include.
bool post_process_model = false
 Whether to invoke postProcess() after a model's children have been parsed.
bool process_geometry = true
 Whether to invoke process() for each Geometry on a model.
bool process_material = false
 Whether to invoke process() for each Material on a model.
bool process_model = true
 Whether to invoke process() for the model itself.
bool use_unit = false
 Whether to apply unit conversions during processing.

Protected Member Functions

virtual void _parseAllModels ()
 Internal method that drives the main parsing loop over all stacked models.
Model popNextModel ()
 Pops and returns the next model from the traversal stack.
virtual ParseResult postProcess (Model &model)
 Called after all children of a model have been processed, when post_process_model is true.
virtual ParseResult process (Model &model)
 Called for each model node during traversal.
virtual ParseResult process (Model &model, Geometry &geo)
 Called for each geometry associated with a model.
virtual ParseResult process (Model &model, Material &mat)
 Called for each material associated with a model.
void removeFromPostProcessStack ()
 Removes the current model from the post-process stack.

Protected Attributes

uint04 m_forward_position = 0U
 Current forward index position used in breadth-first traversal.
Buffer< std::pair< Model, uint04 > > m_model_parent_stack
 Stack tracking parent models and their child indices for post-processing.
Buffer< Modelm_model_stack
 The stack of models pending traversal.

Detailed Description

A base class for easily traversing a model hierarchy, applying an overridden function at each level or for each object.


Provides a stack-based iteration mechanism that walks through a tree of Model objects, optionally processing associated Geometry and Material objects at each node. Subclasses override the virtual process() methods to perform custom logic during traversal.

See also
Model, Geometry, Material, DesignObjectLookup

Definition at line 48 of file ModelIterator.h.

Member Enumeration Documentation

◆ ParseResult

The result returned by process functions to control iteration flow.


Enumerator
e_continue_parsing 

Continue normal traversal to sibling and child nodes.

e_do_not_parse_children 

Skip the children of the current node but continue with siblings.

e_finish_parsing 

Stop all traversal immediately.

Definition at line 54 of file ModelIterator.h.

Constructor & Destructor Documentation

◆ ModelIterator() [1/3]

ModelIterator::ModelIterator ( )

Default constructor.


Creates an iterator with an empty model stack.

◆ ModelIterator() [2/3]

ModelIterator::ModelIterator ( const Model & model)
explicit

Constructs an iterator initialized with a single root model.


Parameters
[in]modelThe root model to begin iteration from.

◆ ModelIterator() [3/3]

ModelIterator::ModelIterator ( Buffer< Model > models)
explicit

Constructs an iterator initialized with multiple root models.


Parameters
[in]modelsThe models to iterate over.

Member Function Documentation

◆ _parseAllModels()

virtual void ModelIterator::_parseAllModels ( )
protectedvirtual

Internal method that drives the main parsing loop over all stacked models.


Reimplemented in DesignParameterAccumulator, and DesignParameterFinder.

◆ addToStack()

void ModelIterator::addToStack ( const Model & model)

Adds a model to the internal traversal stack without starting iteration.


Parameters
[in]modelThe model to push onto the stack.

◆ currentModel()

Model ModelIterator::currentModel ( ) const

Returns the model currently at the top of the traversal stack.


Returns
The current Model being iterated over.

◆ parseAll() [1/2]

void ModelIterator::parseAll ( )

Parses all models currently on the internal stack and their descendants.


◆ parseAll() [2/2]

void ModelIterator::parseAll ( const Model & model)

Parses the given model and all of its descendants.


Parameters
[in]modelThe root model to begin parsing from.

Referenced by GravityIntersection::FindGravityPoints().

◆ parseAllChildren()

void ModelIterator::parseAllChildren ( const Model & parent)

Parses all children of the given parent model, but not the parent itself.


Parameters
[in]parentThe parent model whose children will be parsed.

◆ parseAllModels()

void ModelIterator::parseAllModels ( const Buffer< Model > & models)

Parses all models in the given buffer and their descendants.


Parameters
[in]modelsThe collection of models to parse.

◆ parseNext()

ParseResult ModelIterator::parseNext ( )

Parses the next model on the stack, processing it and optionally its geometry and material.


Returns
The ParseResult indicating how iteration should proceed.

◆ popNextModel()

Model ModelIterator::popNextModel ( )
protected

Pops and returns the next model from the traversal stack.


Returns
The next Model to process.

◆ postProcess()

virtual ParseResult ModelIterator::postProcess ( Model & model)
protectedvirtual

Called after all children of a model have been processed, when post_process_model is true.


Parameters
[in]modelThe model being post-processed.
Returns
A ParseResult controlling further traversal.

Reimplemented in DesignParameterAccumulator, DXFBlockWriter, and SelectionInfo.

◆ process() [1/3]

virtual ParseResult ModelIterator::process ( Model & model)
protectedvirtual

Called for each model node during traversal.


Override to add custom model logic.

Parameters
[in]modelThe model being processed.
Returns
A ParseResult controlling further traversal.

Reimplemented in BasicModelIterator, DesignParameterAccumulator, DesignParameterExecutor, DesignParameterFinder, DesignParameterSetter, DXFBlockWriter, DXFTableWriteIterator, and SelectionInfo.

◆ process() [2/3]

virtual ParseResult ModelIterator::process ( Model & model,
Geometry & geo )
protectedvirtual

Called for each geometry associated with a model.


Override to add custom geometry logic.

Parameters
[in]modelThe model that owns the geometry.
[in]geoThe geometry being processed.
Returns
A ParseResult controlling further traversal.

Reimplemented in BasicModelIterator, DesignParameterAccumulator, DesignParameterExecutor, DesignParameterFinder, DesignParameterSetter, DXFTableWriteIterator, and SelectionInfo.

◆ process() [3/3]

virtual ParseResult ModelIterator::process ( Model & model,
Material & mat )
protectedvirtual

Called for each material associated with a model.


Override to add custom material logic.

Parameters
[in]modelThe model that owns the material.
[in]matThe material being processed.
Returns
A ParseResult controlling further traversal.

Reimplemented in BasicModelIterator, DesignParameterAccumulator, DesignParameterExecutor, DesignParameterFinder, DesignParameterSetter, and SelectionInfo.

◆ removeFromPostProcessStack()

void ModelIterator::removeFromPostProcessStack ( )
protected

Removes the current model from the post-process stack.



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