CubbyFlow::BVH< T, N > Class Template Referencefinal

Bounding Volume Hierarchy (BVH) in N-D. More...

#include <Core/Geometry/BVH.hpp>

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

Public Types

using ContainerType = Array1< T >
 
using Iterator = typename ContainerType::Iterator
 
using ConstIterator = typename ContainerType::ConstIterator
 

Public Member Functions

void Build (const ConstArrayView1< T > &items, const ConstArrayView1< BoundingBox< double, N >> &itemsBounds)
 Builds bounding volume hierarchy. More...
 
void Clear ()
 Clears all the contents of this instance. More...
 
NearestNeighborQueryResult< T, N > Nearest (const Vector< double, N > &pt, const NearestNeighborDistanceFunc< T, N > &distanceFunc) const override
 
bool Intersects (const BoundingBox< double, N > &box, const BoxIntersectionTestFunc< T, N > &testFunc) const override
 Returns true if given box intersects with any of the stored items. More...
 
bool Intersects (const Ray< double, N > &ray, const RayIntersectionTestFunc< T, N > &testFunc) const override
 Returns true if given ray intersects with any of the stored items. More...
 
void ForEachIntersectingItem (const BoundingBox< double, N > &box, const BoxIntersectionTestFunc< T, N > &testFunc, const IntersectionVisitorFunc< T > &visitorFunc) const override
 Invokes visitorFunc for every intersecting items. More...
 
void ForEachIntersectingItem (const Ray< double, N > &ray, const RayIntersectionTestFunc< T, N > &testFunc, const IntersectionVisitorFunc< T > &visitorFunc) const override
 Invokes visitorFunc for every intersecting items. More...
 
ClosestIntersectionQueryResult< T, N > ClosestIntersection (const Ray< double, N > &ray, const GetRayIntersectionFunc< T, N > &testFunc) const override
 Returns the closest intersection for given ray. More...
 
const BoundingBox< double, N > & GetBoundingBox () const
 Returns bounding box of every items. 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 NumberOfItems () const
 Returns the number of items. More...
 
const T & Item (size_t i) const
 Returns the item at i. More...
 
size_t NumberOfNodes () const
 Returns the number of nodes. More...
 
std::pair< size_t, size_t > Children (size_t i) const
 Returns the children indices of i-th node. More...
 
bool IsLeaf (size_t i) const
 Returns true if i-th node is a leaf node. More...
 
const BoundingBox< double, N > & NodeBound (size_t i) const
 Returns bounding box of i-th node. More...
 
Iterator ItemOfNode (size_t i)
 Returns item of i-th node. More...
 
ConstIterator ItemOfNode (size_t i) const
 Returns item of i-th node. 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...
 
- 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...
 

Detailed Description

template<typename T, size_t N>
class CubbyFlow::BVH< T, N >

Bounding Volume Hierarchy (BVH) in N-D.

This class implements the classic bounding volume hierarchy structure in N-D. It implements IntersectionQueryEngine in order to support box/ray intersection tests. Also, NearestNeighborQueryEngine is implemented to provide nearest neighbor query.

Member Typedef Documentation

◆ ConstIterator

template<typename T, size_t N>
using CubbyFlow::BVH< T, N >::ConstIterator = typename ContainerType::ConstIterator

◆ ContainerType

template<typename T, size_t N>
using CubbyFlow::BVH< T, N >::ContainerType = Array1<T>

◆ Iterator

template<typename T, size_t N>
using CubbyFlow::BVH< T, N >::Iterator = typename ContainerType::Iterator

Member Function Documentation

◆ begin() [1/2]

template<typename T , size_t N>
BVH< T, N >::Iterator CubbyFlow::BVH< T, N >::begin ( )

Returns the begin Iterator of the item.

◆ begin() [2/2]

template<typename T , size_t N>
BVH< T, N >::ConstIterator CubbyFlow::BVH< T, N >::begin ( ) const

Returns the immutable begin Iterator of the item.

◆ Build()

template<typename T, size_t N>
void CubbyFlow::BVH< T, N >::Build ( const ConstArrayView1< T > &  items,
const ConstArrayView1< BoundingBox< double, N >> &  itemsBounds 
)

Builds bounding volume hierarchy.

◆ Children()

template<typename T , size_t N>
std::pair< size_t, size_t > CubbyFlow::BVH< T, N >::Children ( size_t  i) const

Returns the children indices of i-th node.

◆ Clear()

