API Documentation
Loading...
Searching...
No Matches
ModelIterator.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Design
28File: ModelIterator
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include <NDEVR/Model.h>
34#include <NDEVR/Geometry.h>
35#include <functional>
36namespace NDEVR
37{
38 /**--------------------------------------------------------------------------------------------------
39 \brief A base class for easily transversing a model heirarchy, applying an overritten function
40 at each level or for each object.
41 **/
43 {
44 public:
46 {
47 e_continue_parsing
48 , e_do_not_parse_children
49 , e_finish_parsing
50 };
52 explicit ModelIterator(const Model& model);
53 explicit ModelIterator(Buffer<Model> models);
54 void parseAll(const Model& model);
55 void parseAll(const Buffer<Model>& models);
56 void parseAll();
59 std::function<bool(const Model&, const Geometry&)> geo_filter;
60 std::function<bool(const Model&, const Material&)> material_filter;
61 std::function<bool(const Model&)> model_filter;
62
63 bool process_material = false;
64 bool process_geometry = true;
65 bool process_model = true;
66 bool post_process_model = false;
67 bool depth_first = true;
68 bool is_recursive = true;
69 bool use_unit = false;
70 PrimitiveProperty material_property = PrimitiveProperty::Solid;
71 protected:
72 virtual ParseResult process(Model& model);
73 virtual ParseResult process(Model& model, Material& mat);
74 virtual ParseResult process(Model& model, Geometry& geo);
75 virtual ParseResult postProcess(Model& model);
77 virtual void parseAllModels();
82 };
83 /**--------------------------------------------------------------------------------------------------
84 \brief A class for easily transversing a model heirarchy, applying an optional function at each level.
85 **/
87 {
88 public:
90 explicit BasicModelIterator(const Model& model);
91 explicit BasicModelIterator(const Buffer<Model>& models);
92 explicit BasicModelIterator(const std::function<ParseResult(Model&, Geometry&)>& geo_callback);
93 explicit BasicModelIterator(const std::function<ParseResult(Model&, Material&)>& material_callback);
94 explicit BasicModelIterator(const std::function<ParseResult(Model&)>& model_callback);
95
96 void setCallback(const std::function<ParseResult(Model&, Geometry&)>& geo_callback);
97 void setCallback(const std::function<ParseResult(Model&, Material&)>& material_callback);
98 void setCallback(const std::function<ParseResult(Model&)>& model_callback);
99 protected:
100 ParseResult process(Model& model) final override;
101 ParseResult process(Model& model, Material& mat) final override;
102 ParseResult process(Model& model, Geometry& geo) final override;
103 protected:
107 };
108}
109
110
111
112
#define NDEVR_DESIGN_API
Definition DLLInfo.h:55
A class for easily transversing a model heirarchy, applying an optional function at each level.
Definition ModelIterator.h:87
ParseResult process(Model &model, Geometry &geo) final override
std::function< ParseResult(Model &)> m_model_callback
Definition ModelIterator.h:106
void setCallback(const std::function< ParseResult(Model &, Geometry &)> &geo_callback)
BasicModelIterator(const Model &model)
std::function< ParseResult(Model &, Geometry &)> m_geo_callback
Definition ModelIterator.h:104
void setCallback(const std::function< ParseResult(Model &, Material &)> &material_callback)
BasicModelIterator(const std::function< ParseResult(Model &, Geometry &)> &geo_callback)
ParseResult process(Model &model, Material &mat) final override
BasicModelIterator(const Buffer< Model > &models)
ParseResult process(Model &model) final override
std::function< ParseResult(Model &, Material &)> m_material_callback
Definition ModelIterator.h:105
BasicModelIterator(const std::function< ParseResult(Model &)> &model_callback)
BasicModelIterator(const std::function< ParseResult(Model &, Material &)> &material_callback)
void setCallback(const std::function< ParseResult(Model &)> &model_callback)
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
A core class within the model heirarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:64
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:51
A core class that represents a node on model heirarchy. This node may contain a Geometry or one or mo...
Definition Model.h:58
A base class for easily transversing a model heirarchy, applying an overritten function at each level...
Definition ModelIterator.h:43
Buffer< Model > m_model_parent_stack
Definition ModelIterator.h:81
ParseResult parseNext()
ModelIterator(const Model &model)
std::function< bool(const Model &, const Geometry &)> geo_filter
Definition ModelIterator.h:59
virtual void parseAllModels()
void removeFromPostProcessStack()
virtual ParseResult process(Model &model, Material &mat)
ModelIterator(Buffer< Model > models)
void parseAll(const Model &model)
virtual ParseResult process(Model &model)
std::function< bool(const Model &, const Material &)> material_filter
Definition ModelIterator.h:60
Buffer< uint04 > m_model_parent_child_count
Definition ModelIterator.h:80
Model currentModel() const
Buffer< Model > m_model_stack
Definition ModelIterator.h:79
ParseResult
Definition ModelIterator.h:46
std::function< bool(const Model &)> model_filter
Definition ModelIterator.h:61
virtual ParseResult process(Model &model, Geometry &geo)
void parseAll(const Buffer< Model > &models)
virtual ParseResult postProcess(Model &model)
Definition ACIColor.h:37
PrimitiveProperty
Definition DesignObjectBase.h:44