Workspace 6.21.5
Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
LinearSpatialPartitioningTree Class Reference

A Linear spatial partitioning tree is a quadtree or octree compressed into a single contiguous array. More...

#include <Rendering/SceneComponents/linearspatialpartitioningtree.h>

Classes

class  Cell
 Describes an octree cell's location and physical geometry. More...
 
class  MaxDepthExceededException
 Thrown if the algorithm attempts to build a tree deeper than the maximum possible depth. More...
 
class  TerminateExecutionRequestedException
 Thrown whenever the caller wishes to terminate traversal due to user intervention. More...
 

Public Types

using CellList = std::vector< Cell >
 
using CellListPtr = QSharedPointer< CellList >
 
using const_pointer = const value_type *
 
using const_reference = const value_type &
 
using difference_type = ptrdiff_t
 
typedef quint64 LocationDescriptor
 The LocationDescriptor is a complete address to a cell from the root.
 
using pointer = value_type *
 
enum  QuadtreePlane { XY , XZ , YZ }
 Defines the orientation of the quadtree, if the tree is layed out as a quadtree. More...
 
using reference = value_type &
 
using size_type = size_t
 
enum  TreeLayout { Quadtree , Octree }
 Defines the layout of the partitioning tree: a quadtree, where every cell splits into 4, or an octree, where each tree splits into 8. More...
 
using value_type = Point
 

Public Member Functions

 LinearSpatialPartitioningTree (TreeLayout layout, Mesh::MeshNodesInterface &nodes, unsigned patchDepth, QuadtreePlane plane=XY)
 
LinearSpatialPartitioningTree::iterator begin ()
 
LinearSpatialPartitioningTree::const_iterator begin () const
 
LinearSpatialPartitioningTree::iterator end ()
 
LinearSpatialPartitioningTree::const_iterator end () const
 
size_type getDiminishingReturnsThreshold () const
 
quint8 getMaxDepth () const
 
Mesh::MeshNodesInterfacegetNodes ()
 
const Mesh::MeshNodesInterfacegetNodes () const
 
quint32 getNumCellsPerLevel () const
 
Point & operator[] (size_type i)
 
const Point & operator[] (size_type i) const
 
quint8 traverse (const std::function< Cell::VisitAction(const Cell &)> &preCellVisit, const std::function< void(const Cell &)> &postCellVisit, const Mesh::BoundingBox &cloudBounds, unsigned maxDepth)
 

Static Public Member Functions

static quint8 getMaxDepth (LinearSpatialPartitioningTree::TreeLayout layout)
 

Static Public Attributes

static constexpr const quint64 NumLocationBits = sizeof(LocationDescriptor) * 8
 

Detailed Description

Each item in the array is a point, and the points are sorted by their location descriptor, which describes the location of the cell in which the point is contained.

We allow the tree to define the number of bits that it's going to use. The location descriptor is a single unsigned value where every 2 or 3 bits corresponds to a single cell identifier at a specific depth, for example, the cell location at the root level is defined in the first three bits of an octree:

000 = back lower left 001 = back lower right 010 = back upper left 011 = back upper right 100 = front lower left 101 = front lower right 110 = front upper left 111 = front upper right

or the first two bits of a quadtree:

00 = lower left 01 = lower right 10 = upper left 11 = upper right

The next three bits contain the cell location at the next depth and so on. When the octree array is properly sorted, enough information is encoded in each point's location descriptor to to allow all the points within a given cell to be looked up using a simple binary search.

Member Typedef Documentation

◆ CellList

using CellList = std::vector<Cell>

◆ CellListPtr

using CellListPtr = QSharedPointer<CellList>

◆ const_pointer

using const_pointer = const value_type*

◆ const_reference

using const_reference = const value_type&

◆ difference_type

using difference_type = ptrdiff_t

◆ LocationDescriptor

typedef quint64 LocationDescriptor

◆ pointer

using pointer = value_type*

◆ reference

◆ size_type

using size_type = size_t

◆ value_type

using value_type = Point

Member Enumeration Documentation

◆ QuadtreePlane

Enumerator
XY 
XZ 
YZ 

◆ TreeLayout

enum TreeLayout
Enumerator
Quadtree 
Octree 

Constructor & Destructor Documentation

◆ LinearSpatialPartitioningTree()

LinearSpatialPartitioningTree ( TreeLayout  layout,
Mesh::MeshNodesInterface nodes,
unsigned  patchDepth,
QuadtreePlane  plane = XY 
)

Member Function Documentation

◆ begin() [1/2]

LinearSpatialPartitioningTree::iterator begin ( )
inline

◆ begin() [2/2]

LinearSpatialPartitioningTree::const_iterator begin ( ) const
inline

◆ end() [1/2]

LinearSpatialPartitioningTree::iterator end ( )
inline

◆ end() [2/2]

LinearSpatialPartitioningTree::const_iterator end ( ) const
inline

◆ getDiminishingReturnsThreshold()

LinearSpatialPartitioningTree::size_type getDiminishingReturnsThreshold ( ) const
Returns
The minimum number of points in a cell before it is considered a leaf.

◆ getMaxDepth() [1/2]

quint8 getMaxDepth ( ) const

◆ getMaxDepth() [2/2]

quint8 getMaxDepth ( LinearSpatialPartitioningTree::TreeLayout  layout)
static

◆ getNodes() [1/2]

Mesh::MeshNodesInterface & getNodes ( )
Returns
the set of nodes associated with this octree.

◆ getNodes() [2/2]

const Mesh::MeshNodesInterface & getNodes ( ) const
Returns
the set of nodes associated with this octree.

◆ getNumCellsPerLevel()

quint32 getNumCellsPerLevel ( ) const

◆ operator[]() [1/2]

Point & operator[] ( size_type  i)
inline

◆ operator[]() [2/2]

const Point & operator[] ( size_type  i) const
inline

◆ traverse()

quint8 traverse ( const std::function< Cell::VisitAction(const Cell &)> &  preCellVisit,
const std::function< void(const Cell &)> &  postCellVisit,
const Mesh::BoundingBox cloudBounds,
unsigned  maxDepth 
)
Parameters
preCellVisitFunction to invoke immediately prior to visiting a cell
postCellVisitFunction to invoke immediately after visiting a cell
cloudBoundsThe bounding box of the point cloud
maxDepthThe maximum depth to which we should traverse

Invoke this method to traverse the octree invoking the specified pre and post visit functions. Traversal is breadth first in order to ensure we can compute LOD data on-the-fly (i.e. only once one entire level of the tree is constructed can we proceed to the next level down).

Returns
the depth of the tree.

Member Data Documentation

◆ NumLocationBits

constexpr const quint64 NumLocationBits = sizeof(LocationDescriptor) * 8
staticconstexpr