From 3df89779240462982b7ebb45c8d8910d28a3f55e Mon Sep 17 00:00:00 2001 From: igiannakas Date: Tue, 7 May 2024 21:34:03 +0100 Subject: [PATCH 1/4] Fix bed mesh algorithm for 3 point bicubic algorightm --- src/libslic3r/GCode.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index fc368eeca55..0e5141ce2ca 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2352,11 +2352,17 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato auto probe_dist_y = std::max(1., m_config.bed_mesh_probe_distance.value.y()); int probe_count_x = std::max(3, (int) std::ceil(mesh_bbox.size().x() / probe_dist_x)); int probe_count_y = std::max(3, (int) std::ceil(mesh_bbox.size().y() / probe_dist_y)); - this->placeholder_parser().set("bed_mesh_probe_count", new ConfigOptionInts({probe_count_x, probe_count_y})); auto bed_mesh_algo = "bicubic"; - if (probe_count_x < 4 || probe_count_y < 4) { + int min_points = 4; // bicubic needs 4 probe points per axis + if (probe_count_x + probe_count_y <= 6) { // lagrange needs up to a total of 6 mesh points bed_mesh_algo = "lagrange"; + min_points = 3; + } + if(print.config().gcode_flavor == gcfKlipper){ + probe_count_x = std::max(probe_count_x,min_points); + probe_count_y = std::max(probe_count_y,min_points); } + this->placeholder_parser().set("bed_mesh_probe_count", new ConfigOptionInts({probe_count_x, probe_count_y})); this->placeholder_parser().set("bed_mesh_algo", bed_mesh_algo); // get center without wipe tower BoundingBoxf bbox_wo_wt; // bounding box without wipe tower From 642e2419a60120317075d612269b487b1979a99e Mon Sep 17 00:00:00 2001 From: igiannakas Date: Wed, 8 May 2024 16:43:46 +0100 Subject: [PATCH 2/4] Corrected + to * --- src/libslic3r/GCode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 0e5141ce2ca..2c9920dde7d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2354,7 +2354,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato int probe_count_y = std::max(3, (int) std::ceil(mesh_bbox.size().y() / probe_dist_y)); auto bed_mesh_algo = "bicubic"; int min_points = 4; // bicubic needs 4 probe points per axis - if (probe_count_x + probe_count_y <= 6) { // lagrange needs up to a total of 6 mesh points + if (probe_count_x * probe_count_y <= 6) { // lagrange needs up to a total of 6 mesh points bed_mesh_algo = "lagrange"; min_points = 3; } From 760b4877fb5ec96c3851e056faf74adda46567ab Mon Sep 17 00:00:00 2001 From: igiannakas Date: Wed, 8 May 2024 16:50:55 +0100 Subject: [PATCH 3/4] Amended algo to mirror KAMP --- src/libslic3r/GCode.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 2c9920dde7d..7339bf6da6a 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2354,7 +2354,7 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato int probe_count_y = std::max(3, (int) std::ceil(mesh_bbox.size().y() / probe_dist_y)); auto bed_mesh_algo = "bicubic"; int min_points = 4; // bicubic needs 4 probe points per axis - if (probe_count_x * probe_count_y <= 6) { // lagrange needs up to a total of 6 mesh points + if (std::max(probe_count_x, probe_count_y) <= 6) { // lagrange needs up to a total of 6 mesh points bed_mesh_algo = "lagrange"; min_points = 3; } From 1ce041e105b62c5a68475106367b9854df21a9a5 Mon Sep 17 00:00:00 2001 From: igiannakas Date: Wed, 8 May 2024 17:56:46 +0100 Subject: [PATCH 4/4] Updated from feedbacl --- src/libslic3r/GCode.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 7339bf6da6a..f65fabe5aad 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2353,15 +2353,15 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato int probe_count_x = std::max(3, (int) std::ceil(mesh_bbox.size().x() / probe_dist_x)); int probe_count_y = std::max(3, (int) std::ceil(mesh_bbox.size().y() / probe_dist_y)); auto bed_mesh_algo = "bicubic"; - int min_points = 4; // bicubic needs 4 probe points per axis - if (std::max(probe_count_x, probe_count_y) <= 6) { // lagrange needs up to a total of 6 mesh points + if (probe_count_x * probe_count_y <= 6) { // lagrange needs up to a total of 6 mesh points bed_mesh_algo = "lagrange"; - min_points = 3; - } - if(print.config().gcode_flavor == gcfKlipper){ - probe_count_x = std::max(probe_count_x,min_points); - probe_count_y = std::max(probe_count_y,min_points); } + else + if(print.config().gcode_flavor == gcfKlipper){ + // bicubic needs 4 probe points per axis + probe_count_x = std::max(probe_count_x,4); + probe_count_y = std::max(probe_count_y,4); + } this->placeholder_parser().set("bed_mesh_probe_count", new ConfigOptionInts({probe_count_x, probe_count_y})); this->placeholder_parser().set("bed_mesh_algo", bed_mesh_algo); // get center without wipe tower