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

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

#include <jet/bvh2.h>

Inheritance diagram for jet::Bvh2< T >:
jet::IntersectionQueryEngine2< T > jet::NearestNeighborQueryEngine2< T >

Public Types

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

Public Member Functions

 Bvh2 ()
 Default constructor. More...
 
void build (const std::vector< T > &items, const std::vector< BoundingBox2D > &itemsBounds)
 Builds bounding volume hierarchy. More...
 
void clear ()
 Clears all the contents of this instance. More...
 
NearestNeighborQueryResult2< T > nearest (const Vector2D &pt, const NearestNeighborDistanceFunc2< T > &distanceFunc) const override
 
bool intersects (const BoundingBox2D &box, const BoxIntersectionTestFunc2< T > &testFunc) const override
 Returns true if given box intersects with any of the stored items. More...
 
bool intersects (const Ray2D &ray, const RayIntersectionTestFunc2< T > &testFunc) const override
 Returns true if given ray intersects with any of the stored items. More...
 
void forEachIntersectingItem (const BoundingBox2D &box, const BoxIntersectionTestFunc2< T > &testFunc, const IntersectionVisitorFunc2< T > &visitorFunc) const override
 Invokes visitorFunc for every intersecting items. More...
 
void forEachIntersectingItem (const Ray2D &ray, const RayIntersectionTestFunc2< T > &testFunc, const IntersectionVisitorFunc2< T > &visitorFunc) const override
 Invokes visitorFunc for every intersecting items. More...
 
ClosestIntersectionQueryResult2< T > closestIntersection (const Ray2D &ray, const GetRayIntersectionFunc2< T > &testFunc) const override
 Returns the closest intersection for given ray. More...
 
const BoundingBox2DboundingBox () 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 BoundingBox2DnodeBound (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::Bvh2< T >

Bounding Volume Hierarchy (BVH) in 2D.

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

Member Typedef Documentation

◆ ConstIterator

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

◆ ContainerType

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

◆ Iterator

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

Constructor & Destructor Documentation

◆ Bvh2()

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

Default constructor.

Member Function Documentation

◆ begin() [1/2]

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

Returns the begin iterator of the item.

◆ begin() [2/2]

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

Returns the immutable begin iterator of the item.

◆ boundingBox()

template<typename T >
const BoundingBox2D& jet::Bvh2< T >::boundingBox ( ) const

Returns bounding box of every items.

◆ build()

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

Builds bounding volume hierarchy.

◆ children()

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

Returns the children indices of i-th node.

◆ clear()

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

Clears all the contents of this instance.

◆ closestIntersection()

template<typename T >
ClosestIntersectionQueryResult2<T> jet::Bvh2< T >::closestIntersection ( const Ray2D ray,
const GetRayIntersectionFunc2< T > &  testFunc 
) const
overridevirtual

Returns the closest intersection for given ray.

Implements jet::IntersectionQueryEngine2< T >.

◆ end() [1/2]

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

Returns the end iterator of the item.

◆ end() [2/2]

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

Returns the immutable end iterator of the item.

◆ forEachIntersectingItem() [1/2]

template<typename T >
void jet::Bvh2< T >::forEachIntersectingItem ( const BoundingBox2D box,
const BoxIntersectionTestFunc2< T > &  testFunc,
const IntersectionVisitorFunc2< T > &  visitorFunc 
) const
overridevirtual

Invokes visitorFunc for every intersecting items.

Implements jet::IntersectionQueryEngine2< T >.

◆ forEachIntersectingItem() [2/2]

template<typename T >
void jet::Bvh2< T >::forEachIntersectingItem ( const Ray2D ray,
const RayIntersectionTestFunc2< T > &  testFunc,
const IntersectionVisitorFunc2< T > &  visitorFunc 
) const
overridevirtual

Invokes visitorFunc for every intersecting items.

Implements jet::IntersectionQueryEngine2< T >.

◆ intersects() [1/2]

template<typename T >
bool jet::Bvh2< T >::intersects ( const BoundingBox2D box,
const BoxIntersectionTestFunc2< T > &  testFunc 
) const
overridevirtual

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

Implements jet::IntersectionQueryEngine2< T >.

◆ intersects() [2/2]

template<typename T >
bool jet::Bvh2< T >::intersects ( const Ray2D ray,
const RayIntersectionTestFunc2< T > &  testFunc 
) const
overridevirtual

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

Implements jet::IntersectionQueryEngine2< T >.

◆ isLeaf()

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

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

◆ item()

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

Returns the item at i.

◆ itemOfNode() [1/2]

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

Returns item of i-th node.

◆ itemOfNode() [2/2]

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

Returns item of i-th node.

◆ nearest()

template<typename T >
NearestNeighborQueryResult2<T> jet::Bvh2< T >::nearest ( const Vector2D pt,
const NearestNeighborDistanceFunc2< T > &  distanceFunc 
) const
overridevirtual

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

Implements jet::NearestNeighborQueryEngine2< T >.

◆ nodeBound()

template<typename T >
const BoundingBox2D& jet::Bvh2< T >::nodeBound ( size_t  i) const

Returns bounding box of i-th node.

◆ numberOfItems()

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

Returns the number of items.

◆ numberOfNodes()

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

Returns the number of nodes.


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