mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 10:32:20 +00:00
Fix:path conflictcheck
Coincident lines are considered as intersecting jira:STUDIO-14085 Change-Id: I1487e6e2479e2488a3fd55651b8b4fb1bc1f4ced (cherry picked from commit 2348328a96a8d805c35cae8f03ebaa0869b1313e)
This commit is contained in:
@@ -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<ConflictComputeResult>(l1._id, l2._id);
|
||||
Point inter;
|
||||
bool intersect = l1._line.intersection(l2._line, &inter);
|
||||
|
||||
|
||||
@@ -76,7 +76,20 @@ bool Line::parallel_to(const Line& line) const
|
||||
const Vec2d v2 = (line.b - line.a).cast<double>();
|
||||
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_max<b_min) return false;
|
||||
overlap_length = std::max((coord_t)0, std::min(a_max, b_max) - std::max(a_min, b_min));
|
||||
overlap_length /= ((double) a_max - a_min) / this->length();
|
||||
return true;
|
||||
}
|
||||
bool Line::perpendicular_to(double angle) const
|
||||
{
|
||||
return Slic3r::Geometry::directions_perpendicular(this->direction(), angle);
|
||||
|
||||
@@ -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)); }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user