| 1543 | } |
| 1544 | |
| 1545 | Graph2D<K> join_segment_runs( |
| 1546 | DebugWriter& debug, |
| 1547 | const std::map<Point_2, std::vector<Point_2>>& line_graph, |
| 1548 | const std::map<Point_2, double>& midpoint_to_edge_length) |
| 1549 | { |
| 1550 | auto graph = make_center_line_graph_data(line_graph, midpoint_to_edge_length); |
| 1551 | auto runs = runs_from_graph(graph); |
| 1552 | runs.erase(std::remove_if(runs.begin(), runs.end(), [](const LineRun& run) { |
| 1553 | return run.vertex_count <= 5; |
| 1554 | }), runs.end()); |
| 1555 | |
| 1556 | std::vector<Polygon_2> run_polygons; |
| 1557 | for (auto& r : runs) { |
| 1558 | auto ps = rectangle_corners(r.start, r.end, r.avg_width); |
| 1559 | std::array<Point_2, 4> exact_corners; |
| 1560 | std::transform(ps.begin(), ps.end(), exact_corners.begin(), [](const DPoint& p) { |
| 1561 | return to_exact_point(p); |
| 1562 | }); |
| 1563 | run_polygons.emplace_back(exact_corners.begin(), exact_corners.end()); |
| 1564 | } |
| 1565 | debug.write_polygons(run_polygons, "initial_runs"); |
| 1566 | run_polygons.clear(); |
| 1567 | |
| 1568 | auto boxes = merge_intersecting_parallel_boxes_iterative(runs); |
| 1569 | |
| 1570 | for (auto& r : boxes) { |
| 1571 | auto ps = rectangle_corners(r.start, r.end, r.avg_width); |
| 1572 | std::array<Point_2, 4> exact_corners; |
| 1573 | std::transform(ps.begin(), ps.end(), exact_corners.begin(), [](const DPoint& p) { |
| 1574 | return to_exact_point(p); |
| 1575 | }); |
| 1576 | run_polygons.emplace_back(exact_corners.begin(), exact_corners.end()); |
| 1577 | } |
| 1578 | debug.write_polygons(run_polygons, "merged_boxes"); |
| 1579 | |
| 1580 | auto snapped_graph = snap_points_to_box_axes(graph, boxes); |
| 1581 | return Graph2D<K>(snapped_graph); |
| 1582 | } |
| 1583 | |
| 1584 | std::set<Triangle<K>> find_triangles(const std::map<Point_2, std::vector<Point_2>>& line_graph) { |
| 1585 | // Find triangles in this network often occuring at junctions in the corridor mesh |
no test coverage detected