NDEVR
API Documentation
SelectionTreeManager

Manages selection trees, which optimize the process of selecting data within large Geometry objects. More...

Collaboration diagram for SelectionTreeManager:
[legend]

Public Member Functions

 SelectionTreeManager ()
 Constructs a SelectionTreeManager with default bucket sizes and timespan settings.
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.
void createTrees (const Model &model, const void *lock)
 Creates selection trees for all geometry within the given model and its children.
void createTrees (DesignObjectLookup *lookup)
 Creates selection trees for all geometry within the given lookup.
void onGeometryDeleted (UUID id)
 Handles cleanup when a geometry object is deleted, removing its associated tree data.
void onSceneDeleted (UUID id)
 Handles cleanup when an entire scene is deleted, removing all associated tree data.
void setEditTimespan (TimeSpan span)
 Sets the time from a geometry edit before we create a tree.
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.
void startLoop (DesignObjectLookup *lookup, const TimeSpan &loop_time)
 Starts a background thread that periodically rebuilds selection trees for modified geometry.
void stopLoop ()
 Stops the background tree-rebuild loop and waits for the thread to finish.

Protected Member Functions

bool canSort (const Geometry &geo)
 Checks whether the given geometry is eligible for vertex sorting.
void createModelTree (const Buffer< Model > &models, const void *lock)
 Creates a spatial tree that indexes child models for a parent model hierarchy.
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.

Protected Attributes

Set< UUIDm_active_models
 Set of model UUIDs currently being processed or tracked.
TimeSpan m_edit_timespan = TimeSpan(2.0)
 Minimum time after a geometry edit before tree creation is allowed.
Time m_last_modified_time = Time(0)
 Timestamp of the most recent geometry modification observed.
uint04 m_line_bucket_size = 32
 Maximum elements per leaf node for line-based trees.
InfoPipem_log = nullptr
 Optional logging pipe for diagnostic output.
DesignObjectLookupm_loop_lookup = nullptr
 Lookup reference used by the background loop.
BasicThreadm_loop_thread = nullptr
 Background thread running the periodic tree-rebuild loop.
TimeSpan m_loop_timespan = Constant<TimeSpan>::Invalid
 Interval between background loop iterations.
uint04 m_model_child_bucket_size = 8
 Maximum elements per leaf node for model child trees.
Dictionary< UUID, Timem_modified_time
 Tracks the last modification time per geometry UUID.
uint04 m_point_bucket_size = 64
 Maximum elements per leaf node for point-based trees.
Buffer< PrimitivePropertym_primitive_properties
 Primitive property channels corresponding to entries in m_tree_geos.
bool m_requesting_delete = false
 Whether a deletion cleanup pass has been requested.
Buffer< Geometrym_sort_geos
 Geometries queued for vertex sorting.
Buffer< Geometrym_tree_geos
 Geometries queued for tree construction.
uint04 m_triangle_bucket_size = 16
 Maximum elements per leaf node for triangle-based trees.
Buffer< VertexPropertym_vertex_properties
 Vertex property channels corresponding to entries in m_tree_geos.

Detailed Description

Manages selection trees, which optimize the process of selecting data within large Geometry objects.


Selection trees are spatial index structures (e.g., KD-trees or bounding volume hierarchies) built over geometry vertex and primitive data to accelerate point-picking, box selection, and other spatial queries. The manager tracks which geometries need tree construction or vertex sorting, and can optionally run a background loop that rebuilds trees as geometry is modified.

Definition at line 25 of file SelectionTreeManager.h.

Member Function Documentation

◆ canSort()

bool SelectionTreeManager::canSort ( const Geometry & geo)
protected

Checks whether the given geometry is eligible for vertex sorting.

Parameters
[in]geoThe geometry to evaluate.
Returns
True if the geometry can be sorted, false otherwise.

◆ createGeoTree()

bool SelectionTreeManager::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.

Parameters
[in]geoThe geometry to build a selection tree for.
[in]primitive_propertyThe primitive property channel used for indexing (e.g., triangles, lines).
[in]vertex_propertyThe vertex property channel providing spatial coordinates.
[in]tree_bucket_sizeThe maximum number of elements per tree leaf node.
[in]lockAn opaque lock pointer used to synchronize concurrent access.
Returns
True if the tree was successfully created, false otherwise.

◆ createModelTree()

void SelectionTreeManager::createModelTree ( const Buffer< Model > & models,
const void * lock )
protected

Creates a spatial tree that indexes child models for a parent model hierarchy.

Parameters
[in]modelsThe buffer of child models to index.
[in]lockAn opaque lock pointer used to synchronize concurrent access.

◆ createTree()

void SelectionTreeManager::createTree ( const Geometry & geo,
PrimitiveProperty primitive_property,
VertexProperty vertex_property,
const void * lock )
protected

Internal method that creates a selection tree for a single geometry using stored bucket sizes.

Parameters
[in]geoThe geometry to build a tree for.
[in]primitive_propertyThe primitive property channel to index.
[in]vertex_propertyThe vertex property channel providing spatial data.
[in]lockAn opaque lock pointer used to synchronize concurrent access.
Note
Unlike createGeoTree, this method does not accept an explicit bucket size; it selects one from the internal defaults based on primitive type.

◆ createTrees() [1/2]

void SelectionTreeManager::createTrees ( const Model & model,
const void * lock )

Creates selection trees for all geometry within the given model and its children.

Parameters
[in]modelThe root model whose geometry should have trees created.
[in]lockAn opaque lock pointer used to synchronize concurrent access to geometry data.

◆ createTrees() [2/2]

void SelectionTreeManager::createTrees ( DesignObjectLookup * lookup)

Creates selection trees for all geometry within the given lookup.

Parameters
[in]lookupThe design object lookup containing models and geometry to process.

◆ onGeometryDeleted()

void SelectionTreeManager::onGeometryDeleted ( UUID id)

Handles cleanup when a geometry object is deleted, removing its associated tree data.

Parameters
[in]idThe UUID of the deleted geometry.

◆ onSceneDeleted()

void SelectionTreeManager::onSceneDeleted ( UUID id)

Handles cleanup when an entire scene is deleted, removing all associated tree data.

Parameters
[in]idThe UUID of the deleted scene.

◆ setEditTimespan()

void SelectionTreeManager::setEditTimespan ( TimeSpan span)
inline

Sets the time from a geometry edit before we create a tree.

This prevents creating trees on objects with dynamic vertices.

Parameters
[in]spanThe minimum time that must elapse after an edit before tree creation proceeds.

Definition at line 59 of file SelectionTreeManager.h.

References m_edit_timespan.

◆ sortVertices()

bool SelectionTreeManager::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.

Parameters
[in]geoThe geometry whose vertices should be sorted.
[in]primitive_propertyThe primitive property channel referencing the vertices.
[in]vertex_propertyThe vertex property channel to sort by.
[in]lockAn opaque lock pointer used to synchronize concurrent access.
Returns
True if sorting was performed, false if the geometry was not eligible or already sorted.

◆ startLoop()

void SelectionTreeManager::startLoop ( DesignObjectLookup * lookup,
const TimeSpan & loop_time )

Starts a background thread that periodically rebuilds selection trees for modified geometry.

Parameters
[in]lookupThe design object lookup providing access to all models and geometry.
[in]loop_timeThe interval between successive tree-rebuild passes.

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