14#include <lagrange/SurfaceMesh.h>
15#include <lagrange/bvh/AABB.h>
16#include <lagrange/utils/function_ref.h>
19#include <Eigen/Geometry>
21namespace lagrange::bvh {
37template <
typename Scalar,
typename Index,
int Dim = 3>
41 using AlignedBoxType =
typename AABB<Scalar, Dim>::Box;
42 using RowVectorType = Eigen::Matrix<Scalar, 1, Dim>;
60 bool empty()
const {
return m_aabb.empty(); }
85 const RowVectorType& p,
87 RowVectorType& closest_point,
88 Scalar& closest_sq_dist)
const;
A general purpose polygonal mesh class.
Definition SurfaceMesh.h:66
Axis-Aligned Bounding Box (AABB) tree for efficient spatial queries.
Definition AABB.h:39
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.
Definition TriangleAABBTree.cpp:56
TriangleAABBTree(const SurfaceMesh< Scalar, Index > &mesh)
Construct an AABB tree over the given triangle mesh.
Definition TriangleAABBTree.cpp:27
function_ref< void(Scalar, Index, const RowVectorType &)> ActionCallback
Callback signature: (squared_distance, triangle_id, closest_point)
Definition TriangleAABBTree.h:46
bool empty() const
Test whether the tree is empty.
Definition TriangleAABBTree.h:60
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.
Definition TriangleAABBTree.cpp:87
A lightweight non-owning reference to a callable.
Definition function_ref.h:47
@ Scalar
Mesh attribute must have exactly 1 channel.
Definition AttributeFwd.h:56