Lagrange
Loading...
Searching...
No Matches
TriangleAABBTree< Scalar, Index, Dim > Class Template Reference

AABB tree for a triangle mesh. More...

#include <lagrange/bvh/TriangleAABBTree.h>

Public Types

using AlignedBoxType = typename AABB<Scalar, Dim>::Box
 
using RowVectorType = Eigen::Matrix<Scalar, 1, Dim>
 
using ActionCallback = function_ref<void(Scalar, Index, const RowVectorType&)>
 Callback signature: (squared_distance, triangle_id, closest_point)
 

Public Member Functions

 TriangleAABBTree (const SurfaceMesh< Scalar, Index > &mesh)
 Construct an AABB tree over the given triangle mesh.
 
bool empty () const
 Test whether the tree is empty.
 
void foreach_triangle_in_radius (const RowVectorType &p, Scalar sq_dist, ActionCallback func) const
 Iterate over triangles within a prescribed distance from a query point.
 
bool get_closest_point (const RowVectorType &p, Index &triangle_id, RowVectorType &closest_point, Scalar &closest_sq_dist) const
 Gets the nearest triangle to a query point using automatic hint optimization.
 

Detailed Description

template<typename Scalar, typename Index, int Dim = 3>
class lagrange::bvh::TriangleAABBTree< Scalar, Index, Dim >

AABB tree for a triangle mesh.

This data structure organizes triangles in a spatial hierarchy to enable efficient geometric queries such as closest point, ray intersection, and spatial containment tests.

Template Parameters
ScalarScalar type for coordinates.
IndexIndex type for triangle indices.
DimSpatial Dimension (typically 3).

Constructor & Destructor Documentation

◆ TriangleAABBTree()

template<typename Scalar, typename Index, int Dim>
TriangleAABBTree ( const SurfaceMesh< Scalar, Index > & mesh)

Construct an AABB tree over the given triangle mesh.

Parameters
[in]meshInput surface mesh.

Member Function Documentation

◆ empty()

template<typename Scalar, typename Index, int Dim = 3>
bool empty ( ) const
inline

Test whether the tree is empty.

Returns
True iff empty, False otherwise.

◆ foreach_triangle_in_radius()

template<typename Scalar, typename Index, int Dim = 3>
void foreach_triangle_in_radius ( const RowVectorType & p,
Scalar sq_dist,
ActionCallback func ) const

Iterate over triangles within a prescribed distance from a query point.

Parameters
[in]p1 x Dim query point.
[in]sq_distSquared query radius.
[in]funcFunction to apply to every triangle within query distance.

◆ get_closest_point()

template<typename Scalar, typename Index, int Dim>
bool get_closest_point ( const RowVectorType & p,
Index & triangle_id,
RowVectorType & closest_point,
Scalar & closest_sq_dist ) const

Gets the nearest triangle to a query point using automatic hint optimization.

This is an optimized version that automatically finds a good starting triangle based on bounding box centers to potentially reduce search time.

Parameters
[in]pQuery point.
[out]triangle_idNearest triangle id.
[out]closest_pointClosest point on the triangle.
[out]closest_sq_distSquared distance between closest point and query point.
Returns
True if a triangle was found, false otherwise.

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