NDEVR
API Documentation
SelectionTreeManager.h
1#pragma once
2#include <NDEVR/DesignObjectBase.h>
3#if NDEVR_VIEWPORT
4#include <NDEVR/Model.h>
5#include <NDEVR/TimeSpan.h>
6#include <NDEVR/Geometry.h>
7namespace NDEVR
8{
10 class Model;
11 class Geometry;
12 class BasicThread;
13 class InfoPipe;
14
25 class NDEVR_DESIGN_API SelectionTreeManager
26 {
27 public:
32#if NDEVR_SUPPORTS_THREADING
38 void startLoop(DesignObjectLookup* lookup, const TimeSpan& loop_time);
42 void stopLoop();
43#endif
54 void createTrees(const Model& model, const void* lock);
69 bool createGeoTree(const Geometry& geo, PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 tree_bucket_size, const void* lock);
78 bool sortVertices(const Geometry& geo, PrimitiveProperty primitive_property, VertexProperty vertex_property, const void* lock);
89 protected:
95 bool canSort(const Geometry& geo);
106 void createTree(const Geometry& geo, PrimitiveProperty primitive_property, VertexProperty vertex_property, const void* lock);
112 void createModelTree(const Buffer<Model>& models, const void* lock);
113 protected:
124 InfoPipe* m_log = nullptr;
126 TimeSpan m_loop_timespan = Constant<TimeSpan>::Invalid;
127#if NDEVR_SUPPORTS_THREADING
129#endif
132 bool m_requesting_delete = false;
133 };
134}
135#endif
A thread that executes a user-provided callback function concurrently.
Definition BasicThread.h:47
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
A core class where all Design Objects including models, materials, and geometries are stored.
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
A light-weight base class for Log that allows processes to update, without the need for additional in...
A core class that represents a node on model hierarchy.
Definition Model.h:292
bool createGeoTree(const Geometry &geo, PrimitiveProperty primitive_property, VertexProperty vertex_property, uint04 tree_bucket_size, const void *lock)
Creates a spatial selection tree for a single geometry object.
bool sortVertices(const Geometry &geo, PrimitiveProperty primitive_property, VertexProperty vertex_property, const void *lock)
Sorts the vertices of a geometry spatially to improve cache coherence and selection performance.
InfoPipe * m_log
Optional logging pipe for diagnostic output.
Time m_last_modified_time
Timestamp of the most recent geometry modification observed.
Buffer< PrimitiveProperty > m_primitive_properties
Primitive property channels corresponding to entries in m_tree_geos.
uint04 m_point_bucket_size
Maximum elements per leaf node for point-based trees.
Buffer< Geometry > m_sort_geos
Geometries queued for vertex sorting.
void onSceneDeleted(UUID id)
Handles cleanup when an entire scene is deleted, removing all associated tree data.
bool m_requesting_delete
Whether a deletion cleanup pass has been requested.
TimeSpan m_loop_timespan
Interval between background loop iterations.
TimeSpan m_edit_timespan
Minimum time after a geometry edit before tree creation is allowed.
DesignObjectLookup * m_loop_lookup
Lookup reference used by the background loop.
bool canSort(const Geometry &geo)
Checks whether the given geometry is eligible for vertex sorting.
Set< UUID > m_active_models
Set of model UUIDs currently being processed or tracked.
void createTrees(const Model &model, const void *lock)
Creates selection trees for all geometry within the given model and its children.
Dictionary< UUID, Time > m_modified_time
Tracks the last modification time per geometry UUID.
Buffer< Geometry > m_tree_geos
Geometries queued for tree construction.
uint04 m_triangle_bucket_size
Maximum elements per leaf node for triangle-based trees.
void createTrees(DesignObjectLookup *lookup)
Creates selection trees for all geometry within the given lookup.
void createModelTree(const Buffer< Model > &models, const void *lock)
Creates a spatial tree that indexes child models for a parent model hierarchy.
void stopLoop()
Stops the background tree-rebuild loop and waits for the thread to finish.
void createTree(const Geometry &geo, PrimitiveProperty primitive_property, VertexProperty vertex_property, const void *lock)
Internal method that creates a selection tree for a single geometry using stored bucket sizes.
uint04 m_model_child_bucket_size
Maximum elements per leaf node for model child trees.
void startLoop(DesignObjectLookup *lookup, const TimeSpan &loop_time)
Starts a background thread that periodically rebuilds selection trees for modified geometry.
Buffer< VertexProperty > m_vertex_properties
Vertex property channels corresponding to entries in m_tree_geos.
SelectionTreeManager()
Constructs a SelectionTreeManager with default bucket sizes and timespan settings.
BasicThread * m_loop_thread
Background thread running the periodic tree-rebuild loop.
void onGeometryDeleted(UUID id)
Handles cleanup when a geometry object is deleted, removing its associated tree data.
void setEditTimespan(TimeSpan span)
Sets the time from a geometry edit before we create a tree.
uint04 m_line_bucket_size
Maximum elements per leaf node for line-based trees.
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
Definition Set.h:59
Stores a time span, or difference between two times, with an optional start time.
Definition TimeSpan.h:46
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:62
A universally unique identifier (UUID) is a 128-bit number used to identify information in computer s...
Definition UUID.h:61
The primary namespace for the NDEVR SDK.
VertexProperty
Per-vertex data channels that can be stored in the vertex table to be used by Geometry.
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
PrimitiveProperty
Describes which rendering property a primitive index buffer corresponds to.