Add direct adaptive bed mesh support (#4212)

* Add direct adaptive bed mesh support

* fix Linux build error

* update tooltip
This commit is contained in:
SoftFever 2024-02-24 20:44:00 +08:00 committed by GitHub
parent ab2aaefe42
commit 2c279c5648
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 74 additions and 3 deletions

View file

@ -1,4 +1,5 @@
#include "BoundingBox.hpp"
#include "Config.hpp"
#include "Polygon.hpp"
#include "PrintConfig.hpp"
#include "libslic3r.h"
@ -21,6 +22,7 @@
#include "Time.hpp"
#include "GCode/ExtrusionProcessor.hpp"
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <chrono>
#include <iostream>
@ -2322,7 +2324,25 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato
this->placeholder_parser().set("first_layer_print_min", new ConfigOptionFloats({bbox.min.x(), bbox.min.y()}));
this->placeholder_parser().set("first_layer_print_max", new ConfigOptionFloats({bbox.max.x(), bbox.max.y()}));
this->placeholder_parser().set("first_layer_print_size", new ConfigOptionFloats({ bbox.size().x(), bbox.size().y() }));
this->placeholder_parser().set("in_head_wrap_detect_zone",bbox_head_wrap_zone.overlap(bbox));
BoundingBoxf mesh_bbox(m_config.bed_mesh_min, m_config.bed_mesh_max);
auto mesh_margin = m_config.adaptive_bed_mesh_margin.value;
mesh_bbox.min = mesh_bbox.min.cwiseMax((bbox.min.array() - mesh_margin).matrix());
mesh_bbox.max = mesh_bbox.max.cwiseMin((bbox.max.array() + mesh_margin).matrix());
this->placeholder_parser().set("adaptive_bed_mesh_min", new ConfigOptionFloats({mesh_bbox.min.x(), mesh_bbox.min.y()}));
this->placeholder_parser().set("adaptive_bed_mesh_max", new ConfigOptionFloats({mesh_bbox.max.x(), mesh_bbox.max.y()}));
auto probe_dist_x = std::max(1., m_config.bed_mesh_probe_distance.value.x());
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) {
bed_mesh_algo = "lagrange";
}
this->placeholder_parser().set("bed_mesh_algo", bed_mesh_algo);
this->placeholder_parser().set("in_head_wrap_detect_zone",probe_count_y);
// get center without wipe tower
BoundingBoxf bbox_wo_wt; // bounding box without wipe tower
for (auto &objPtr : print.objects()) {

View file

@ -881,7 +881,7 @@ static std::vector<std::string> s_Preset_printer_options {
"cooling_tube_retraction",
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "purge_in_prime_tower", "enable_filament_ramming",
"z_offset",
"disable_m73", "preferred_orientation", "emit_machine_limits_to_gcode", "support_multi_bed_types"
"disable_m73", "preferred_orientation", "emit_machine_limits_to_gcode", "support_multi_bed_types","bed_mesh_min","bed_mesh_max","bed_mesh_probe_distance", "adaptive_bed_mesh_margin"
};
static std::vector<std::string> s_Preset_sla_print_options {

View file

@ -1550,6 +1550,42 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(40));
def = this->add("bed_mesh_min", coPoint);
def->label = L("Bed mesh min");
def->tooltip = L(
"This option sets the min point for the allowed bed mesh area. Due to the probe's XY offset, most printers are unable to probe the "
"entire bed. To ensure the probe point does not go outside the bed area, the minimum and maximum points of the bed mesh should be "
"set appropriately. OrcaSlicer ensures that adaptive_bed_mesh_min/adaptive_bed_mesh_max values do not exceed these min/max "
"points. This information can usually be obtained from your printer manufacturer. The default setting is (-99999, -99999), which "
"means there are no limits, thus allowing probing across the entire bed.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPoint(Vec2d(-99999, -99999)));
def = this->add("bed_mesh_max", coPoint);
def->label = L("Bed mesh max");
def->tooltip = L(
"This option sets the max point for the allowed bed mesh area. Due to the probe's XY offset, most printers are unable to probe the "
"entire bed. To ensure the probe point does not go outside the bed area, the minimum and maximum points of the bed mesh should be "
"set appropriately. OrcaSlicer ensures that adaptive_bed_mesh_min/adaptive_bed_mesh_max values do not exceed these min/max "
"points. This information can usually be obtained from your printer manufacturer. The default setting is (99999, 99999), which "
"means there are no limits, thus allowing probing across the entire bed.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPoint(Vec2d(99999, 99999)));
def = this->add("bed_mesh_probe_distance", coPoint);
def->label = L("Probe point distance");
def->tooltip = L("This option sets the preferred distance between probe points (grid size) for the X and Y directions, with the "
"default being 50mm for both X and Y.");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionPoint(Vec2d(50, 50)));
def = this->add("adaptive_bed_mesh_margin", coFloat);
def->label = L("Mesh margin");
def->tooltip = L("This option determines the additional distance by which the adaptive bed mesh area should be expanded in the XY directions.");
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(0));
def = this->add("extruder_colour", coStrings);
def->label = L("Extruder Color");
def->tooltip = L("Only used as a visual help on UI");

View file

@ -1224,7 +1224,12 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE(
((ConfigOptionBools, activate_chamber_temp_control))
((ConfigOptionInts , chamber_temperature))
// Orca: support adaptive bed mesh
((ConfigOptionFloat, preferred_orientation))
((ConfigOptionPoint, bed_mesh_min))
((ConfigOptionPoint, bed_mesh_max))
((ConfigOptionPoint, bed_mesh_probe_distance))
((ConfigOptionFloat, adaptive_bed_mesh_margin))
)

View file

@ -1156,7 +1156,11 @@ bool PrintObject::invalidate_state_by_config_options(
|| opt_key == "sparse_infill_speed"
|| opt_key == "inner_wall_speed"
|| opt_key == "internal_solid_infill_speed"
|| opt_key == "top_surface_speed") {
|| opt_key == "top_surface_speed"
|| opt_key == "bed_mesh_min"
|| opt_key == "bed_mesh_max"
|| opt_key == "adaptive_bed_mesh_margin"
|| opt_key == "bed_mesh_probe_distance") {
invalidated |= m_print->invalidate_step(psGCodeExport);
} else if (
opt_key == "flush_into_infill"

View file

@ -3561,6 +3561,12 @@ void TabPrinter::build_fff()
optgroup->append_single_option_line("extruder_clearance_height_to_rod");
optgroup->append_single_option_line("extruder_clearance_height_to_lid");
optgroup = page->new_optgroup(L("Adaptive bed mesh"));
optgroup->append_single_option_line("bed_mesh_min", "adaptive_bed_mesh");
optgroup->append_single_option_line("bed_mesh_max", "adaptive_bed_mesh");
optgroup->append_single_option_line("bed_mesh_probe_distance", "adaptive_bed_mesh");
optgroup->append_single_option_line("adaptive_bed_mesh_margin", "adaptive_bed_mesh");
optgroup = page->new_optgroup(L("Accessory") /*, L"param_accessory"*/);
optgroup->append_single_option_line("nozzle_type");
optgroup->append_single_option_line("nozzle_hrc");