NDEVR
API Documentation
BasicModelIterator

A convenience subclass of ModelIterator that delegates processing to user-supplied std::function callbacks rather than requiring a full subclass override. More...

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

Public Member Functions

 BasicModelIterator ()
 Default constructor.
 BasicModelIterator (const Buffer< Model > &models)
 Constructs an iterator initialized with multiple root models.
 BasicModelIterator (const Model &model)
 Constructs an iterator initialized with a single root model.
 BasicModelIterator (const std::function< ParseResult(Model &)> &model_callback)
 Constructs an iterator with a model processing callback.
 BasicModelIterator (const std::function< ParseResult(Model &, Geometry &)> &geo_callback)
 Constructs an iterator with a geometry processing callback.
 BasicModelIterator (const std::function< ParseResult(Model &, Material &)> &material_callback)
 Constructs an iterator with a material processing callback.
void setCallback (const std::function< ParseResult(Model &)> &model_callback)
 Sets the callback invoked for each model during traversal.
void setCallback (const std::function< ParseResult(Model &, Geometry &)> &geo_callback)
 Sets the callback invoked for each geometry during traversal.
void setCallback (const std::function< ParseResult(Model &, Material &)> &material_callback)
 Sets the callback invoked for each material during traversal.
Public Member Functions inherited from ModelIterator
 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.

Protected Member Functions

ParseResult process (Model &model) final override
 Dispatches to m_model_callback if set; otherwise returns e_continue_parsing.
ParseResult process (Model &model, Geometry &geo) final override
 Dispatches to m_geo_callback if set; otherwise returns e_continue_parsing.
ParseResult process (Model &model, Material &mat) final override
 Dispatches to m_material_callback if set; otherwise returns e_continue_parsing.
Protected Member Functions inherited from ModelIterator
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.
void removeFromPostProcessStack ()
 Removes the current model from the post-process stack.

Protected Attributes

std::function< ParseResult(Model &, Geometry &)> m_geo_callback
 Callback invoked for each geometry during traversal.
std::function< ParseResult(Model &, Material &)> m_material_callback
 Callback invoked for each material during traversal.
std::function< ParseResult(Model &)> m_model_callback
 Callback invoked for each model during traversal.
Protected Attributes inherited from ModelIterator
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.

Additional Inherited Members

Public Types inherited from ModelIterator
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 Attributes inherited from ModelIterator
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.

Detailed Description

A convenience subclass of ModelIterator that delegates processing to user-supplied std::function callbacks rather than requiring a full subclass override.


Allows setting geometry, material, and model callbacks either via the constructor or through setCallback(). The appropriate callback is invoked during traversal.

Definition at line 189 of file ModelIterator.h.

Constructor & Destructor Documentation

◆ BasicModelIterator() [1/6]

BasicModelIterator::BasicModelIterator ( )

Default constructor.


Creates an iterator with no callbacks set.

◆ BasicModelIterator() [2/6]

BasicModelIterator::BasicModelIterator ( const Model & model)
explicit

Constructs an iterator initialized with a single root model.


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

◆ BasicModelIterator() [3/6]

BasicModelIterator::BasicModelIterator ( const Buffer< Model > & models)
explicit

Constructs an iterator initialized with multiple root models.


Parameters
[in]modelsThe collection of models to iterate over.

◆ BasicModelIterator() [4/6]

BasicModelIterator::BasicModelIterator ( const std::function< ParseResult(Model &, Geometry &)> & geo_callback)
explicit

Constructs an iterator with a geometry processing callback.


Parameters
[in]geo_callbackThe function to invoke for each geometry encountered.

◆ BasicModelIterator() [5/6]

BasicModelIterator::BasicModelIterator ( const std::function< ParseResult(Model &, Material &)> & material_callback)
explicit

Constructs an iterator with a material processing callback.


Parameters
[in]material_callbackThe function to invoke for each material encountered.

◆ BasicModelIterator() [6/6]

BasicModelIterator::BasicModelIterator ( const std::function< ParseResult(Model &)> & model_callback)
explicit

Constructs an iterator with a model processing callback.


Parameters
[in]model_callbackThe function to invoke for each model encountered.

Member Function Documentation

◆ process() [1/3]

ParseResult BasicModelIterator::process ( Model & model)
finaloverrideprotectedvirtual

Dispatches to m_model_callback if set; otherwise returns e_continue_parsing.


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

Reimplemented from ModelIterator.

◆ process() [2/3]

ParseResult BasicModelIterator::process ( Model & model,
Geometry & geo )
finaloverrideprotectedvirtual

Dispatches to m_geo_callback if set; otherwise returns e_continue_parsing.


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

Reimplemented from ModelIterator.

◆ process() [3/3]

ParseResult BasicModelIterator::process ( Model & model,
Material & mat )
finaloverrideprotectedvirtual

Dispatches to m_material_callback if set; otherwise returns e_continue_parsing.


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

Reimplemented from ModelIterator.

◆ setCallback() [1/3]

void BasicModelIterator::setCallback ( const std::function< ParseResult(Model &)> & model_callback)

Sets the callback invoked for each model during traversal.


Parameters
[in]model_callbackThe model processing function.

◆ setCallback() [2/3]

void BasicModelIterator::setCallback ( const std::function< ParseResult(Model &, Geometry &)> & geo_callback)

Sets the callback invoked for each geometry during traversal.


Parameters
[in]geo_callbackThe geometry processing function.

◆ setCallback() [3/3]

void BasicModelIterator::setCallback ( const std::function< ParseResult(Model &, Material &)> & material_callback)

Sets the callback invoked for each material during traversal.


Parameters
[in]material_callbackThe material processing function.

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