From c86deb92db87231d53e549fc91ad97aef7592c5f Mon Sep 17 00:00:00 2001 From: Pavel Mikus Date: Thu, 6 Oct 2022 12:19:33 +0200 Subject: [PATCH] improve function name to reflect that it does unscaling (to_unscaled_linesf) --- src/libslic3r/ExPolygon.hpp | 13 +++++++++---- src/libslic3r/GCode/SeamPlacer.cpp | 5 +++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/ExPolygon.hpp b/src/libslic3r/ExPolygon.hpp index 7f2aac628..def2be85a 100644 --- a/src/libslic3r/ExPolygon.hpp +++ b/src/libslic3r/ExPolygon.hpp @@ -125,7 +125,7 @@ inline Lines to_lines(const ExPolygons &src) return lines; } -inline std::vector to_linesf(const ExPolygons &src) +inline std::vector to_unscaled_linesf(const ExPolygons &src) { size_t n_lines = 0; for (ExPolygons::const_iterator it_expoly = src.begin(); it_expoly != src.end(); ++ it_expoly) { @@ -138,9 +138,14 @@ inline std::vector to_linesf(const ExPolygons &src) for (ExPolygons::const_iterator it_expoly = src.begin(); it_expoly != src.end(); ++ it_expoly) { for (size_t i = 0; i <= it_expoly->holes.size(); ++ i) { const Points &points = ((i == 0) ? it_expoly->contour : it_expoly->holes[i - 1]).points; - for (Points::const_iterator it = points.begin(); it != points.end()-1; ++it) - lines.push_back(Linef(unscaled(*it), unscaled(*(it + 1)))); - lines.push_back(Linef(unscaled(points.back()), unscaled(points.front()))); + Vec2d unscaled_a = unscaled(points.front()); + Vec2d unscaled_b = unscaled_a; + for (Points::const_iterator it = points.begin()+1; it != points.end(); ++it){ + unscaled_b = unscaled(*(it)); + lines.push_back(Linef(unscaled_a, unscaled_b)); + unscaled_a = unscaled_b; + } + lines.push_back(Linef(unscaled_a, unscaled(points.front()))); } } return lines; diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index e18984a64..1d7fd5b3c 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -1054,7 +1054,7 @@ void SeamPlacer::calculate_overhangs_and_layer_embedding(const PrintObject *po) [po, &layers](tbb::blocked_range r) { std::unique_ptr prev_layer_distancer; if (r.begin() > 0) { // previous layer exists - prev_layer_distancer = std::make_unique(to_linesf(po->layers()[r.begin() - 1]->lslices)); + prev_layer_distancer = std::make_unique(to_unscaled_linesf(po->layers()[r.begin() - 1]->lslices)); } for (size_t layer_idx = r.begin(); layer_idx < r.end(); ++layer_idx) { @@ -1065,7 +1065,8 @@ void SeamPlacer::calculate_overhangs_and_layer_embedding(const PrintObject *po) } }; bool should_compute_layer_embedding = regions_with_perimeter > 1; - std::unique_ptr current_layer_distancer = std::make_unique(to_linesf(po->layers()[layer_idx]->lslices)); + std::unique_ptr current_layer_distancer = std::make_unique( + to_unscaled_linesf(po->layers()[layer_idx]->lslices)); for (SeamCandidate &perimeter_point : layers[layer_idx].points) { Vec2f point = Vec2f { perimeter_point.position.head<2>() };