NDEVR
API Documentation
DesignObjectResourceCache.h
1#pragma once
2#include <NDEVR/Model.h>
3#include <NDEVR/Geometry.h>
4namespace NDEVR
5{
15 {
16 public:
26 {
27 Model parent = model.getParent();
28 if (parent.isValid())
29 parent.removeChild(model);
30 model.clearChildren();
31 model.clearLayer();
32 model.clearMaterial();
33 model.removeGeometry();
34
35 model.set(NDPO::is_deleted, false);
37 model.set<NDPN::type>(StringView());
38 model.set<NDPN::calculation_ignored>(false);
39 model.set<NDPO::is_application_owned>(false);
40 model.set(NDPN::child_base_ptr, nullptr);
41 model.set<NDPN::can_select_children>(false);
43 model.set<NDPO::author>(StringView());
44 Time time = Time::SystemTime();
45 model.set<NDPO::modified_time>(time);
46 model.set<NDPO::desc_modified_time>(time);
47 model.set<NDPO::asc_modified_time>(time);
48 model.set<NDPO::creation_time>(time);
49 model.set<NDPO::library_id>(Constant<UUID>::Invalid);
50 model.clearAllMetaData();
51
52 }
53
62 void addToCache(const Buffer<Model>& items)
63 {
64 for (Model iter : items)
66 models.addAll(items);
67 }
68
77 void addToCache(const Buffer<Geometry>& items)
78 {
79 for (Geometry iter : items)
80 {
81 Buffer<Model> parents = iter.getParents();
82 for (Model parent : parents)
83 parent.removeGeometry();
84 }
85 geometries.addAll(items);
86 }
87
97 void createChildren(Model& parent, uint04 size)
98 {
99 if (size > models.size())
100 {
101 parent.createChildren(size - models.size());
102 }
103 uint04 cache_size = models.size();
104 for (uint04 i = 0; i < getMin(cache_size, size); i++)
105 {
106 createModel(parent);
107 }
108 }
109
120 {
121 if (models.size() > 0)
122 {
123 Model model = models.last();
124 models.removeLast();
125 parent.addChild(model);
126 return model;
127 }
128 else
129 {
130 return parent.createChild();
131 }
132 }
133
144 {
145 if (geometries.size() > 0)
146 {
147 Geometry geo = geometries.last();
148 geometries.removeLast();
149 parent.setGeometryChild(geo);
150 return geo;
151 }
152 else
153 {
154 return parent.createChildGeometry();
155 }
156 }
157
160 };
161}
A specification of upper and lower bounds in N-dimensions.
Definition Bounds.hpp:54
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A cache for reusing Model and Geometry objects to avoid repeated allocation.
Model createModel(Model &parent)
Creates or retrieves a child Model for the given parent, preferring cached models.
void addToCache(const Buffer< Model > &items)
Adds a buffer of Models to the cache after resetting each to defaults.
void addToCache(const Buffer< Geometry > &items)
Adds a buffer of Geometry objects to the cache after detaching them from parents.
void createChildren(Model &parent, uint04 size)
Ensures a parent model has the specified number of children, using cached models when available.
Buffer< Geometry > geometries
Cached geometries that have been detached and are available for reuse.
Buffer< Model > models
Cached models that have been reset and are available for reuse.
void setModelToDefaults(Model &model)
Resets a Model to its default state so it can be reused from the cache.
Geometry createGeometry(Model &parent)
Creates or retrieves a Geometry for the given parent model, preferring cached geometries.
void set(t_property_type property, const t_type &value)
Sets a property value in the database.
bool isValid() const
Checks whether this design object has a valid index into the database.
void clearAllMetaData()
Removes all metadata entries from this design object.
A core class within the model hierarchy containing vertex-based data (Usually 3D data) within a set c...
Definition Geometry.h:143
Templated logic for doing matrix multiplication.
Definition Matrix.hpp:182
A core class that represents a node on model hierarchy.
Definition Model.h:292
void clearChildren()
Removes all children from this model without deleting them.
Model getParent() const
Returns the parent model of this model.
void removeChild(const Model &model)
Removes a specific child model from this model's child list.
Model createChild()
Creates a new child model and appends it to this model's child list.
Geometry createChildGeometry()
Creates a new child geometry for this model.
void addChild(Model &child)
Adds an existing model as a child of this model.
void clearMaterial()
Removes the material assignment from this model.
void removeGeometry()
Removes the geometry reference from this model (does not delete the geometry).
void setGeometryChild(Geometry &geo)
Sets the geometry child of this model to an existing Geometry object.
void clearLayer()
Removes the layer assignment from this model.
void createChildren(uint04 child_size)
Creates multiple children at once.
The core String View class for the NDEVR API.
Definition StringView.h:58
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
static Time SystemTime()
Retrieves the current system time which is a combination of std::chrono::steady_clock to ensure smoot...
The primary namespace for the NDEVR SDK.
@ calculation_ignored
Whether this model is ignored in calculations (e.g., volume, area).
Definition Model.h:61
@ type
The type identifier string for this model node.
Definition Model.h:58
@ child_base_ptr
Pointer to the DesignObjectBase that stores child model data.
Definition Model.h:72
@ fixed_bounding_box
A user-defined fixed bounding box override for this model.
Definition Model.h:59
@ can_select_children
Whether children of this model can be individually selected.
Definition Model.h:62
constexpr t_type getMin(const t_type &left, const t_type &right)
Finds the minimum of the given arguments based on the < operator Author: Tyler Parke Date: 2017-11-05...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
@ author
The author or creator of the object.
@ desc_modified_time
Timestamp tracking descending-order modification.
@ creation_time
Timestamp when the object was created.
@ modified_time
Timestamp when the object was last modified.
@ library_id
UUID referencing a library item this object was created from.
@ is_application_owned
Whether the object is owned and managed by the application.
@ transform
A 4x4 transform matrix that maps local coordinates into global space.
@ asc_modified_time
Timestamp tracking ascending-order modification.
@ is_deleted
Whether the object has been soft-deleted.
Defines for a given type (such as sint04, fltp08, UUID, etc) a maximum, minimum, and reserved 'invali...