diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 8d57f3c39..8d5483f81 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -4390,12 +4390,11 @@ double GCode::get_overhang_degree_corr_speed(float normal_speed, double path_deg if (path_degree <= 0) return normal_speed; - if (path_degree >= 5 ) - return m_config.get_abs_value(overhang_speed_key_map[5].c_str()); - int lower_degree_bound = int(path_degree); - if (path_degree==lower_degree_bound) + // BBS: use lower speed of 75%-100% for better cooling + if (path_degree >= 4 || path_degree == lower_degree_bound) return m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str()); + int upper_degree_bound = lower_degree_bound + 1; double lower_speed_bound = lower_degree_bound == 0 ? normal_speed : m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str()); diff --git a/src/libslic3r/PerimeterGenerator.cpp b/src/libslic3r/PerimeterGenerator.cpp index 7dc4c613b..01a1d2c56 100644 --- a/src/libslic3r/PerimeterGenerator.cpp +++ b/src/libslic3r/PerimeterGenerator.cpp @@ -14,6 +14,7 @@ static const int overhang_sampling_number = 6; static const double narrow_loop_length_threshold = 10; static const double min_degree_gap = 0.1; static const int max_overhang_degree = overhang_sampling_number - 1; +static const std::vector non_uniform_degree_map = { 0, 10, 25, 50, 75, 100}; //BBS: when the width of expolygon is smaller than //ext_perimeter_width + ext_perimeter_spacing * (1 - SMALLER_EXT_INSET_OVERLAP_TOLERANCE), //we think it's small detail area and will generate smaller line width for it @@ -350,29 +351,40 @@ static std::deque detect_overahng_degree(Polygons low Polyline polyline_with_insert_points; points_overhang.clear(); - double last_degree = 0; + double last_terraced_overhang = 0; // BBS : calculate overhang dist for (size_t point_idx = 0; point_idx < middle_poly.points.size(); ++point_idx) { Point pt = middle_poly.points[point_idx]; float overhang_dist = prev_layer_distancer->distance_from_perimeter(pt.cast()); overhang_dist = overhang_dist > upper_bound ? upper_bound : overhang_dist; - // BBS : calculate overhang degree - int max_overhang = max_overhang_degree; - int min_overhang = 0; - double t = (overhang_dist - lower_bound) / (upper_bound - lower_bound); - t = t > 1.0 ? 1: t; - t = t < EPSILON ? 0 : t; - double this_degree = (1.0 - t) * min_overhang + t * max_overhang; + // BBS : calculate overhang degree -- overhang length / width + double this_degree = (overhang_dist - lower_bound) / (upper_bound - lower_bound) *100; + // BBS: covert to terraced overhang + double terraced_overhang = 0; + if (this_degree >= 100) + terraced_overhang = max_overhang_degree; + else if (this_degree > EPSILON * 100) { + int upper_bound_idx = std::upper_bound(non_uniform_degree_map.begin(), non_uniform_degree_map.end(), this_degree) - non_uniform_degree_map.begin(); + int lower_bound_idx = upper_bound_idx - 1; + + if (this_degree == non_uniform_degree_map[lower_bound_idx]) + terraced_overhang = lower_bound_idx; + else { + double t = (this_degree - non_uniform_degree_map[lower_bound_idx]) / (non_uniform_degree_map[upper_bound_idx] - non_uniform_degree_map[lower_bound_idx]); + terraced_overhang = (1.0 - t) * lower_bound_idx + t * upper_bound_idx; + } + } + // BBS: intert points if (point_idx > 0) { - insert_point_to_line(last_degree, middle_poly.points[point_idx - 1], this_degree, pt, points_overhang, polyline_with_insert_points, + insert_point_to_line(last_terraced_overhang, middle_poly.points[point_idx - 1], terraced_overhang, pt, points_overhang, polyline_with_insert_points, upper_bound - lower_bound); } - points_overhang.push_back(this_degree); + points_overhang.push_back(terraced_overhang); polyline_with_insert_points.append(pt); - last_degree = this_degree; + last_terraced_overhang = terraced_overhang; }