template<typename T , size_t N>
void CubbyFlow::BVH< T, N >::Clear ( )

Clears all the contents of this instance.

◆ ClosestIntersection()

template<typename T, size_t N>
ClosestIntersectionQueryResult< T, N > CubbyFlow::BVH< T, N >::ClosestIntersection ( const Ray< double, N > &  ray,
const GetRayIntersectionFunc< T, N > &  testFunc 
) const
overridevirtual

Returns the closest intersection for given ray.

Implements CubbyFlow::IntersectionQueryEngine< T, N >.

◆ end() [1/2]

template<typename T , size_t N>
BVH< T, N >::Iterator CubbyFlow::BVH< T, N >::end ( )

Returns the end Iterator of the item.

◆ end() [2/2]

template<typename T , size_t N>
BVH< T, N >::ConstIterator CubbyFlow::BVH< T, N >::end ( ) const

Returns the immutable end Iterator of the item.

◆ ForEachIntersectingItem() [1/2]

template<typename T, size_t N>
void CubbyFlow::BVH< T, N >::ForEachIntersectingItem ( const BoundingBox< double, N > &  box,
const BoxIntersectionTestFunc< T, N > &  testFunc,
const IntersectionVisitorFunc< T > &  visitorFunc 
) const
overridevirtual

Invokes visitorFunc for every intersecting items.

Implements CubbyFlow::IntersectionQueryEngine< T, N >.

◆ ForEachIntersectingItem() [2/2]

template<typename T, size_t N>
void CubbyFlow::BVH< T, N >::ForEachIntersectingItem ( const Ray< double, N > &  ray,
const RayIntersectionTestFunc< T, N > &  testFunc,
const IntersectionVisitorFunc< T > &  visitorFunc 
) const
overridevirtual

Invokes visitorFunc for every intersecting items.

Implements CubbyFlow::IntersectionQueryEngine< T, N >.

◆ GetBoundingBox()

template<typename T , size_t N>
const BoundingBox< double, N > & CubbyFlow::BVH< T, N >::GetBoundingBox ( ) const

Returns bounding box of every items.

◆ Intersects() [1/2]

template<typename T, size_t N>
bool CubbyFlow::BVH< T, N >::Intersects ( const BoundingBox< double, N > &  box,
const BoxIntersectionTestFunc< T, N > &  testFunc 
) const
overridevirtual

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

Implements CubbyFlow::IntersectionQueryEngine< T, N >.

◆ Intersects() [2/2]

template<typename T, size_t N>
bool CubbyFlow::BVH< T, N >::Intersects ( const Ray< double, N > &  ray,
const RayIntersectionTestFunc< T, N > &  testFunc 
) const
overridevirtual

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

Implements CubbyFlow::IntersectionQueryEngine< T, N >.

◆ IsLeaf()

template<typename T , size_t N>
bool CubbyFlow::BVH< T, N >::IsLeaf ( size_t  i) const

Returns true if i-th node is a leaf node.

◆ Item()

template<typename T , size_t N>
const T & CubbyFlow::BVH< T, N >::Item ( size_t  i) const

Returns the item at i.

◆ ItemOfNode() [1/2]

template<typename T , size_t N>
BVH< T, N >::Iterator CubbyFlow::BVH< T, N >::ItemOfNode ( size_t  i)

Returns item of i-th node.

◆ ItemOfNode() [2/2]

template<typename T , size_t N>
BVH< T, N >::ConstIterator CubbyFlow::BVH< T, N >::ItemOfNode ( size_t  i) const

Returns item of i-th node.

◆ Nearest()

template<typename T, size_t N>
NearestNeighborQueryResult< T, N > CubbyFlow::BVH< T, N >::Nearest ( const Vector< double, N > &  pt,
const NearestNeighborDistanceFunc< T, N > &  distanceFunc 
) const
inlineoverridevirtual

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

Implements CubbyFlow::NearestNeighborQueryEngine< T, N >.

◆ NodeBound()

template<typename T , size_t N>
const BoundingBox< double, N > & CubbyFlow::BVH< T, N >::NodeBound ( size_t  i) const

Returns bounding box of i-th node.

◆ NumberOfItems()

template<typename T , size_t N>
size_t CubbyFlow::BVH< T, N >::NumberOfItems ( ) const

Returns the number of items.

◆ NumberOfNodes()

template<typename T , size_t N>
size_t CubbyFlow::BVH< T, N >::NumberOfNodes ( ) const

Returns the number of nodes.


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