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

Function subdivide_polygon

src/svgfill/src/arrange_polygons.cpp:819–831  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

817};
818
819Polygon_2 subdivide_polygon(double max_distance, const Polygon_2 & p) {
820 std::vector<Point_2> points;
821 for (auto it = p.edges_begin(); it != p.edges_end(); ++it) {
822 const auto& seg = *it;
823 auto num_splits = (int)std::ceil(std::sqrt(CGAL::to_double(seg.squared_length())) / max_distance) - 1;
824 points.push_back(seg.source());
825 for (auto i = 0; i < num_splits; ++i) {
826 auto d = (seg.target() - seg.source()) / (num_splits + 1) * (i + 1);
827 points.push_back(seg.source() + d);
828 }
829 }
830 return Polygon_2(points.begin(), points.end());
831};
832
833Polygon_with_holes_2 subdivide_polygon(double max_distance, const Polygon_with_holes_2& pwh) {
834 Polygon_2 outer = subdivide_polygon(max_distance, pwh.outer_boundary());

Callers 1

arrange_cgal_polygonsFunction · 0.85

Calls 6

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

Tested by

no test coverage detected