CubbyFlow::Octree< T > Class Template Referencefinal

Generic octree data structure. More...

#include <Core/Geometry/Octree.h>

Inheritance diagram for CubbyFlow::Octree< T >:
CubbyFlow::IntersectionQueryEngine3< T > CubbyFlow::NearestNeighborQueryEngine3< T >

Public Types

using ContainerType = std::vector< T >
 
using Iterator = typename ContainerType::iterator
 
using ConstIterator = typename ContainerType::const_iterator
 

Public Member Functions

 Octree ()
 Default constructor. More...
 
void Build (const std::vector< T > &items, const BoundingBox3D &bound, const BoxIntersectionTestFunc3< T > &testFunc, size_t maxDepth)
 
void Clear ()
 Clears all the contents of this instance. More...
 
NearestNeighborQueryResult3< T > GetNearestNeighbor (const Vector3D &pt, const NearestNeighborDistanceFunc3< T > &distanceFunc) const override
 
bool IsIntersects (const BoundingBox3D &box, const BoxIntersectionTestFunc3< T > &testFunc) const override
 Returns true if given box intersects with any of the stored items. More...
 
bool IsIntersects (const Ray3D &ray, const RayIntersectionTestFunc3< T > &testFunc) const override
 Returns true if given ray intersects with any of the stored items. More...
 
void ForEachIntersectingItem (const BoundingBox3D &box, const BoxIntersectionTestFunc3< T > &testFunc, const IntersectionVisitorFunc3< T > &visitorFunc) const override
 Invokes visitorFunc for every intersecting items. More...
 
void ForEachIntersectingItem (const Ray3D &ray, const RayIntersectionTestFunc3< T > &testFunc, const IntersectionVisitorFunc3< T > &visitorFunc) const override
 Invokes visitorFunc for every intersecting items. More...
 
ClosestIntersectionQueryResult3< T > GetClosestIntersection (const Ray3D &ray, const GetRayIntersectionFunc3< T > &testFunc) const override
 Returns the closest intersection for given ray. More...
 
Iterator begin ()
 Returns the begin iterator of the item. More...
 
Iterator end ()
 Returns the end iterator of the item. More...
 
ConstIterator begin () const
 Returns the immutable begin iterator of the item. More...
 
ConstIterator end () const
 Returns the immutable end iterator of the item. More...
 
size_t GetNumberOfItems () const
 Returns the number of items. More...
 
const T & GetItem (size_t i) const
 Returns the item at i. More...
 
size_t GetNumberOfNodes () const
 Returns the number of octree nodes. More...
 
const std::vector< size_t > & GetItemsAtNode (size_t nodeIdx) const
 Returns the list of the items for given node index. More...
 
size_t GetChildIndex (size_t nodeIdx, size_t childIdx) const
 Returns a child's index for given node. More...
 
const BoundingBox3DGetBoundingBox () const
 Returns the bounding box of this octree. More...
 
size_t GetMaxDepth () const
 Returns the maximum depth of the tree. More...
 

Detailed Description

template<typename T>
class CubbyFlow::Octree< T >

Generic octree data structure.

This class is a generic octree representation to store arbitrary spatial data. The octree supports closest neighbor search, overlapping test, and ray intersection test.

Template Parameters
TValue type.

Member Typedef Documentation

◆ ConstIterator

template<typename T>
using CubbyFlow::Octree< T >::ConstIterator = typename ContainerType::const_iterator

◆ ContainerType

template<typename T>
using CubbyFlow::Octree< T >::ContainerType = std::vector<T>

◆ Iterator

template<typename T>
using CubbyFlow::Octree< T >::Iterator = typename ContainerType::iterator

Constructor & Destructor Documentation

◆ Octree()

template<typename T >
CubbyFlow::Octree< T >::Octree ( )

Default constructor.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
Octree< T >::Iterator CubbyFlow::Octree< T >::begin ( )

Returns the begin iterator of the item.

◆ begin() [2/2]

template<typename T >
Octree< T >::ConstIterator CubbyFlow::Octree< T >::begin ( ) const

Returns the immutable begin iterator of the item.

◆ Build()

template<typename T >
void CubbyFlow::Octree< T >::Build ( const std::vector< T > &  items,
const BoundingBox3D bound,
const BoxIntersectionTestFunc3< T > &  testFunc,
size_t  maxDepth 
)

Builds an octree with given list of items, bounding box of the items, overlapping test function, and max depth of the tree.

