From b88ab02d1cda215691c66fc790994f929421d9d6 Mon Sep 17 00:00:00 2001 From: PavelMikus Date: Fri, 20 May 2022 11:26:07 +0200 Subject: [PATCH] additional minor fixes and simplifications --- src/libslic3r/GCode/SeamPlacer.cpp | 14 ++++++-------- src/libslic3r/GCode/SeamPlacer.hpp | 9 +++++++-- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/libslic3r/GCode/SeamPlacer.cpp b/src/libslic3r/GCode/SeamPlacer.cpp index 8fe8a31b8c..e7171ee7cb 100644 --- a/src/libslic3r/GCode/SeamPlacer.cpp +++ b/src/libslic3r/GCode/SeamPlacer.cpp @@ -678,7 +678,8 @@ struct SeamComparator { } //avoid overhangs - if (a.overhang > 0.1f || b.overhang > 0.1f) { + if (a.overhang > SeamPlacer::overhang_distance_tolerance_factor * a.perimeter.flow_width || + b.overhang > SeamPlacer::overhang_distance_tolerance_factor * b.perimeter.flow_width) { return a.overhang < b.overhang; } @@ -738,7 +739,8 @@ struct SeamComparator { } //avoid overhangs - if (a.overhang > 0.1f || b.overhang > 0.1f) { + if (a.overhang > SeamPlacer::overhang_distance_tolerance_factor * a.perimeter.flow_width || + b.overhang > SeamPlacer::overhang_distance_tolerance_factor * b.perimeter.flow_width) { return a.overhang < b.overhang; } @@ -761,7 +763,6 @@ struct SeamComparator { return a.position.y() > b.position.y(); } - //ranges: [0 - 1] (0 - 1.3] ; float penalty_a = a.visibility + SeamPlacer::angle_importance * compute_angle_penalty(a.local_ccw_angle); float penalty_b = b.visibility + @@ -780,11 +781,8 @@ struct SeamComparator { // looks scary, but it is gaussian combined with sigmoid, // so that concave points have much smaller penalty over convex ones // https://github.com/prusa3d/PrusaSlicer/tree/master/doc/seam_placement/corner_penalty_function.png - float f_value = gauss(ccw_angle, 0.0f, 1.0f, 3.0f) + - 1.0f / (2 + std::exp(-ccw_angle)); // sigmoid, which heavily favourizes concave angles - //NOTE for very small angles, the noise in the angle computation cause aligned lines curving. - //for this reason, the value will be clamped to 1.2 value, throwing away angles roughly smaller than 30 degrees - return std::min(f_value, 1.2f); + return gauss(ccw_angle, 0.0f, 1.0f, 3.0f) + + 1.0f / (2 + std::exp(-ccw_angle)); } }; diff --git a/src/libslic3r/GCode/SeamPlacer.hpp b/src/libslic3r/GCode/SeamPlacer.hpp index 23f165a583..fe2d88b7d5 100644 --- a/src/libslic3r/GCode/SeamPlacer.hpp +++ b/src/libslic3r/GCode/SeamPlacer.hpp @@ -121,6 +121,11 @@ public: // arm length used during angles computation static constexpr float polygon_local_angles_arm_distance = 0.1f; + + // max tolerable distance from the previous layer is overhang_distance_tolerance_factor * flow_width + static constexpr float overhang_distance_tolerance_factor = 0.5f; + + // determines angle importance compared to visibility ( neutral value is 1.0f. ) static constexpr float angle_importance = 0.7f; @@ -131,7 +136,7 @@ public: // When searching for seam clusters for alignment: // following value describes, how much worse score can point have and still be picked into seam cluster instead of original seam point on the same layer - static constexpr float seam_align_score_tolerance = 0.2f; + static constexpr float seam_align_score_tolerance = 0.27f; // seam_align_tolerable_dist - if next layer closes point is too far away, break string static constexpr float seam_align_tolerable_dist = 1.0f; // if the seam of the current layer is too far away, and the closest seam candidate is not very good, layer is skipped. @@ -140,7 +145,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 = 14; + static constexpr size_t seam_align_seams_per_segment = 8; //The following data structures hold all perimeter points for all PrintObject. std::unordered_map m_seam_per_object;