| 1329 | } |
| 1330 | |
| 1331 | bool clusters_can_merge(const BoxCluster& a, const BoxCluster& b, double angle_tol_deg = 5., double axis_overlap_ratio_limit = 0.5) { |
| 1332 | if (!aabb_overlap(a.box.bbox, b.box.bbox)) { |
| 1333 | return false; |
| 1334 | } |
| 1335 | if (angle_between_dirs_deg(a.box.direction, b.box.direction) > angle_tol_deg) { |
| 1336 | return false; |
| 1337 | } |
| 1338 | if (boxes_overlap_along_merge_axis(a.box, b.box) > axis_overlap_ratio_limit) { |
| 1339 | auto a_center = CGAL::ORIGIN + ((a.box.start - CGAL::ORIGIN) + (a.box.end - CGAL::ORIGIN)) / 2.; |
| 1340 | auto b_center = CGAL::ORIGIN + ((b.box.start - CGAL::ORIGIN) + (b.box.end - CGAL::ORIGIN)) / 2.; |
| 1341 | auto a_dir = a.box.direction; |
| 1342 | auto b_dir = b.box.direction; |
| 1343 | auto dist = a.box.length < b.box.length ? point_line_distance(a_center, b_center, b_dir) : point_line_distance(b_center, a_center, a_dir); |
| 1344 | auto ref = a.box.length < b.box.length ? a.box.avg_width : b.box.avg_width; |
| 1345 | return dist < (ref / 4.); |
| 1346 | } |
| 1347 | return true; |
| 1348 | } |
| 1349 | |
| 1350 | std::vector<MergedBoxRecord> merge_intersecting_parallel_boxes_iterative(const std::vector<LineRun>& runs) { |
| 1351 | auto records = build_run_box_records(runs); |
no test coverage detected