| 672 | typedef std::vector<Polygon_2>::const_iterator PolygonIt; |
| 673 | |
| 674 | SegmentLookup(const std::vector<Polygon_2>& polygons) |
| 675 | : polygons_ref_(polygons) |
| 676 | { |
| 677 | // Unfortunately CGAL does not seem to have a ready to use aabb primitive for segments in 2D, |
| 678 | // so we have to use 3D segments and aabb tree for 2D polygons. |
| 679 | for (auto it = polygons.begin(); it != polygons.end(); ++it) { |
| 680 | for (auto eit = it->edges_begin(); eit != it->edges_end(); ++eit) { |
| 681 | CGAL::Segment_3<K> seg3d( |
| 682 | CGAL::Point_3<K>(eit->source().x(), eit->source().y(), 0), |
| 683 | CGAL::Point_3<K>(eit->target().x(), eit->target().y(), 0)); |
| 684 | all_segs.push_back(seg3d); |
| 685 | seg_to_poly[&all_segs.back()] = it; |
| 686 | } |
| 687 | } |
| 688 | tree_ = Tree(all_segs.begin(), all_segs.end()); |
| 689 | tree_.accelerate_distance_queries(); |
| 690 | } |
| 691 | |
| 692 | // This part is the most computationally expensive. Caching effectively halves the lookup time here, since every vertex on the subdivided corridor mesh has on average two outgoing edges. |
| 693 | PolygonIt input_polygon_boundary(const Point_2& p, double tol = 1e-5) { |
nothing calls this directly
no test coverage detected