From 3e50699576dcea42c6f97517f2c7829ee2a6a3a5 Mon Sep 17 00:00:00 2001 From: Vojtech Bubnik Date: Tue, 20 Oct 2020 09:17:26 +0200 Subject: [PATCH] Renamed Line::offset to extend Don't use unscaled constants! What if the scaling constant changes in the future? --- src/libslic3r/Fill/FillAdaptive.cpp | 2 +- src/libslic3r/Line.cpp | 2 +- src/libslic3r/Line.hpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Fill/FillAdaptive.cpp b/src/libslic3r/Fill/FillAdaptive.cpp index be7f0bc59..4435a43e7 100644 --- a/src/libslic3r/Fill/FillAdaptive.cpp +++ b/src/libslic3r/Fill/FillAdaptive.cpp @@ -625,7 +625,7 @@ static Line create_offset_line(const Line &line_to_offset, const Intersection &i Line offset_line = line_to_offset; offset_line.translate(offset_vector.x(), offset_vector.y()); // Extend the line by small value to guarantee a collision with adjacent lines - offset_line.offset(1000000); + offset_line.extend(coord_t(scale_(1.))); return offset_line; }; diff --git a/src/libslic3r/Line.cpp b/src/libslic3r/Line.cpp index abea80f5f..8a2a2875b 100644 --- a/src/libslic3r/Line.cpp +++ b/src/libslic3r/Line.cpp @@ -100,7 +100,7 @@ bool Line::clip_with_bbox(const BoundingBox &bbox) return result; } -void Line::offset(double offset) +void Line::extend(double offset) { Vector offset_vector = (offset * this->vector().cast().normalized()).cast(); this->a -= offset_vector; diff --git a/src/libslic3r/Line.hpp b/src/libslic3r/Line.hpp index 2cc8139f1..aeb185160 100644 --- a/src/libslic3r/Line.hpp +++ b/src/libslic3r/Line.hpp @@ -75,8 +75,8 @@ public: double ccw(const Point& point) const { return point.ccw(*this); } // Clip a line with a bounding box. Returns false if the line is completely outside of the bounding box. bool clip_with_bbox(const BoundingBox &bbox); - // Resize a line from both sides by the offset. - void offset(double offset); + // Extend the line from both sides by an offset. + void extend(double offset); 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)); }