◆ Clear()

template<typename T >
void CubbyFlow::Octree< T >::Clear ( )

Clears all the contents of this instance.

◆ end() [1/2]

template<typename T >
Octree< T >::Iterator CubbyFlow::Octree< T >::end ( )

Returns the end iterator of the item.

◆ end() [2/2]

template<typename T >
Octree< T >::ConstIterator CubbyFlow::Octree< T >::end ( ) const

Returns the immutable end iterator of the item.

◆ ForEachIntersectingItem() [1/2]

template<typename T >
void CubbyFlow::Octree< T >::ForEachIntersectingItem ( const BoundingBox3D box,
const BoxIntersectionTestFunc3< T > &  testFunc,
const IntersectionVisitorFunc3< T > &  visitorFunc 
) const
overridevirtual

Invokes visitorFunc for every intersecting items.

Implements CubbyFlow::IntersectionQueryEngine3< T >.

◆ ForEachIntersectingItem() [2/2]

template<typename T >
void CubbyFlow::Octree< T >::ForEachIntersectingItem ( const Ray3D ray,
const RayIntersectionTestFunc3< T > &  testFunc,
const IntersectionVisitorFunc3< T > &  visitorFunc 
) const
overridevirtual

Invokes visitorFunc for every intersecting items.

Implements CubbyFlow::IntersectionQueryEngine3< T >.

◆ GetBoundingBox()

template<typename T >
const BoundingBox3D & CubbyFlow::Octree< T >::GetBoundingBox ( ) const

Returns the bounding box of this octree.

◆ GetChildIndex()

template<typename T >
size_t CubbyFlow::Octree< T >::GetChildIndex ( size_t  nodeIdx,
size_t  childIdx 
) const

Returns a child's index for given node.

For a given node, its children is stored continuously, such that if the node's first child's index is i, then i + 1, i + 2, ... , i + 7 are the indices for its children. The order of octant is x-major.

Parameters
[in]nodeIdxThe node index.
[in]childIdxThe child index (0 to 7).
Returns
Index of the selected child.

◆ GetClosestIntersection()

template<typename T >
ClosestIntersectionQueryResult3< T > CubbyFlow::Octree< T >::GetClosestIntersection ( const Ray3D ray,
const GetRayIntersectionFunc3< T > &  testFunc 
) const
overridevirtual

Returns the closest intersection for given ray.

Implements CubbyFlow::IntersectionQueryEngine3< T >.

◆ GetItem()

template<typename T >
const T & CubbyFlow::Octree< T >::GetItem ( size_t  i) const

Returns the item at i.

◆ GetItemsAtNode()

template<typename T >
const std::vector< size_t > & CubbyFlow::Octree< T >::GetItemsAtNode ( size_t  nodeIdx) const

Returns the list of the items for given node index.

◆ GetMaxDepth()

template<typename T >
size_t CubbyFlow::Octree< T >::GetMaxDepth ( ) const

Returns the maximum depth of the tree.

◆ GetNearestNeighbor()

template<typename T >
NearestNeighborQueryResult3< T > CubbyFlow::Octree< T >::GetNearestNeighbor ( const Vector3D pt,
const NearestNeighborDistanceFunc3< T > &  distanceFunc 
) const
overridevirtual

Returns the nearest neighbor for given point and distance measure function.

Implements CubbyFlow::NearestNeighborQueryEngine3< T >.

◆ GetNumberOfItems()

template<typename T >
size_t CubbyFlow::Octree< T >::GetNumberOfItems ( ) const

Returns the number of items.

◆ GetNumberOfNodes()

template<typename T >
size_t CubbyFlow::Octree< T >::GetNumberOfNodes ( ) const

Returns the number of octree nodes.

◆ IsIntersects() [1/2]

template<typename T >
bool CubbyFlow::Octree< T >::IsIntersects ( const BoundingBox3D box,
const BoxIntersectionTestFunc3< T > &  testFunc 
) const
overridevirtual

Returns true if given box intersects with any of the stored items.

Implements CubbyFlow::IntersectionQueryEngine3< T >.

◆ IsIntersects() [2/2]

template<typename T >
bool CubbyFlow::Octree< T >::IsIntersects ( const Ray3D ray,
const RayIntersectionTestFunc3< T > &  testFunc 
) const
overridevirtual

Returns true if given ray intersects with any of the stored items.

Implements CubbyFlow::IntersectionQueryEngine3< T >.


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