Jet  v1.3.3
Classes | Public Types | Public Member Functions | List of all members
jet::Bvh3< T > Class Template Referencefinal

Bounding Volume Hierarchy (BVH) in 3D. More...

#include <jet/bvh3.h>

Inheritance diagram for jet::Bvh3< T >:
jet::IntersectionQueryEngine3< T > jet::NearestNeighborQueryEngine3< T >

Public Types

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

Public Member Functions

 Bvh3 ()
 Default constructor. More...
 
void build (const std::vector< T > &items, const std::vector< BoundingBox3D > &itemsBounds)
 Builds bounding volume hierarchy. More...
 
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 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 > closestIntersection (const Ray3D &ray, const GetRayIntersectionFunc3< T > &testFunc) const override
 Returns the closest intersection for given ray. More...
 
const BoundingBox3DboundingBox () 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 BoundingBox3DnodeBound (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...
 

Detailed Description

template<typename T>
class jet::Bvh3< T >

Bounding Volume Hierarchy (BVH) in 3D.

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

Member Typedef Documentation

◆ ConstIterator

template<typename T >
using jet::Bvh3< T >::ConstIterator = typename ContainerType::const_iterator

◆ ContainerType

template<typename T >
using jet::Bvh3< T >::ContainerType = std::vector<T>

◆ Iterator

template<typename T >
using jet::Bvh3< T >::Iterator = typename ContainerType::iterator

Constructor & Destructor Documentation

◆ Bvh3()

template<typename T >
jet::Bvh3< T >::Bvh3 ( )

Default constructor.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
Iterator jet::Bvh3< T >::begin ( )

Returns the begin iterator of the item.

◆ begin() [2/2]

template<typename T >
ConstIterator jet::Bvh3< T >::begin ( ) const

Returns the immutable begin iterator of the item.

◆ boundingBox()

template<typename T >
const BoundingBox3D& jet::Bvh3< T >::boundingBox ( ) const

Returns bounding box of every items.

◆ build()

template<typename T >
void jet::Bvh3< T >::build ( const std::vector< T > &  items,
const std::vector< BoundingBox3D > &  itemsBounds 
)

Builds bounding volume hierarchy.

◆ children()

template<typename T >
std::pair<size_t, size_t> jet::Bvh3< T >::children ( size_t  i) const

Returns the children indices of i-th node.

◆ clear()

template<typename T >
void jet::Bvh3< T >::clear ( )

Clears all the contents of this instance.

◆ closestIntersection()

template<typename T >
ClosestIntersectionQueryResult3<T> jet::Bvh3< T >::closestIntersection ( const Ray3D ray,
const GetRayIntersectionFunc3< T > &  testFunc 
) const
overridevirtual

Returns the closest intersection for given ray.

Implements jet::IntersectionQueryEngine3< T >.

◆ end() [1/2]

template<typename T >
Iterator jet::Bvh3< T >::end ( )

Returns the end iterator of the item.

◆ end() [2/2]

template<typename T >
ConstIterator jet::Bvh3< T >::end ( ) const

Returns the immutable end iterator of the item.

◆ forEachIntersectingItem() [1/2]

template<typename T >
void jet::Bvh3< T >::forEachIntersectingItem ( const BoundingBox3D box,
const BoxIntersectionTestFunc3< T > &  testFunc,
const IntersectionVisitorFunc3< T > &  visitorFunc 
) const
overridevirtual

Invokes visitorFunc for every intersecting items.

Implements jet::IntersectionQueryEngine3< T >.

◆ forEachIntersectingItem() [2/2]

template<typename T >
void jet::Bvh3< T >::forEachIntersectingItem ( const Ray3D ray,
const RayIntersectionTestFunc3< T > &  testFunc,
const IntersectionVisitorFunc3< T > &  visitorFunc 
) const
overridevirtual

Invokes visitorFunc for every intersecting items.

Implements jet::IntersectionQueryEngine3< T >.

◆ intersects() [1/2]

template<typename T >
bool jet::Bvh3< T >::intersects ( const BoundingBox3D box,
const BoxIntersectionTestFunc3< T > &  testFunc 
) const
overridevirtual

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

Implements jet::IntersectionQueryEngine3< T >.

◆ intersects() [2/2]

template<typename T >
bool jet::Bvh3< T >::intersects ( const Ray3D ray,
const RayIntersectionTestFunc3< T > &  testFunc 
) const
overridevirtual

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

Implements jet::IntersectionQueryEngine3< T >.

◆ isLeaf()

template<typename T >
bool jet::Bvh3< T >::isLeaf ( size_t  i) const

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

◆ item()

template<typename T >
const T& jet::Bvh3< T >::item ( size_t  i) const

Returns the item at i.

◆ itemOfNode() [1/2]

template<typename T >
Iterator jet::Bvh3< T >::itemOfNode ( size_t  i)

Returns item of i-th node.

◆ itemOfNode() [2/2]

template<typename T >
ConstIterator jet::Bvh3< T >::itemOfNode ( size_t  i) const

Returns item of i-th node.

◆ nearest()

template<typename T >
NearestNeighborQueryResult3<T> jet::Bvh3< T >::nearest ( const Vector3D pt,
const NearestNeighborDistanceFunc3< T > &  distanceFunc 
) const
overridevirtual

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

Implements jet::NearestNeighborQueryEngine3< T >.

◆ nodeBound()

template<typename T >
const BoundingBox3D& jet::Bvh3< T >::nodeBound ( size_t  i) const

Returns bounding box of i-th node.

◆ numberOfItems()

template<typename T >
size_t jet::Bvh3< T >::numberOfItems ( ) const

Returns the number of items.

◆ numberOfNodes()

template<typename T >
size_t jet::Bvh3< T >::numberOfNodes ( ) const

Returns the number of nodes.


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