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:
jiangkai.zhao
2025-08-19 11:24:39 +08:00
committed by Noisyfox
parent 69b2b5d86d
commit 6923230495
3 changed files with 18 additions and 2 deletions

View File

@@ -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);