14#include <lagrange/utils/function_ref.h>
15#include <lagrange/utils/invalid.h>
16#include <lagrange/utils/span.h>
18#include <Eigen/Geometry>
22namespace lagrange::bvh {
37template <
typename Scalar,
int Dim>
41 using Index = uint32_t;
42 using Box = Eigen::AlignedBox<Scalar, Dim>;
43 using Point =
typename Box::VectorType;
59 void intersect(
const Box& query_box, std::vector<Index>& results)
const;
124 std::vector<Node> m_nodes;
Axis-Aligned Bounding Box (AABB) tree for efficient spatial queries.
Definition AABB.h:39
Index get_closest_element(const Point &q, function_ref< Scalar(Index)> sq_dist_fn) const
Find the index of the closest element to a query point.
Definition AABB.cpp:188
void foreach_element_within_radius(const Point &q, Scalar sq_radius, function_ref< void(Index)> func) const
Call a function for each element within a given radius from a query point.
Definition AABB.cpp:253
Index intersect_first(const Box &query_box) const
Find the first box that intersects with a query box.
Definition AABB.cpp:177
bool empty() const
Check if the tree is empty.
Definition AABB.h:110
void build(span< Box > boxes)
Build the AABB tree from a collection of bounding boxes.
Definition AABB.cpp:32
void intersect(const Box &query_box, std::vector< Index > &results) const
Find all boxes that intersect with a query box.
Definition AABB.cpp:127
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
::nonstd::span< T, Extent > span
A bounds-safe view for sequences of objects.
Definition span.h:27
constexpr T invalid()
You can use invalid<T>() to get a value that can represent "invalid" values, such as invalid indices ...
Definition invalid.h:40