FIX: lower overhang speed to get better cooling

Jira: none

Signed-off-by: qing.zhang <qing.zhang@bambulab.com>
Change-Id: I79235fac75d6601da13d55ddc7d8602f88b1a462
This commit is contained in:
qing.zhang 2024-06-18 15:20:50 +08:00 committed by Lane.Wei
parent 758d087f15
commit bcdcea2bfe
2 changed files with 26 additions and 15 deletions

View File

@ -4390,12 +4390,11 @@ double GCode::get_overhang_degree_corr_speed(float normal_speed, double path_deg
if (path_degree <= 0) if (path_degree <= 0)
return normal_speed; 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); 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()); return m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str());
int upper_degree_bound = lower_degree_bound + 1; 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()); double lower_speed_bound = lower_degree_bound == 0 ? normal_speed : m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str());

View File

@ -14,6 +14,7 @@ static const int overhang_sampling_number = 6;
static const double narrow_loop_length_threshold = 10; static const double narrow_loop_length_threshold = 10;
static const double min_degree_gap = 0.1; static const double min_degree_gap = 0.1;
static const int max_overhang_degree = overhang_sampling_number - 1; static const int max_overhang_degree = overhang_sampling_number - 1;
static const std::vector<double> non_uniform_degree_map = { 0, 10, 25, 50, 75, 100};
//BBS: when the width of expolygon is smaller than //BBS: when the width of expolygon is smaller than
//ext_perimeter_width + ext_perimeter_spacing * (1 - SMALLER_EXT_INSET_OVERLAP_TOLERANCE), //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 //we think it's small detail area and will generate smaller line width for it
@ -350,29 +351,40 @@ static std::deque<PolylineWithDegree> detect_overahng_degree(Polygons low
Polyline polyline_with_insert_points; Polyline polyline_with_insert_points;
points_overhang.clear(); points_overhang.clear();
double last_degree = 0; double last_terraced_overhang = 0;
// BBS : calculate overhang dist // BBS : calculate overhang dist
for (size_t point_idx = 0; point_idx < middle_poly.points.size(); ++point_idx) { for (size_t point_idx = 0; point_idx < middle_poly.points.size(); ++point_idx) {
Point pt = middle_poly.points[point_idx]; Point pt = middle_poly.points[point_idx];
float overhang_dist = prev_layer_distancer->distance_from_perimeter(pt.cast<float>()); float overhang_dist = prev_layer_distancer->distance_from_perimeter(pt.cast<float>());
overhang_dist = overhang_dist > upper_bound ? upper_bound : overhang_dist; overhang_dist = overhang_dist > upper_bound ? upper_bound : overhang_dist;
// BBS : calculate overhang degree // BBS : calculate overhang degree -- overhang length / width
int max_overhang = max_overhang_degree; double this_degree = (overhang_dist - lower_bound) / (upper_bound - lower_bound) *100;
int min_overhang = 0; // BBS: covert to terraced overhang
double t = (overhang_dist - lower_bound) / (upper_bound - lower_bound); double terraced_overhang = 0;
t = t > 1.0 ? 1: t; if (this_degree >= 100)
t = t < EPSILON ? 0 : t; terraced_overhang = max_overhang_degree;
double this_degree = (1.0 - t) * min_overhang + t * max_overhang; 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 // BBS: intert points
if (point_idx > 0) { 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); upper_bound - lower_bound);
} }
points_overhang.push_back(this_degree); points_overhang.push_back(terraced_overhang);
polyline_with_insert_points.append(pt); polyline_with_insert_points.append(pt);
last_degree = this_degree; last_terraced_overhang = terraced_overhang;
} }