Skip to content

Commit

Permalink
Merge branch 'main' into Xcode-16-debug-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
igiannakas authored Dec 18, 2024
2 parents aab3e43 + 27ec198 commit 2ba194b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/libslic3r/Arachne/utils/ExtrusionLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,19 @@ void ExtrusionLine::simplify(const int64_t smallest_line_segment_squared, const
// ^ current
Point intersection_point;
bool has_intersection = Line(previous_previous.p, previous.p).intersection_infinite(Line(current.p, next.p), &intersection_point);
const auto dist_greater = [](const Point& p1, const Point& p2, const int64_t threshold) {
const auto vec = (p1 - p2).cwiseAbs().cast<uint64_t>();
if(vec.x() > threshold || vec.y() > threshold) {
// If this condition is true, the distance is definitely greater than the threshold.
// We don't need to calculate the squared norm at all, which avoid potential arithmetic overflow.
return true;
}
return vec.squaredNorm() > threshold;
};
if (!has_intersection
|| Line::distance_to_infinite_squared(intersection_point, previous.p, current.p) > double(allowed_error_distance_squared)
|| (intersection_point - previous.p).cast<int64_t>().squaredNorm() > smallest_line_segment_squared // The intersection point is way too far from the 'previous'
|| (intersection_point - current.p).cast<int64_t>().squaredNorm() > smallest_line_segment_squared) // and 'current' points, so it shouldn't replace 'current'
|| dist_greater(intersection_point, previous.p, smallest_line_segment_squared) // The intersection point is way too far from the 'previous'
|| dist_greater(intersection_point, current.p, smallest_line_segment_squared)) // and 'current' points, so it shouldn't replace 'current'
{
// We can't find a better spot for it, but the size of the line is more than 5 micron.
// So the only thing we can do here is leave it in...
Expand Down

0 comments on commit 2ba194b

Please sign in to comment.