diff --git a/src/libslic3r/ExtrusionEntity.cpp b/src/libslic3r/ExtrusionEntity.cpp index 45e0ae5d3..7cc2a35ad 100644 --- a/src/libslic3r/ExtrusionEntity.cpp +++ b/src/libslic3r/ExtrusionEntity.cpp @@ -426,8 +426,8 @@ double ExtrusionLoop::min_mm3_per_mm() const } // Orca: This function is used to check if the loop is smooth(continuous) or not. -// TODO: the main logic is largly copied from the calculate_polygon_angles_at_vertices function in SeamPlacer file. Need to refactor the code in the future. -bool ExtrusionLoop::is_smooth(double angle_threshold, double min_arm_length) const +//BBS: only check angle of seam point while the seam has been decided. +bool ExtrusionLoop::check_seam_point_angle(double angle_threshold, double min_arm_length) const { // go through all the points in the loop and check if the angle between two segments(AB and BC) is less than the threshold size_t idx_prev = 0; @@ -450,31 +450,19 @@ bool ExtrusionLoop::is_smooth(double angle_threshold, double min_arm_length) con distance_to_prev += lengths[idx_prev]; } - for (size_t _i = 0; _i < points.size(); ++_i) { - // pull idx_prev to current as much as possible, while respecting the min_arm_length - while (distance_to_prev - lengths[idx_prev] > min_arm_length) { - distance_to_prev -= lengths[idx_prev]; - idx_prev = Slic3r::next_idx_modulo(idx_prev, points.size()); - } + // push idx_next forward as far as needed + while (distance_to_next < min_arm_length) { + distance_to_next += lengths[idx_next]; + idx_next = Slic3r::next_idx_modulo(idx_next, points.size()); + } - // push idx_next forward as far as needed - while (distance_to_next < min_arm_length) { - distance_to_next += lengths[idx_next]; - idx_next = Slic3r::next_idx_modulo(idx_next, points.size()); - } - - // Calculate angle between idx_prev, idx_curr, idx_next. - const Point &p0 = points[idx_prev]; - const Point &p1 = points[idx_curr]; - const Point &p2 = points[idx_next]; - const auto a = angle(p0 - p1, p2 - p1); - if (a > 0 ? a < angle_threshold : a > -angle_threshold) { return false; } - - // increase idx_curr by one - float curr_distance = lengths[idx_curr]; - idx_curr++; - distance_to_prev += curr_distance; - distance_to_next -= curr_distance; + // Calculate angle between idx_prev, idx_curr, idx_next. + const Point &p0 = points[idx_prev]; + const Point &p1 = points[idx_curr]; + const Point &p2 = points[idx_next]; + const auto a = angle(p0 - p1, p2 - p1); + if (a > 0 ? a < angle_threshold : a > -angle_threshold) { + return false; } return true; diff --git a/src/libslic3r/ExtrusionEntity.hpp b/src/libslic3r/ExtrusionEntity.hpp index f2c21e83a..5be89cb62 100644 --- a/src/libslic3r/ExtrusionEntity.hpp +++ b/src/libslic3r/ExtrusionEntity.hpp @@ -459,7 +459,7 @@ public: } double total_volume() const override { double volume =0.; for (const auto& path : paths) volume += path.total_volume(); return volume; } // check if the loop is smooth, angle_threshold is in radians, default is 10 degrees - bool is_smooth(double angle_threshold = 0.174, double min_arm_length = 0.025) const; + bool check_seam_point_angle(double angle_threshold = 0.174, double min_arm_length = 0.025) const; //static inline std::string role_to_string(ExtrusionLoopRole role); #ifndef NDEBUG diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index ae9397e41..dc96cf6a7 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -4037,7 +4037,8 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou !on_first_layer(); if (enable_seam_slope && m_config.seam_slope_conditional.value) { - enable_seam_slope = loop.is_smooth(m_config.scarf_angle_threshold.value * M_PI / 180., EXTRUDER_CONFIG(nozzle_diameter)); + //BBS: the seam has been decide, only check the seam position angle + enable_seam_slope = loop.check_seam_point_angle(m_config.scarf_angle_threshold.value * M_PI / 180.0); } // clip the path to avoid the extruder to get exactly on the first point of the loop; diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 55c172564..4b54c0f4e 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2863,7 +2863,7 @@ void PrintConfigDef::init_fff_params() def = this->add("scarf_angle_threshold", coInt); def->label = L("Conditional angle threshold"); - def->tooltip = L("This option sets the threshold angle for applying a conditional scarf joint seam.\nIf the maximum angle within the perimeter loop " "exceeds this value (indicating the absence of sharp corners), a scarf joint seam will be used. The default value is 155°."); + def->tooltip = L("This option sets the threshold angle for applying a conditional scarf joint seam.\nIf the seam angle within the perimeter loop " "exceeds this value (indicating the absence of sharp corners), a scarf joint seam will be used. The default value is 155°."); def->mode = comAdvanced; def->sidetext = L("°"); def->min = 0;