PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
Loading...
Searching...
No Matches
pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims > Class Template Reference

CRTP base class for BVHs. More...

#include <BoundingVolumeHierarchy.h>

Public Types

using DerivedType = TDerived
 Actual type.
 
using BoundingVolumeType = TBoundingVolume
 Type of bounding volumes.
 
using PrimitiveType = TPrimitive
 Type of primitives.
 

Public Member Functions

void Construct (Index nPrimitives, Index maxPointsInLeaf=10)
 Construct the BVH from a set of primitives.
 
auto BoundingVolumes () const -> std::vector< BoundingVolumeType > const &
 Returns the bounding volumes of this BVH.
 
auto PrimitivesInBoundingVolume (Index bvIdx) const
 Returns the indices of the primitives contained in the bounding volume bvIdx.
 
template<class FIntersectsBoundingVolume, class FIntersectsPrimitive>
std::vector< IndexPrimitivesIntersecting (FIntersectsBoundingVolume &&ibv, FIntersectsPrimitive &&ip, std::size_t reserve=50ULL) const
 Returns the indices of the primitives intersecting the bounding volume bv.
 
template<class FDistanceToBoundingVolume, class FDistanceToPrimitive>
auto NearestPrimitivesTo (FDistanceToBoundingVolume &&db, FDistanceToPrimitive &&dp, std::size_t K) const -> std::pair< std::vector< Index >, std::vector< Scalar > >
 Obtains the k nearest neighbours (primitives of this BVH)
 
void Update ()
 Update the bounding volumes of this BVH.
 
PrimitiveType Primitive (Index p) const
 Returns the primitive at index p.
 
auto PrimitiveLocation (PrimitiveType const &primitive) const
 Returns the location of the primitive.
 
template<class RPrimitiveIndices>
BoundingVolumeType BoundingVolumeOf (RPrimitiveIndices &&primitiveIndexRange) const
 Returns the bounding volume of the primitives in the range [first, last)
 

Static Public Attributes

static auto constexpr kDims = Dims
 Embedding dimensionality.
 

Protected Member Functions

template<class TDerived2, class TBoundingVolume2, class TPrimitive2, int Dims2, class FBoundingVolumesOverlap, class FPrimitivesOverlap, class FPrimitivesAreAdjacent>
IndexMatrixX OverlappingPrimitivesImpl (BoundingVolumeHierarchy< TDerived2, TBoundingVolume2, TPrimitive2, Dims2 > const &other, FBoundingVolumesOverlap &&bvo, FPrimitivesOverlap &&po, FPrimitivesAreAdjacent &&PrimitivesAreAdjacent=[](PrimitiveType const &p1, TPrimitive2 const &p2) -> bool { return false;}, std::size_t reserve=50ULL) const
 Returns the indices of the primitives overlapping between this BVH and another BVH.
 

Protected Attributes

std::vector< BoundingVolumeTypemBoundingVolumes
 Bounding volumes of the BVH.
 
KdTree< kDimsmKdTree
 K-d tree used to store the primitives and the BVH tree.
 

Detailed Description

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
class pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >

CRTP base class for BVHs.

Template Parameters
TDerivedType of the child class (the concrete BVH implementation)
TBoundingVolumeType of bounding volumes used in the BVH tree
TPrimitiveType of primitives stored in the BVH
DimsEmbedding dimensionality

Member Function Documentation

◆ BoundingVolumeOf()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
template<class RPrimitiveIndices>
BoundingVolumeType pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::BoundingVolumeOf ( RPrimitiveIndices && primitiveIndexRange) const
inline

Returns the bounding volume of the primitives in the range [first, last)

Note
This function must be implemented by the derived class
Template Parameters
RPrimitiveIndicesRange of primitive indices
Parameters
primitiveIndexRangeRange of primitive indices
Returns
Bounding volume of the primitives

◆ BoundingVolumes()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
auto pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::BoundingVolumes ( ) const -> std::vector<BoundingVolumeType> const&
inline

Returns the bounding volumes of this BVH.

Returns
Bounding volumes

◆ Construct()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
void pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::Construct ( Index nPrimitives,
Index maxPointsInLeaf = 10 )
inline

Construct the BVH from a set of primitives.

Parameters
nPrimitivesNumber of primitives
maxPointsInLeafMaximum number of primitives in a leaf node

