MCPcopy Create free account
hub / github.com/IfcOpenShell/IfcOpenShell / SegmentLookup

Method SegmentLookup

src/svgfill/src/arrange_polygons.cpp:674–690  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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) {

Callers

nothing calls this directly

Calls 5

edges_beginMethod · 0.80
edges_endMethod · 0.80
push_backMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected