FIX: seam render missing for path split

Jira: none

Signed-off-by: qing.zhang <qing.zhang@bambulab.com>
Change-Id: I7109d38e3f7f858836cfa199c2871dc583e42eca
This commit is contained in:
qing.zhang 2024-10-18 14:26:07 +08:00 committed by Lane.Wei
parent 63be8a61fb
commit beb3241c96
1 changed files with 20 additions and 44 deletions

View File

@ -4420,17 +4420,6 @@ static bool need_smooth_speed(const ExtrusionPath &other_path, const ExtrusionPa
return false; return false;
} }
static void append_split_line(bool split_from_left, Polyline &polyline, Point p1, Point p2)
{
if (split_from_left) {
polyline.append(p1);
polyline.append(p2);
} else {
polyline.append(p2);
polyline.append(p1);
}
}
ExtrusionPaths GCode::split_and_mapping_speed(double &other_path_v, double &final_v, ExtrusionPath &this_path, double max_smooth_length, bool split_from_left) ExtrusionPaths GCode::split_and_mapping_speed(double &other_path_v, double &final_v, ExtrusionPath &this_path, double max_smooth_length, bool split_from_left)
{ {
ExtrusionPaths splited_path; ExtrusionPaths splited_path;
@ -4473,64 +4462,51 @@ ExtrusionPaths GCode::split_and_mapping_speed(double &other_path_v, double &fina
return pos_x_speed; return pos_x_speed;
}; };
while (end_pt_idx < input_polyline.points.size()) { while (split_line_speed < final_v && end_pt_idx < input_polyline.size()) {
// move to next line // move to next line
if (get_next_line) { if (get_next_line) {
line_start_pt = input_polyline.points[end_pt_idx - 1]; line_start_pt = input_polyline.points[end_pt_idx - 1];
line_end_pt = input_polyline.points[end_pt_idx]; line_end_pt = input_polyline.points[end_pt_idx];
} }
//This line is cut off as a speed transition area
Polyline polyline; Polyline cuted_polyline;
Line line(line_start_pt, line_end_pt); Line line(line_start_pt, line_end_pt);
cuted_polyline.append(line_start_pt);
// split polyline and set speed // split polyline and set speed
if (line.length() < max_step_length || line.length() - min_step_length < min_step_length / 2) { if (line.length() < max_step_length || line.length() - min_step_length < min_step_length / 2) {
split_line_speed = insert_speed(line.length(), x_base, smooth_length_count, final_v); split_line_speed = insert_speed(line.length(), x_base, smooth_length_count, final_v);
append_split_line(split_from_left, polyline, line_start_pt, line_end_pt);
end_pt_idx++; end_pt_idx++;
get_next_line = true; get_next_line = true;
cuted_polyline.append(line.b);
} else { } else {
// path is too long, split it // path is too long, split it
double rate = min_step_length / line.length(); double rate = min_step_length / line.length();
Point insert_p = line.a + (line.b - line.a) * rate; Point insert_p = line.a + (line.b - line.a) * rate;
split_line_speed = insert_speed(min_step_length, x_base, smooth_length_count, final_v); split_line_speed = insert_speed(min_step_length, x_base, smooth_length_count, final_v);
append_split_line(split_from_left, polyline, line_start_pt, insert_p);
line_start_pt = insert_p; line_start_pt = insert_p;
get_next_line = false; get_next_line = false;
cuted_polyline.append(insert_p);
} }
ExtrusionPath path_step(polyline, this_path); ExtrusionPath path_step(cuted_polyline, this_path);
path_step.smooth_speed = split_line_speed; path_step.smooth_speed = split_line_speed;
splited_path.push_back(std::move(path_step)); splited_path.push_back(std::move(path_step));
// stop condition
if (split_line_speed >= final_v) break;
} }
if (!split_from_left) // reverse path back
std::reverse(input_polyline.points.begin(), input_polyline.points.end());
// get_remain_path
if (end_pt_idx < input_polyline.points.size()) {
// split at index or split at corr length
Polyline p1, p2; Polyline p1, p2;
Point & split_point = splited_path.back().polyline.points.back();
this_path.polyline.split_at(split_point, &p1, &p2);
if (!split_from_left) { if (!split_from_left) {
input_polyline.split_at_length(input_polyline.length() - smooth_length_count, &p1, &p2);
this_path.polyline = p1; this_path.polyline = p1;
std::reverse(splited_path.begin(), splited_path.end());
for (ExtrusionPath &path : splited_path) { std::reverse(path.polyline.points.begin(), path.polyline.points.end()); }
} else { } else {
input_polyline.split_at_length(smooth_length_count, &p1, &p2);
this_path.polyline = p2; this_path.polyline = p2;
} }
} else {
this_path.polyline.clear();
}
// reverse paths if this start from right
if (!split_from_left)
std::reverse(splited_path.begin(), splited_path.end());
return splited_path; return splited_path;
} }