18#include <lagrange/bvh/BVHType.h>
19#include <lagrange/common.h>
20#include <lagrange/utils/range.h>
25template <
typename _VertexArray,
typename _ElementArray>
29 using VertexArray = _VertexArray;
30 using ElementArray = _ElementArray;
31 using Scalar =
typename VertexArray::Scalar;
32 using Index =
typename ElementArray::Scalar;
33 using PointType = Eigen::Matrix<Scalar, 1, VertexArray::ColsAtCompileTime>;
37 virtual ~BVH() =
default;
52 virtual bool does_support_triangles()
const = 0;
53 virtual bool does_support_lines()
const = 0;
58 virtual void build(
const VertexArray& vertices,
const ElementArray& elements) = 0;
60 virtual void build(
const VertexArray& vertices) = 0;
64 Index embedding_element_idx = invalid<Index>();
65 Index closest_vertex_idx = invalid<Index>();
66 PointType closest_point;
67 Scalar squared_distance = invalid<Scalar>();
74 virtual ClosestPoint query_closest_point(
const PointType& p)
const = 0;
80 virtual std::vector<ClosestPoint> query_k_nearest_neighbours(
const PointType& p,
int k)
87 virtual std::vector<ClosestPoint> query_in_sphere_neighbours(
89 const Scalar radius)
const = 0;
95 const VertexArray& query_pts)
const = 0;
98 std::vector<ClosestPoint> default_batch_query_closest_point(
const VertexArray& query_pts)
const
100 const auto num_queries = query_pts.rows();
101 std::vector<ClosestPoint> results(num_queries);
105 query_pts.rowwise().begin(),
106 query_pts.rowwise().end(),
108 [
this](
const PointType& p) { return this->query_closest_point(p); });
virtual bool does_support_query_in_sphere_neighbours() const =0
Query for the closest point with in radius.
virtual bool does_support_pointcloud() const =0
Does it support supplying elements or just points?
virtual bool does_support_query_closest_point() const =0
Query for the closest point.
virtual std::vector< ClosestPoint > batch_query_closest_point(const VertexArray &query_pts) const =0
Batch query closest points.
virtual void build(const VertexArray &vertices, const ElementArray &elements)=0
Construct bvh based on vertices and elements.
virtual BVHType get_bvh_type() const =0
Get the enum type.
virtual bool does_support_query_k_nearest_neighbours() const =0
Query for the k nearest neighbours.
Main namespace for Lagrange.
Definition: AABBIGL.h:30