From 692323049594e1800e0981bac0349b985177a237 Mon Sep 17 00:00:00 2001 From: "jiangkai.zhao" Date: Tue, 19 Aug 2025 11:24:39 +0800 Subject: [PATCH] Fix:path conflictcheck Coincident lines are considered as intersecting jira:STUDIO-14085 Change-Id: I1487e6e2479e2488a3fd55651b8b4fb1bc1f4ced (cherry picked from commit 2348328a96a8d805c35cae8f03ebaa0869b1313e) --- src/libslic3r/GCode/ConflictChecker.cpp | 3 +++ src/libslic3r/Line.cpp | 15 ++++++++++++++- src/libslic3r/Line.hpp | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode/ConflictChecker.cpp b/src/libslic3r/GCode/ConflictChecker.cpp index 78a696f950..e8780a818c 100644 --- a/src/libslic3r/GCode/ConflictChecker.cpp +++ b/src/libslic3r/GCode/ConflictChecker.cpp @@ -288,6 +288,9 @@ ConflictComputeOpt ConflictChecker::line_intersect(const LineWithID &l1, const L constexpr double SUPPORT_THRESHOLD = 100; // this large almost disables conflict check of supports constexpr double OTHER_THRESHOLD = 0.01; if (l1._id == l2._id) { return {}; } // return true if lines are from same object + double overlap_length = 0.; + bool overlap = l1._line.overlap(l2._line, overlap_length); + if (overlap && overlap_length > scaled(OTHER_THRESHOLD)) return std::make_optional(l1._id, l2._id); Point inter; bool intersect = l1._line.intersection(l2._line, &inter); diff --git a/src/libslic3r/Line.cpp b/src/libslic3r/Line.cpp index 20591f0377..c74df3aa59 100644 --- a/src/libslic3r/Line.cpp +++ b/src/libslic3r/Line.cpp @@ -76,7 +76,20 @@ bool Line::parallel_to(const Line& line) const const Vec2d v2 = (line.b - line.a).cast(); return sqr(cross2(v1, v2)) < sqr(EPSILON) * v1.squaredNorm() * v2.squaredNorm(); } - +bool Line::overlap(const Line &line, double &overlap_length) const +{ + if (!this->parallel_to(line)) return false; + Line line_(this->a, line.a); + if (line_.length() > scaled(EPSILON) && !this->parallel_to(line_)) return false; + coord_t a_min = std::min(this->a.x(), this->b.x()); + coord_t a_max = std::max(this->a.x(), this->b.x()); + coord_t b_min = std::min(line.a.x(), line.b.x()); + coord_t b_max = std::max(line.a.x(), line.b.x()); + if (a_min>b_max||a_maxlength(); + return true; +} bool Line::perpendicular_to(double angle) const { return Slic3r::Geometry::directions_perpendicular(this->direction(), angle); diff --git a/src/libslic3r/Line.hpp b/src/libslic3r/Line.hpp index 5c39f25faa..028ea2aafa 100644 --- a/src/libslic3r/Line.hpp +++ b/src/libslic3r/Line.hpp @@ -183,7 +183,7 @@ public: bool clip_with_bbox(const BoundingBox &bbox); // Extend the line from both sides by an offset. void extend(double offset); - + bool overlap(const Line &line, double &overlap_length) const; static inline double distance_to_squared(const Point &point, const Point &a, const Point &b) { return line_alg::distance_to_squared(Line{a, b}, Vec<2, coord_t>{point}); } static double distance_to(const Point &point, const Point &a, const Point &b) { return sqrt(distance_to_squared(point, a, b)); }