From 352f4222b1c279bd0c9700691192161dafccbdeb Mon Sep 17 00:00:00 2001 From: manch1n Date: Sat, 6 May 2023 16:53:06 +0800 Subject: [PATCH] ENH: increase conflict threshold to 1mm for both support lines Little overlap of support lines from two objects are allowed. Change-Id: I738874ee71fc9787abbef764dbad762c76bc5731 (cherry picked from commit a5f7a53dc818d598523149d675fd0310f5d22f86) --- src/libslic3r/GCode/ConflictChecker.cpp | 12 +++++++++++- src/libslic3r/GCode/ConflictChecker.hpp | 4 ++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/GCode/ConflictChecker.cpp b/src/libslic3r/GCode/ConflictChecker.cpp index 482dd65a8..9dc41e68c 100644 --- a/src/libslic3r/GCode/ConflictChecker.cpp +++ b/src/libslic3r/GCode/ConflictChecker.cpp @@ -263,14 +263,24 @@ ConflictResultOpt ConflictChecker::find_inter_of_lines_in_diff_objs(PrintObjectP ConflictComputeOpt ConflictChecker::line_intersect(const LineWithID &l1, const LineWithID &l2) { + constexpr double SUPPORT_THRESHOLD = 1.0; + constexpr double OTHER_THRESHOLD = 0.01; if (l1._id == l2._id) { return {}; } // return true if lines are from same object Point inter; bool intersect = l1._line.intersection(l2._line, &inter); + if (intersect) { auto dist1 = std::min(unscale(Point(l1._line.a - inter)).norm(), unscale(Point(l1._line.b - inter)).norm()); auto dist2 = std::min(unscale(Point(l2._line.a - inter)).norm(), unscale(Point(l2._line.b - inter)).norm()); auto dist = std::min(dist1, dist2); - if (dist > 0.01) { return std::make_optional(l1._id, l2._id); } // the two lines intersects if dist>0.01mm + ExtrusionRole r1 = l1._role; + ExtrusionRole r2 = l2._role; + bool both_support = r1 == ExtrusionRole::erSupportMaterial || r1 == ExtrusionRole::erSupportMaterialInterface || r1 == ExtrusionRole::erSupportTransition; + both_support &= r2 == ExtrusionRole::erSupportMaterial || r2 == ExtrusionRole::erSupportMaterialInterface || r2 == ExtrusionRole::erSupportTransition; + if (dist > (both_support ? SUPPORT_THRESHOLD:OTHER_THRESHOLD)) { + // the two lines intersects if dist>0.01mm for regular lines, and if dist>1mm for both supports + return std::make_optional(l1._id, l2._id); + } } return {}; } diff --git a/src/libslic3r/GCode/ConflictChecker.hpp b/src/libslic3r/GCode/ConflictChecker.hpp index a9a6e85f2..f7e522065 100644 --- a/src/libslic3r/GCode/ConflictChecker.hpp +++ b/src/libslic3r/GCode/ConflictChecker.hpp @@ -16,9 +16,9 @@ struct LineWithID { Line _line; int _id; - int _role; + ExtrusionRole _role; - LineWithID(const Line &line, int id, int role) : _line(line), _id(id), _role(role) {} + LineWithID(const Line &line, int id, ExtrusionRole role) : _line(line), _id(id), _role(role) {} }; using LineWithIDs = std::vector;