NDEVR
API Documentation
DesignParameterAccumulator.h
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: DesignParameterAccumulator
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "DLLInfo.h"
34#include <NDEVR/DesignParameter.h>
35#include <NDEVR/DesignObject.h>
36#include <NDEVR/ModelIterator.h>
37
38namespace NDEVR
39{
40 class Geometry;
41 class Model;
42 class TableColumn;
43 class DesignObject;
44
50 class NDEVR_DESIGN_API DesignParameterFinder final : public ModelIterator
51 {
52 public:
56 ParseResult process(Model& model) final override;
57
62 ParseResult process(Model& model, Geometry& geo) final override;
63
68 ParseResult process(Model& model, Material& mat) final override;
69
72 void addParameter(const StringView& parameter);
73 private:
75 void _parseAllModels() final override;
76 public:
79 };
80
85 class NDEVR_DESIGN_API DesignParameterAccumulator final : public ModelIterator
86 {
87 public:
100 public:
104 explicit DesignParameterAccumulator(const DesignParameter& design_parameter, BitFlag mode = BitFlag(0));
105
108 void setToDefaults(const DesignObject& object);
109
114 void accumulate(fltp08 value, const uint01& dim = X, bool to_unit = true);
115
119 void accumulate(const DesignObject& object, fltp08 known_avg = Constant<fltp08>::Invalid);
120
123 void addToTotal(fltp08 value);
124
128
130 void clear();
131
134 void setCollectVerticesByPrimitive(PrimitiveProperty vertex_collection_primitive);
135 private:
139 ParseResult process(Model& model) final override;
140
145 ParseResult process(Model& model, Geometry& geo) final override;
146
151 ParseResult process(Model& model, Material& mat) final override;
152
156 ParseResult postProcess(Model& m) final override;
157 private:
159 void _parseAllModels() final override;
160
164 bool _setupValues(const DesignObject& object);
165
168 void _accumulate(const DesignObject& object);
169
173 Matrix<fltp08> _matrix(const DesignObject& object);
174
178 void _accumulateVertices(const Geometry& geo, const TableColumn& column);
179
184 void _accumulate(const DesignObject& object, uint04 row, const TableColumn& column);
185 //void _accumulate(const StringView& data);
186 public:
207 bool is_normal_prop = false;
208 bool add_commas = false;
209 bool recursive_matrix = false;
210 bool use_defaults = false;
216 protected:
218 bool is_matrix_prop = false;
219 bool is_design_index = false;
220 bool is_vertex_index = false;
221 bool is_special_field = false;
223 DesignObject::DesignObjectType m_design_type = DesignObject::DesignObjectType::e_model;
225 };
226
230 class NDEVR_DESIGN_API DesignParameterSetter final : public ModelIterator
231 {
232 public:
238 public:
242 ParseResult process(Model& model) final override;
243
248
253
258
262 explicit DesignParameterSetter(const DesignParameter& design_parameter, SetMode mode);
263
266 void setToDefaults(const DesignObject& object);
267 private:
272 ParseResult process(Model& model, Geometry& geo) final override;
273
278 ParseResult process(Model& model, Material& mat) final override;
279
281 void clear();
282 private:
285 StringView currentValue() const;
286
290 bool _setupValues(const DesignObject& object);
291
294 void _set(DesignObject& object);
295
299 Matrix<fltp08> _matrix(const DesignObject& object) const;
300
304 void _setVertices(Geometry& geo, TableColumn& column);
305
310 void _set(DesignObject& object, uint04 row, TableColumn& column);
311 public:
321 uint04 max_num_of_values = Constant<uint04>::Max;
322 bool is_normal_prop = false;
323 bool recursive = true;
324 bool recursive_matrix = false;
325 bool use_defaults = false;
326 bool swap_result = false;
327 protected:
329 bool is_matrix_prop = false;
330 bool is_design_index = false;
331 bool is_vertex_index = false;
332 bool is_special_field = false;
333 DesignObject::DesignObjectType m_design_type = DesignObject::DesignObjectType::e_model;
334 uint04 property_index = Constant<uint04>::Invalid;
335 };
336
337
338}
339
340
341
A bitset that stores 8 bits (elements with only two possible values: 0 or 1, true or false,...
Definition BitFlag.hpp:55
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Provides a constant, unmodifiable pointer that has shared ownership of a dynamically allocated object...
Definition Pointer.hpp:276
A low-level database object that can be used to access general stored properties within the NDEVR Mod...
fltp08 lower_std_dev
Standard deviation for values less than the average.
fltp08 total_value
The running sum of all accumulated values.
String default_value
Default value string used when a parameter is missing.
uint04 total_upper
Count of values greater than the average.
void clear()
Resets all accumulated statistics and collected data to their initial state.
fltp08 upper_variance
Variance for values greater than the average.
void setToDefaults(const DesignObject &object)
Initialises accumulator defaults from the given design object's properties.
uint04 min_digits
Minimum number of digits for string formatting.
uint04 min_num_of_decimals
Minimum number of decimal places for string formatting.
uint04 total_lower
Count of values less than the average.
bool is_vertex_index
Whether the parameter represents a vertex-level index property.
fltp08 lower_variance
Variance for values less than the average.
uint04 max_num_of_values
Maximum number of values to collect before stopping.
uint04 max_num_of_decimals
Maximum number of decimal places for string formatting.
void _parseAllModels() final override
Internal entry point that begins parsing all models in the hierarchy.
Buffer< StringAllocatingView > string_values
Collected string representations of parameter values (when e_get_strings is set).
Buffer< fltp08 > float_values
Collected raw floating-point values (when e_get_floats is set).
bool is_normal_prop
Whether the parameter is a standard built-in property.
void setCollectVerticesByPrimitive(PrimitiveProperty vertex_collection_primitive)
Configures vertex collection to gather vertices by the specified primitive property.
bool recursive_matrix
Whether to recursively compose parent transform matrices.
fltp08 upper_std_dev
Standard deviation for values greater than the average.
bool is_matrix_prop
Whether the parameter represents a matrix-type property.
ParseResult process(Model &model, Geometry &geo) final override
Processes a Geometry node associated with a Model during accumulation.
ParseResult process(Model &model) final override
Processes a single Model node during accumulation.
fltp08 average
The computed average value, or Invalid if not yet calculated.
bool add_commas
Whether to insert commas as thousands separators in formatted output.
uint04 total_count
Total number of values accumulated.
fltp08 max
The maximum value encountered during accumulation.
DesignObject::DesignObjectType m_design_type
The type of design object this accumulator targets.
bool use_defaults
Whether to use default_value when the parameter is absent from an object.
ParseResult process(Model &model, Material &mat) final override
Processes a Material node associated with a Model during accumulation.
void accumulate(const DesignObject &object, fltp08 known_avg=Constant< fltp08 >::Invalid)
Accumulates parameter data from a design object.
uint04 property_index
Cached column/property index for the current parameter lookup.
DesignParameterAccumulator(const DesignParameter &design_parameter, BitFlag mode=BitFlag(0))
Constructs a DesignParameterAccumulator for a specific parameter.
DesignParameter parameter
The design parameter being accumulated.
bool is_design_index
Whether the parameter represents a design-level index property.
DesignObject::DesignObjectType type()
Returns the DesignObjectType that this accumulator is targeting.
ParseResult postProcess(Model &m) final override
Post-processes a Model after its children have been visited, finalising statistics.
fltp08 total_value_c
Kahan summation compensation term for maintaining precision during accumulation.
AccumulateMode
Defines which statistical or data-collection operations to perform during accumulation.
@ e_get_average
Compute the average value.
@ e_get_strings
Collect parameter values as strings.
@ e_get_std_dev
Compute upper and lower standard deviation relative to the average.
@ e_get_total
Compute the total (sum) of all values.
@ e_get_indices
Collect the row/object indices of matched parameters.
@ e_get_variance
Compute upper and lower variance relative to the average.
@ e_get_max_min
Collect the maximum and minimum values.
@ e_get_floats
Collect raw floating-point parameter values.
fltp08 min
The minimum value encountered during accumulation.
void accumulate(fltp08 value, const uint01 &dim=X, bool to_unit=true)
Accumulates a single floating-point value into the running statistics.
StringAllocatingView string_cache
Temporary string buffer used during value formatting.
bool include_unit_symbols
Whether to append unit symbols (e.g., "m", "ft") in formatted string output.
BitFlag accumulate_mode
Bitmask of AccumulateMode flags controlling which statistics to collect.
PrimitiveProperty m_vertex_collection_primitive
The primitive property used to group vertices during collection.
bool is_special_field
Whether the parameter requires special handling (e.g., computed fields).
void addToTotal(fltp08 value)
Adds a value directly to the running total without updating other statistics.
Buffer< uint04 > indices
Collected row or object indices (when e_get_indices is set).
ConstPointer< Unit > override_unit
Optional unit override for value conversion. Null uses the parameter's default unit.
Matrix< fltp08 > transform
The current transformation matrix applied during accumulation.
Searches a model hierarchy and pulls a list of available parameters along with the count for how many...
ParseResult process(Model &model, Material &mat) final override
Processes a Material node associated with a Model during iteration.
ParseResult process(Model &model) final override
Processes a single Model node during iteration, collecting its parameters.
Dictionary< String, uint04 > parameter_count
Maps each parameter name to the number of occurrences found.
void _parseAllModels() final override
Internal entry point that begins parsing all models in the hierarchy.
ParseResult process(Model &model, Geometry &geo) final override
Processes a Geometry node associated with a Model during iteration.
Buffer< DesignParameter > parameters
The collected list of unique design parameters found.
void addParameter(const StringView &parameter)
Manually adds a parameter by name to the finder's collection.
bool is_design_index
Whether the parameter represents a design-level index property.
DesignObject::DesignObjectType m_design_type
The type of design object this setter targets.
String default_value
Default value string used when no explicit value is provided.
fltp08 total_value_c
Kahan summation compensation term for maintaining precision.
bool is_normal_prop
Whether the parameter is a standard built-in property.
Matrix< fltp08 > transform
The current transformation matrix applied during setting.
DesignParameterSetter(const DesignParameter &design_parameter, SetMode mode)
Constructs a DesignParameterSetter for a specific parameter and set mode.
DesignParameter parameter
The design parameter being set.
ParseResult process(DesignObject &object)
Sets the parameter value on a generic DesignObject.
ParseResult process(Model &model, Material &mat) final override
Processes a Material node associated with a Model during iteration.
Buffer< uint04 > indices
Indices specifying which rows or objects to target.
bool swap_result
Whether to swap byte order of the result value.
bool is_matrix_prop
Whether the parameter represents a matrix-type property.
void setToDefaults(const DesignObject &object)
Initialises setter defaults from the given design object's properties.
SetMode
Defines the mode used when setting parameter values.
@ e_set_from_strings
Set parameter values by parsing from string representations.
Buffer< String > string_values
The string values to apply, one per object or vertex.
uint04 set_offset
Current offset into string_values or float_values during iteration.
Buffer< fltp08 > float_values
Floating-point values to apply when not using string mode.
bool is_vertex_index
Whether the parameter represents a vertex-level index property.
bool recursive
Whether to recurse into child models.
uint04 property_index
Cached column/property index for the current parameter lookup.
uint04 total_count
Total number of values that have been set so far.
bool recursive_matrix
Whether to recursively compose parent transform matrices.
bool use_defaults
Whether to apply default_value when the parameter is absent.
bool is_special_field
Whether the parameter requires special handling (e.g., computed fields).
ParseResult process(Material &mat)
Sets the parameter value on a Material.
ParseResult process(Model &model) final override
Processes a single Model node, setting its parameter value.
ParseResult process(Geometry &geo)
Sets the parameter value on a Geometry.
ParseResult process(Model &model, Geometry &geo) final override
Processes a Geometry node associated with a Model during iteration.
uint04 max_num_of_values
Maximum number of values to set before stopping.
SetMode set_mode
The current mode controlling how values are interpreted.
A definition of data that is logically stored in the Model hierarchy.
A hash-based key-value store, useful for quick associative lookups.
Definition Dictionary.h:64
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
Container responsible for storing and setting the appearance of a Model or Geometry within the NDEVR ...
Definition Material.h:153
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
ParseResult
The result returned by process functions to control iteration flow.
ModelIterator()
Default constructor.
A core class that represents a node on model hierarchy.
Definition Model.h:292
This class is like a string view, but may optionally store the data internally Useful if the return t...
Definition String.h:1278
The core String View class for the NDEVR API.
Definition StringView.h:58
The core String class for the NDEVR API.
Definition String.h:95
A virtual storage type that is used with Table class to store data where the actual mechanism for sto...
Definition TableColumn.h:86
The primary namespace for the NDEVR SDK.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
double fltp08
Defines an alias representing an 8 byte floating-point number.
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...
PrimitiveProperty
Describes which rendering property a primitive index buffer corresponds to.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...
Defines a unit of measurement for converting and displaying data values.
Definition Unit.h:39