FIX: error overhang degree mapping

Jira: none

Signed-off-by: qing.zhang <qing.zhang@bambulab.com>
Change-Id: Ifa24aa0cad0a06b09ee62a8be8781188a765d1d0
This commit is contained in:
qing.zhang 2024-03-12 16:33:02 +08:00 committed by Lane.Wei
parent af9ac3d216
commit 9b3d7c36ff
2 changed files with 9 additions and 4 deletions

View File

@ -4249,11 +4249,14 @@ static std::map<int, std::string> overhang_speed_key_map =
double GCode::get_overhang_degree_corr_speed(float normal_speed, double path_degree) {
if (path_degree== 0)
//BBS: protection: overhang degree is float, make sure it not excess degree range
if (path_degree <= 0)
return normal_speed;
int lower_degree_bound = int(path_degree);
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)
return m_config.get_abs_value(overhang_speed_key_map[lower_degree_bound].c_str());
int upper_degree_bound = lower_degree_bound + 1;

View File

@ -13,6 +13,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;
//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
@ -231,6 +232,7 @@ static std::deque<PolylineWithDegree> split_polyline_by_degree(const Polyline &p
// BBS: merge degree in limited range
//find first degee base
double degree_base = int(points_overhang[points_overhang.size() - 1] / min_degree_gap) * min_degree_gap + min_degree_gap;
degree_base = degree_base > max_overhang_degree ? max_overhang_degree : degree_base;
double short_poly_len = 0;
for (int point_idx = points_overhang.size() - 2; point_idx > 0; --point_idx) {
@ -245,7 +247,7 @@ static std::deque<PolylineWithDegree> split_polyline_by_degree(const Polyline &p
out.push_back(PolylineWithDegree(right, degree_base));
degree_base = int(degree / min_degree_gap) * min_degree_gap + min_degree_gap;
degree_base = degree_base > overhang_sampling_number - 2 ? overhang_sampling_number - 2 : degree_base;
degree_base = degree_base > max_overhang_degree ? max_overhang_degree : degree_base;
}
if (!temp_copy.empty()) {
@ -356,7 +358,7 @@ static std::deque<PolylineWithDegree> detect_overahng_degree(Polygons low
float overhang_dist = prev_layer_distancer->distance_from_perimeter(pt.cast<float>());
overhang_dist = overhang_dist > upper_bound ? upper_bound : overhang_dist;
// BBS : calculate overhang degree
int max_overhang = overhang_sampling_number - 2;
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;