c++ - How to augment objects in CGAL AABB tree with custom labels? -
for fixed point, efficiently find closest item (fixed) set of line segments. end, have been experimenting along lines of cgal example:
#include <iostream> #include <list> #include <cgal/simple_cartesian.h> #include <cgal/aabb_tree.h> #include <cgal/aabb_traits.h> #include <cgal/aabb_segment_primitive.h> typedef cgal::simple_cartesian<double> k; typedef k::ft ft; typedef k::point_3 point; typedef k::segment_3 segment; typedef std::list<segment>::iterator iterator; typedef cgal::aabb_segment_primitive<k, iterator> primitive; typedef cgal::aabb_traits<k, primitive> traits; typedef cgal::aabb_tree<traits> tree; int main() { point a(1.0, 0.0, 0.0); point b(0.0, 1.0, 0.0); point c(0.0, 0.0, 1.0); std::list<segment> segments; segments.push_back(segment(a,b)); segments.push_back(segment(a,c)); tree tree(segments.begin(),segments.end()); tree.accelerate_distance_queries(); point point_query(2.0, 2.0, 2.0); point closest = tree.closest_point(point_query); std::cerr << "closest point is: " << closest << std::endl; return exit_success; }
now, instead of closest point, need identify particular line segment (to point belongs). if use example:
auto closest = tree.closest_point_and_primitive(point_query); auto = closest.second;
then it
indeed points particular segment. however, prefer somehow label each of segments custom id , retrieve id/tag instead of segment itself. can achieved in reasonably painless way? have been trying find inspiration in another cgal example, unfortunately no avail yet...
Comments
Post a Comment