CubbyFlow::Octree< T > Class Template Referencefinal

Generic octree data structure. More...

#include <Core/Geometry/Octree.hpp>

Inheritance diagram for CubbyFlow::Octree< T >:
CubbyFlow::IntersectionQueryEngine< T, N > CubbyFlow::NearestNeighborQueryEngine< T, N >

Public Types

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

Public Member Functions

 Octree ()=default
 Default constructor. More...
 
 Octree (const Octree &)=default
 Default copy constructor. More...
 
 Octree (Octree &&) noexcept=default
 Default move constructor. More...
 
virtual ~Octree ()=default
 Default virtual destructor. More...
 
Octreeoperator= (const Octree &)=default
 Default copy assignment operator. More...
 
Octreeoperator= (Octree &&) noexcept=default
 Default move assignment operator. 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 > Nearest (const Vector3D &pt, const NearestNeighborDistanceFunc3< T > &distanceFunc) const override
 
bool Intersects (const BoundingBox3D &box, const BoxIntersectionTestFunc3< T > &testFunc) const override
 Returns true if given box intersects with any of the stored items. More...
 
bool Intersects (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 IntersectionVisitorFunc< T > &visitorFunc) const override
 Invokes visitorFunc for every intersecting items. More...
 
void ForEachIntersectingItem (const Ray3D &ray, const RayIntersectionTestFunc3< T > &testFunc, const IntersectionVisitorFunc< T > &visitorFunc) const override
 Invokes visitorFunc for every intersecting items. More...
 
ClosestIntersectionQueryResult3< T > ClosestIntersection (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...
 
- Public Member Functions inherited from CubbyFlow::IntersectionQueryEngine< T, N >
 IntersectionQueryEngine ()=default
 Default constructor. More...
 
virtual ~IntersectionQueryEngine ()=default
 Default virtual destructor. More...
 
 IntersectionQueryEngine (const IntersectionQueryEngine &other)=default
 Default copy constructor. More...
 
 IntersectionQueryEngine (IntersectionQueryEngine &&other) noexcept=default
 Default move constructor. More...
 
IntersectionQueryEngineoperator= (const IntersectionQueryEngine &other)=default
 Default copy assignment operator. More...
 
IntersectionQueryEngineoperator= (IntersectionQueryEngine &&other) noexcept=default
 Default move assignment operator. More...
 
virtual bool Intersects (const BoundingBox< double, N > &box, const BoxIntersectionTestFunc< T, N > &testFunc) const =0
 Returns true if given box intersects with any of the stored items. More...
 
virtual bool Intersects (const Ray< double, N > &ray, const RayIntersectionTestFunc< T, N > &testFunc) const =0
 Returns true if given ray intersects with any of the stored items. More...
 
virtual void ForEachIntersectingItem (const BoundingBox< double, N > &box, const BoxIntersectionTestFunc< T, N > &testFunc, const IntersectionVisitorFunc< T > &visitorFunc) const =0
 Invokes visitorFunc for every intersecting items. More...
 
virtual void ForEachIntersectingItem (const Ray< double, N > &ray, const RayIntersectionTestFunc< T, N > &testFunc, const IntersectionVisitorFunc< T > &visitorFunc) const =0
 Invokes visitorFunc for every intersecting items. More...
 
virtual ClosestIntersectionQueryResult< T, N > ClosestIntersection (const Ray< double, N > &ray, const GetRayIntersectionFunc< T, N > &testFunc) const =0
 Returns the closest intersection for given ray. More...
 
- Public Member Functions inherited from CubbyFlow::NearestNeighborQueryEngine< T, N >
 NearestNeighborQueryEngine ()=default
 Default constructor. More...
 
virtual ~NearestNeighborQueryEngine ()=default
 Default virtual destructor. More...
 
 NearestNeighborQueryEngine (const NearestNeighborQueryEngine &other)=default
 Default copy constructor. More...
 
 NearestNeighborQueryEngine (NearestNeighborQueryEngine &&other) noexcept=default
 Default move constructor. More...
 
NearestNeighborQueryEngineoperator= (const NearestNeighborQueryEngine &other)=default
 Default copy assignment operator. More...
 
NearestNeighborQueryEngineoperator= (NearestNeighborQueryEngine &&other) noexcept=default
 Default move assignment operator. More...
 
virtual NearestNeighborQueryResult< T, N > Nearest (const Vector< double, N > &pt, const NearestNeighborDistanceFunc< T, N > &distanceFunc) const =0
 

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() [1/3]

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

Default constructor.

◆ Octree() [2/3]

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

Default copy constructor.

◆ Octree() [3/3]

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

Default move constructor.

◆ ~Octree()

template<typename T>
virtual CubbyFlow::Octree< T >::~Octree ( )
virtualdefault

Default virtual destructor.

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.

◆ ClosestIntersection()

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

Returns the closest intersection for given ray.

◆ 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 IntersectionVisitorFunc< T > &  visitorFunc 
) const
override

Invokes visitorFunc for every intersecting items.

◆ ForEachIntersectingItem() [2/2]

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

Invokes visitorFunc for every intersecting items.

◆ 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.

◆ 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.

◆ 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.

◆ Intersects() [1/2]

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

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

◆ Intersects() [2/2]

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

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

◆ Nearest()

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

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

◆ operator=() [1/2]

template<typename T>
Octree& CubbyFlow::Octree< T >::operator= ( const Octree< T > &  )
default

Default copy assignment operator.

◆ operator=() [2/2]

template<typename T>
Octree& CubbyFlow::Octree< T >::operator= ( Octree< T > &&  )
defaultnoexcept

Default move assignment operator.


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