CubbyFlow::BVH2< T > Class Template Referencefinal

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

#include <Core/Geometry/BVH2.h>

Inheritance diagram for CubbyFlow::BVH2< T >:
CubbyFlow::IntersectionQueryEngine2< T > CubbyFlow::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 > GetNearestNeighbor (const Vector2D &pt, const NearestNeighborDistanceFunc2< T > &distanceFunc) const override
 
bool IsIntersects (const BoundingBox2D &box, const BoxIntersectionTestFunc2< T > &testFunc) const override
 Returns true if given box intersects with any of the stored items. More...
 
bool IsIntersects (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 > GetClosestIntersection (const Ray2D &ray, const GetRayIntersectionFunc2< T > &testFunc) const override
 Returns the closest intersection for given ray. More...
 
const BoundingBox2DGetBoundingBox () 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 GetNumberOfItems () const
 Returns the number of items. More...
 
const T & GetItem (size_t i) const
 Returns the item at i. More...
 

Detailed Description

template<typename T>
class CubbyFlow::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 CubbyFlow::BVH2< T >::ConstIterator = typename ContainerType::const_iterator

◆ ContainerType

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

◆ Iterator

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

Constructor & Destructor Documentation

◆ BVH2()

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

Default constructor.

Member Function Documentation

◆ begin() [1/2]

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

Returns the begin iterator of the item.

◆ begin() [2/2]

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

Returns the immutable begin iterator of the item.

◆ Build()

template<typename T>
void CubbyFlow::BVH2< T >::Build ( const std::vector< T > &  items,
const std::vector< BoundingBox2D > &  itemsBounds 
)

Builds bounding volume hierarchy.

◆ Clear()

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

Clears all the contents of this instance.

◆ end() [1/2]

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

Returns the end iterator of the item.

◆ end() [2/2]

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

Returns the immutable end iterator of the item.

◆ ForEachIntersectingItem() [1/2]

template<typename T>
void CubbyFlow::BVH2< T >::ForEachIntersectingItem ( const BoundingBox2D box,
const BoxIntersectionTestFunc2< T > &  testFunc,
const IntersectionVisitorFunc2< T > &  visitorFunc 
) const
inlineoverridevirtual

Invokes visitorFunc for every intersecting items.

Implements CubbyFlow::IntersectionQueryEngine2< T >.

◆ ForEachIntersectingItem() [2/2]

template<typename T>
void CubbyFlow::BVH2< T >::ForEachIntersectingItem ( const Ray2D ray,
const RayIntersectionTestFunc2< T > &  testFunc,
const IntersectionVisitorFunc2< T > &  visitorFunc 
) const
inlineoverridevirtual

Invokes visitorFunc for every intersecting items.

Implements CubbyFlow::IntersectionQueryEngine2< T >.

◆ GetBoundingBox()

template<typename T >
const BoundingBox2D & CubbyFlow::BVH2< T >::GetBoundingBox ( ) const

Returns bounding box of every items.

◆ GetClosestIntersection()

template<typename T>
ClosestIntersectionQueryResult2< T > CubbyFlow::BVH2< T >::GetClosestIntersection ( const Ray2D ray,
const GetRayIntersectionFunc2< T > &  testFunc 
) const
inlineoverridevirtual

Returns the closest intersection for given ray.

Implements CubbyFlow::IntersectionQueryEngine2< T >.

◆ GetItem()

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

Returns the item at i.

◆ GetNearestNeighbor()

template<typename T>
NearestNeighborQueryResult2< T > CubbyFlow::BVH2< T >::GetNearestNeighbor ( const Vector2D pt,
const NearestNeighborDistanceFunc2< T > &  distanceFunc 
) const
inlineoverridevirtual

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

Implements CubbyFlow::NearestNeighborQueryEngine2< T >.

◆ GetNumberOfItems()

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

Returns the number of items.

◆ IsIntersects() [1/2]

template<typename T>
bool CubbyFlow::BVH2< T >::IsIntersects ( const BoundingBox2D box,
const BoxIntersectionTestFunc2< T > &  testFunc 
) const
inlineoverridevirtual

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

Implements CubbyFlow::IntersectionQueryEngine2< T >.

◆ IsIntersects() [2/2]

template<typename T>
bool CubbyFlow::BVH2< T >::IsIntersects ( const Ray2D ray,
const RayIntersectionTestFunc2< T > &  testFunc 
) const
inlineoverridevirtual

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

Implements CubbyFlow::IntersectionQueryEngine2< T >.


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