PhysicsBasedAnimationToolkit 0.0.10
Cross-platform C++20 library of algorithms and data structures commonly used in computer graphics research on physically-based simulation.
|
Bounding volume hierarchy for triangles in 2D. More...
#include <TriangleAabbHierarchy.h>
Public Types | |
using | SelfType = TriangleAabbHierarchy2D |
Self type. | |
using | BaseType |
Base type. | |
![]() | |
using | DerivedType |
Actual type. | |
using | BoundingVolumeType |
Type of bounding volumes. | |
using | PrimitiveType |
Type of primitives. | |
Public Member Functions | |
PBAT_API | TriangleAabbHierarchy2D (Eigen::Ref< MatrixX const > const &V, Eigen::Ref< IndexMatrixX const > const &C, Index maxPointsInLeaf=10) |
Construct a triangle Aabb BVH from an input mesh (V,C) | |
PBAT_API PrimitiveType | Primitive (Index p) const |
Returns the primitive at index p. | |
PBAT_API Vector< kDims > | PrimitiveLocation (PrimitiveType const &primitive) const |
Returns the location of the primitive. | |
template<class RPrimitiveIndices> | |
BoundingVolumeType | BoundingVolumeOf (RPrimitiveIndices &&pinds) const |
Returns the bounding volume of the primitive. | |
PBAT_API void | Update () |
Updates the AABBs. | |
PBAT_API IndexMatrixX | OverlappingPrimitives (SelfType const &bvh, std::size_t reserve=1000ULL) const |
Returns the overlapping primitives of this BVH and another BVH. | |
template<class TDerivedP> | |
IndexVectorX | PrimitivesContainingPoints (Eigen::MatrixBase< TDerivedP > const &P, bool bParallelize=true) const |
For each point in P, returns the index of the primitive containing it. | |
template<class TDerivedP> | |
auto | NearestPrimitivesToPoints (Eigen::MatrixBase< TDerivedP > const &P, bool bParallelize=true) const -> std::pair< IndexVectorX, VectorX > |
For each point in P, returns the index of the nearest primitive to it. | |
auto const & | GetBoundingVolumes () const |
Returns this BVH's bounding volumes. | |
template<class TDerivedP> | |
void | SetV (Eigen::MatrixBase< TDerivedP > const &P) |
Updates this BVH's mesh's vertex positions. | |
auto | GetV () const |
Returns this BVH's mesh's vertex positions. | |
![]() | |
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. | |
std::vector< Index > | PrimitivesIntersecting (FIntersectsBoundingVolume &&ibv, FIntersectsPrimitive &&ip, std::size_t reserve=50ULL) const |
Returns the indices of the primitives intersecting the bounding volume bv. | |
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. | |
BoundingVolumeType | BoundingVolumeOf (RPrimitiveIndices &&primitiveIndexRange) const |
Returns the bounding volume of the primitives in the range [first, last) | |
Public Attributes | |
Eigen::Ref< MatrixX const > | V |
|kDims|x|# verts| vertex positions | |
Eigen::Ref< IndexMatrixX const > | C |
3x|# triangles| triangle vertex indices into V | |
Static Public Attributes | |
static auto constexpr | kDims = 2 |
Number of dimensions. | |
![]() | |
static auto constexpr | kDims |
Embedding dimensionality. | |
Additional Inherited Members | |
![]() | |
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. | |
![]() | |
std::vector< BoundingVolumeType > | mBoundingVolumes |
Bounding volumes of the BVH. | |
KdTree< kDims > | mKdTree |
K-d tree used to store the primitives and the BVH tree. | |
Bounding volume hierarchy for triangles in 2D.
Base type.
pbat::geometry::TriangleAabbHierarchy2D::TriangleAabbHierarchy2D | ( | Eigen::Ref< MatrixX const > const & | V, |
Eigen::Ref< IndexMatrixX const > const & | C, | ||
Index | maxPointsInLeaf = 10 ) |
Construct a triangle Aabb BVH from an input mesh (V,C)
V | 2x|# verts| matrix of vertex positions |
C | 3x|# triangles| matrix of cell vertex indices |
maxPointsInLeaf | Maximum number of simplices in a leaf node |
|
inline |
Returns the bounding volume of the primitive.
RPrimitiveIndices | Index range type |
pinds | Range of primitive indices |
|
inline |
Returns this BVH's bounding volumes.
|
inline |
Returns this BVH's mesh's vertex positions.
|
inline |
For each point in P, returns the index of the nearest primitive to it.
TDerivedP | Eigen matrix type |
FCull | Culling function type |
P | |kDims|x|# points| matrix of points |
bParallelize | Whether to parallelize the computation |
|# points|
vector of nearest primitive indices to the points IndexMatrixX pbat::geometry::TriangleAabbHierarchy2D::OverlappingPrimitives | ( | SelfType const & | bvh, |
std::size_t | reserve = 1000ULL ) const |
Returns the overlapping primitives of this BVH and another BVH.
bvh | The other BVH |
reserve | Estimated number of overlapping primitives to reserve memory for |
2x|# overlaps|
matrix O
of overlapping primitive pairs s.t. primitives O(0,o)
in this bvh, and O(1,o)
in the other bvh overlap. TriangleAabbHierarchy2D::PrimitiveType pbat::geometry::TriangleAabbHierarchy2D::Primitive | ( | Index | p | ) | const |
Returns the primitive at index p.
p | Index of the primitive |
Vector< TriangleAabbHierarchy2D::kDims > pbat::geometry::TriangleAabbHierarchy2D::PrimitiveLocation | ( | PrimitiveType const & | primitive | ) | const |
Returns the location of the primitive.
primitive | The primitive |
|
inline |
For each point in P, returns the index of the primitive containing it.
TDerivedP | Eigen matrix type |
P | |kDims|x|# points| matrix of points |
bParallelize | Whether to parallelize the computation |
|# points|
vector of primitive indices containing the points
|
inline |
Updates this BVH's mesh's vertex positions.
TDerivedP | Eigen matrix type |
P | |kDims|x|# verts| matrix of vertex positions |