I have a requirement: given a triangle mesh M (which may be unoriented, non-manifold, or a soup), as well as an arbitrary 3D point p and a radius r, I want to query all triangles on M whose distance from point p is less than or equal to r, and return the results sorted in ascending order of distance from point p to these triangles.
My current idea is to use CGAL to construct an AABB Tree for M, then construct a sphere centered at point p with radius r, and finally use the AABB’s function all_intersected_primitives()
to find all intersecting triangles. However, this does not guarantee that the results are sorted by distance, and may exhibit performance issues especially with a large number of queries or r is large.
Are there any other better and faster alternatives?
1