From faaaf4148e97e6fb470eb26085048e0f898f969f Mon Sep 17 00:00:00 2001 From: PavelMikus Date: Tue, 10 May 2022 16:54:06 +0200 Subject: [PATCH] simplifed choice of seam spot in the next layer removed checks for similarity. increased raycasting precision a little smoothen the B-splines increasing the number of points per segment (from 8 to 14) --- src/libslic3r/GCode/SeamPlacer.cpp | 10 ++++------ src/libslic3r/GCode/SeamPlacer.hpp | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index ec2b59e370..518764f2e3 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -1112,9 +1112,8 @@ std::optional> SeamPlacer::find_next_seam_in_layer( return {std::pair {layer_idx, nearest_point.perimeter.seam_index}}; } - // Next compare nearest and nearby point. If they are similar pick nearest, Otherwise expect curvy lines on smooth surfaces like chimney of benchy model - if (comparator.are_similar(nearest_point, best_nearby_point) - && comparator.is_first_not_much_worse(nearest_point, next_layer_seam)) { + // First try to align the nearest, then try the best nearby + if (comparator.is_first_not_much_worse(nearest_point, next_layer_seam)) { return {std::pair {layer_idx, nearest_point_index}}; } // If nearest point is not good enough, try it with the best nearby point. @@ -1237,13 +1236,12 @@ void SeamPlacer::align_seam_points(const PrintObject *po, const SeamPlacerImpl:: } } - Vec2f back_attractor = 2.0f * unscaled(po->bounding_box().max).cast(); //sort them before alignment. Alignment is sensitive to initializaion, this gives it better chance to choose something nice std::sort(seams.begin(), seams.end(), - [&comparator, &layers, &back_attractor](const std::pair &left, + [&comparator, &layers](const std::pair &left, const std::pair &right) { return comparator.is_first_better(layers[left.first].points[left.second], - layers[right.first].points[right.second], back_attractor); + layers[right.first].points[right.second]); } ); diff --git a/src/libslic3r/GCode/SeamPlacer.hpp b/src/libslic3r/GCode/SeamPlacer.hpp index 1138ef7482..1fddea4958 100644 --- a/src/libslic3r/GCode/SeamPlacer.hpp +++ b/src/libslic3r/GCode/SeamPlacer.hpp @@ -113,7 +113,7 @@ class SeamPlacer { public: static constexpr size_t raycasting_decimation_target_triangle_count = 10000; // for subdivision, both following criteria are considered, and the one with less resulting triangles is used - static constexpr size_t raycasting_subdivision_target_triangle_count = 15000; + static constexpr size_t raycasting_subdivision_target_triangle_count = 20000; static constexpr float raycasting_subdivision_target_length = 2.0f; //square of number of rays per triangle static constexpr size_t sqr_rays_per_triangle = 7; @@ -140,7 +140,7 @@ public: // minimum number of seams needed in cluster to make alignment happen static constexpr size_t seam_align_minimum_string_seams = 6; // points covered by spline; determines number of splines for the given string - static constexpr size_t seam_align_seams_per_segment = 8; + static constexpr size_t seam_align_seams_per_segment = 14; //The following data structures hold all perimeter points for all PrintObject. std::unordered_map m_seam_per_object;