◆ NearestPrimitivesTo()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
template<class FDistanceToBoundingVolume, class FDistanceToPrimitive>
auto pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::NearestPrimitivesTo ( FDistanceToBoundingVolume && db,
FDistanceToPrimitive && dp,
std::size_t K ) const -> std::pair<std::vector<Index>, std::vector<Scalar>>
inline

Obtains the k nearest neighbours (primitives of this BVH)

Template Parameters
FDistanceToBoundingVolumeCallable with signature Scalar pred(BoundingVolume const&)
FDistanceToPrimitiveCallable with signature Scalar pred(Primitive const&)
Parameters
dbDistance function d(b) between bounding volume b and user-owned shape
dpDistance function d(p) between primitive p and user-owned shape
KNumber of nearest neighbours to query
Returns
Pair of vectors containing the indices of the nearest primitives and their distances

◆ OverlappingPrimitivesImpl()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
template<class TDerived2, class TBoundingVolume2, class TPrimitive2, int Dims2, class FBoundingVolumesOverlap, class FPrimitivesOverlap, class FPrimitivesAreAdjacent>
IndexMatrixX pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::OverlappingPrimitivesImpl ( BoundingVolumeHierarchy< TDerived2, TBoundingVolume2, TPrimitive2, Dims2 > const & other,
FBoundingVolumesOverlap && bvo,
FPrimitivesOverlap && po,
FPrimitivesAreAdjacent && PrimitivesAreAdjacent = [](PrimitiveType const& p1, TPrimitive2 const& p2) -> bool { return false; },
std::size_t reserve = 50ULL ) const
inlineprotected

Returns the indices of the primitives overlapping between this BVH and another BVH.

Template Parameters
TDerived2Type of the other BVH
TBoundingVolume2Type of bounding volumes of the other BVH
TPrimitive2Type of primitives of the other BVH
FBoundingVolumesOverlapCallable with signature bool pred(BoundingVolume const&, BoundingVolume2 const&)
FPrimitivesOverlapCallable with signature bool pred(Primitive const&, Primitive2 const&)
FPrimitivesAreAdjacentCallable with signature bool pred(Primitive const&, Primitive2 const&)
Dims2Embedding dimensionality of the other BVH
Parameters
otherOther BVH
bvoPredicate pred(bv1, bv2) evaluating to true if the bounding volumes bv1 and bv2 overlap
poPredicate pred(p1, p2) evaluating to true if the primitives p1 and p2 overlap
PrimitivesAreAdjacentPredicate pred(p1, p2) evaluating to true if the primitives p1 and p2 are adjacent
reserveEstimated number of overlapping primitives to reserve in memory
Returns
2 x |# overlaps| matrix of overlapping primitive indices

◆ Primitive()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
PrimitiveType pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::Primitive ( Index p) const
inline

Returns the primitive at index p.

Note
This function must be implemented by the derived class
Parameters
pIndex of the primitive
Returns
Primitive at index p

◆ PrimitiveLocation()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
auto pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::PrimitiveLocation ( PrimitiveType const & primitive) const
inline

Returns the location of the primitive.

Note
This function must be implemented by the derived class
Parameters
primitivePrimitive
Returns
Location of the primitive

◆ PrimitivesInBoundingVolume()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
auto pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::PrimitivesInBoundingVolume ( Index bvIdx) const
inline

Returns the indices of the primitives contained in the bounding volume bvIdx.

Parameters
bvIdxIndex of the bounding volume
Returns
Range of indices of the primitives

◆ PrimitivesIntersecting()

template<class TDerived, class TBoundingVolume, class TPrimitive, int Dims>
template<class FIntersectsBoundingVolume, class FIntersectsPrimitive>
std::vector< Index > pbat::geometry::BoundingVolumeHierarchy< TDerived, TBoundingVolume, TPrimitive, Dims >::PrimitivesIntersecting ( FIntersectsBoundingVolume && ibv,
FIntersectsPrimitive && ip,
std::size_t reserve = 50ULL ) const
inline

Returns the indices of the primitives intersecting the bounding volume bv.

Template Parameters
FIntersectsBoundingVolumeCallable with signature bool pred(BoundingVolume const&)
FIntersectsPrimitiveCallable with signature bool pred(Primitive const&) primitive p is intersected.
Parameters
ibvPredicate pred(bv) evaluating to true if the bounding volume bv is intersected.
ipPredicate pred(p) evaluating to true if the primitive p is intersected.
reserveEstimated number of intersecting primitives to reserve in memory
Returns

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