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

Function clusters_can_merge

src/svgfill/src/arrange_polygons.cpp:1331–1348  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1329}
1330
1331bool 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
1350std::vector<MergedBoxRecord> merge_intersecting_parallel_boxes_iterative(const std::vector<LineRun>& runs) {
1351 auto records = build_run_box_records(runs);

Calls 4

aabb_overlapFunction · 0.85
angle_between_dirs_degFunction · 0.85
point_line_distanceFunction · 0.85

Tested by

no test coverage detected