ENH: cut travel before wipe

Signed-off-by: qing.zhang <qing.zhang@bambulab.com>
Change-Id: I3b5dfc19c601e0cd72a4fd7fe320791f1d10c87b
This commit is contained in:
qing.zhang 2023-01-10 17:04:55 +08:00 committed by Lane.Wei
parent df84229adb
commit a726628657
3 changed files with 38 additions and 37 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "Bambulab", "name": "Bambulab",
"url": "http://www.bambulab.com/Parameters/vendor/BBL.json", "url": "http://www.bambulab.com/Parameters/vendor/BBL.json",
"version": "01.05.00.09", "version": "01.05.00.10",
"force_update": "0", "force_update": "0",
"description": "the initial version of BBL configurations", "description": "the initial version of BBL configurations",
"machine_model_list": [ "machine_model_list": [

View file

@ -125,7 +125,7 @@
"1" "1"
], ],
"retract_before_wipe": [ "retract_before_wipe": [
"70%" "0%"
], ],
"retract_when_changing_layer": [ "retract_when_changing_layer": [
"1" "1"

View file

@ -3290,44 +3290,45 @@ std::string GCode::extrude_loop(ExtrusionLoop loop, std::string description, dou
} }
} }
// make a little move inwards before leaving loop //BBS. move the travel path before wipe to improve the seam
if (paths.back().role() == erExternalPerimeter && m_layer != NULL && m_config.wall_loops.value > 1 && paths.front().size() >= 2 && paths.back().polyline.points.size() >= 3) { //// make a little move inwards before leaving loop
// detect angle between last and first segment //if (paths.back().role() == erExternalPerimeter && m_layer != NULL && m_config.wall_loops.value > 1 && paths.front().size() >= 2 && paths.back().polyline.points.size() >= 3) {
// the side depends on the original winding order of the polygon (left for contours, right for holes) // // detect angle between last and first segment
//FIXME improve the algorithm in case the loop is tiny. // // the side depends on the original winding order of the polygon (left for contours, right for holes)
//FIXME improve the algorithm in case the loop is split into segments with a low number of points (see the Point b query). // //FIXME improve the algorithm in case the loop is tiny.
Point a = paths.front().polyline.points[1]; // second point // //FIXME improve the algorithm in case the loop is split into segments with a low number of points (see the Point b query).
Point b = *(paths.back().polyline.points.end()-3); // second to last point // Point a = paths.front().polyline.points[1]; // second point
if (was_clockwise) { // Point b = *(paths.back().polyline.points.end()-3); // second to last point
// swap points // if (was_clockwise) {
Point c = a; a = b; b = c; // // swap points
} // Point c = a; a = b; b = c;
// }
double angle = paths.front().first_point().ccw_angle(a, b) / 3; // double angle = paths.front().first_point().ccw_angle(a, b) / 3;
// turn left if contour, turn right if hole // // turn left if contour, turn right if hole
if (was_clockwise) angle *= -1; // if (was_clockwise) angle *= -1;
// create the destination point along the first segment and rotate it // // create the destination point along the first segment and rotate it
// we make sure we don't exceed the segment length because we don't know // // we make sure we don't exceed the segment length because we don't know
// the rotation of the second segment so we might cross the object boundary // // the rotation of the second segment so we might cross the object boundary
Vec2d p1 = paths.front().polyline.points.front().cast<double>(); // Vec2d p1 = paths.front().polyline.points.front().cast<double>();
Vec2d p2 = paths.front().polyline.points[1].cast<double>(); // Vec2d p2 = paths.front().polyline.points[1].cast<double>();
Vec2d v = p2 - p1; // Vec2d v = p2 - p1;
double nd = scale_(EXTRUDER_CONFIG(nozzle_diameter)); // double nd = scale_(EXTRUDER_CONFIG(nozzle_diameter));
double l2 = v.squaredNorm(); // double l2 = v.squaredNorm();
// Shift by no more than a nozzle diameter. // // Shift by no more than a nozzle diameter.
//FIXME Hiding the seams will not work nicely for very densely discretized contours! // //FIXME Hiding the seams will not work nicely for very densely discretized contours!
//BBS. shorten the travel distant before the wipe path // //BBS. shorten the travel distant before the wipe path
double threshold = 0.2; // double threshold = 0.2;
Point pt = (p1 + v * threshold).cast<coord_t>(); // Point pt = (p1 + v * threshold).cast<coord_t>();
if (nd * nd < l2) // if (nd * nd < l2)
pt = (p1 + threshold * v * (nd / sqrt(l2))).cast<coord_t>(); // pt = (p1 + threshold * v * (nd / sqrt(l2))).cast<coord_t>();
//Point pt = ((nd * nd >= l2) ? (p1+v*0.4): (p1 + 0.2 * v * (nd / sqrt(l2)))).cast<coord_t>(); // //Point pt = ((nd * nd >= l2) ? (p1+v*0.4): (p1 + 0.2 * v * (nd / sqrt(l2)))).cast<coord_t>();
pt.rotate(angle, paths.front().polyline.points.front()); // pt.rotate(angle, paths.front().polyline.points.front());
// generate the travel move // // generate the travel move
gcode += m_writer.travel_to_xy(this->point_to_gcode(pt), "move inwards before travel"); // gcode += m_writer.travel_to_xy(this->point_to_gcode(pt), "move inwards before travel");
} //}
return gcode; return gcode;
} }