From 8723b6987d747a971c40566a38d2983a629380dc Mon Sep 17 00:00:00 2001 From: "jiangkai.zhao" Date: Mon, 20 Jan 2025 16:20:49 +0800 Subject: [PATCH] ENH: enhance some functions of the wipe_tower MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.Add automatic calculation of the wipe_tower's brim width by height; 2.modify the min_depth_per_height and the default ridwidth jira: none Change-Id: Idd96bc90e8e631aa8481b559e1e9fec24c6b822f (cherry picked from commit 4dd4e9e12c02d945a0ac3fd2020f75313c5b2cc9) --- .../0.10mm Standard @BBL H2D 0.2 nozzle.json | 1 + .../BBL/process/0.20mm Standard @BBL H2D.json | 1 + .../0.30mm Standard @BBL H2D 0.6 nozzle.json | 1 + .../0.40mm Standard @BBL H2D 0.8 nozzle.json | 1 + src/OrcaSlicer.cpp | 2 ++ src/libslic3r/GCode/WipeTower.cpp | 21 ++++++++++++------- src/libslic3r/GCode/WipeTower.hpp | 1 + src/libslic3r/Print.cpp | 19 ++++++++--------- src/libslic3r/PrintConfig.cpp | 6 +++--- src/slic3r/GUI/GLCanvas3D.cpp | 2 ++ src/slic3r/GUI/PartPlate.cpp | 1 + 11 files changed, 36 insertions(+), 20 deletions(-) diff --git a/resources/profiles/BBL/process/0.10mm Standard @BBL H2D 0.2 nozzle.json b/resources/profiles/BBL/process/0.10mm Standard @BBL H2D 0.2 nozzle.json index 355d88d6d1..7bb487fb55 100644 --- a/resources/profiles/BBL/process/0.10mm Standard @BBL H2D 0.2 nozzle.json +++ b/resources/profiles/BBL/process/0.10mm Standard @BBL H2D 0.2 nozzle.json @@ -9,6 +9,7 @@ "default_acceleration": "8000", "initial_layer_speed": "40", "prime_tower_width": "60", + "prime_tower_brim_width": "-1", "travel_speed": "1000", "compatible_printers": [ "Bambu Lab H2D 0.2 nozzle" diff --git a/resources/profiles/BBL/process/0.20mm Standard @BBL H2D.json b/resources/profiles/BBL/process/0.20mm Standard @BBL H2D.json index 21c8679f54..efa68fd5a5 100644 --- a/resources/profiles/BBL/process/0.20mm Standard @BBL H2D.json +++ b/resources/profiles/BBL/process/0.20mm Standard @BBL H2D.json @@ -11,6 +11,7 @@ "internal_solid_infill_speed": "250", "outer_wall_speed": "200", "prime_tower_width": "60", + "prime_tower_brim_width": "-1", "sparse_infill_speed": "350", "travel_speed": "1000", "compatible_printers": [ diff --git a/resources/profiles/BBL/process/0.30mm Standard @BBL H2D 0.6 nozzle.json b/resources/profiles/BBL/process/0.30mm Standard @BBL H2D 0.6 nozzle.json index df24c0f134..7070135646 100644 --- a/resources/profiles/BBL/process/0.30mm Standard @BBL H2D 0.6 nozzle.json +++ b/resources/profiles/BBL/process/0.30mm Standard @BBL H2D 0.6 nozzle.json @@ -16,6 +16,7 @@ "outer_wall_speed": "200", "overhang_3_4_speed": "30", "prime_tower_width": "60", + "prime_tower_brim_width": "-1", "sparse_infill_speed": "350", "top_surface_speed": "200", "travel_speed": "1000", diff --git a/resources/profiles/BBL/process/0.40mm Standard @BBL H2D 0.8 nozzle.json b/resources/profiles/BBL/process/0.40mm Standard @BBL H2D 0.8 nozzle.json index a9dd7e9883..8c4a4b08f8 100644 --- a/resources/profiles/BBL/process/0.40mm Standard @BBL H2D 0.8 nozzle.json +++ b/resources/profiles/BBL/process/0.40mm Standard @BBL H2D 0.8 nozzle.json @@ -17,6 +17,7 @@ "overhang_3_4_speed": "30", "overhang_4_4_speed": "10", "prime_tower_width": "60", + "prime_tower_brim_width": "-1", "sparse_infill_speed": "350", "top_surface_speed": "200", "travel_speed": "1000", diff --git a/src/OrcaSlicer.cpp b/src/OrcaSlicer.cpp index ea9d7c0159..e087106c99 100644 --- a/src/OrcaSlicer.cpp +++ b/src/OrcaSlicer.cpp @@ -3492,6 +3492,7 @@ int CLI::run(int argc, char **argv) ConfigOptionFloat* brim_width_option = print_config.option("prime_tower_brim_width", true); float brim_width = brim_width_option->value; + if (brim_width < 0) brim_width = WipeTower::get_auto_brim_by_height((float)plate_obj_size_info.obj_bbox.max.z()); ConfigOptionFloat* volume_option = print_config.option("prime_volume", true); float wipe_volume = volume_option->value; @@ -4591,6 +4592,7 @@ int CLI::run(int argc, char **argv) ConfigOption *wipe_tower_brim_width_opt = m_print_config.option("prime_tower_brim_width"); if (wipe_tower_brim_width_opt ) { wp_brim_width = wipe_tower_brim_width_opt->getFloat(); + if (wp_brim_width < 0) wp_brim_width = WipeTower::get_auto_brim_by_height((float) wipe_tower_size.z()); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("arrange wipe_tower: wp_brim_width %1%")%wp_brim_width; } diff --git a/src/libslic3r/GCode/WipeTower.cpp b/src/libslic3r/GCode/WipeTower.cpp index 3816e07a15..4fff6c07fa 100644 --- a/src/libslic3r/GCode/WipeTower.cpp +++ b/src/libslic3r/GCode/WipeTower.cpp @@ -15,7 +15,6 @@ namespace Slic3r { static const double wipe_tower_wall_infill_overlap = 0.0; -static const double wipe_tower_wall_infill_overlap_new = -0.2; static constexpr double WIPE_TOWER_RESOLUTION = 0.0375; #define SCALED_WIPE_TOWER_RESOLUTION (WIPE_TOWER_RESOLUTION / SCALING_FACTOR) inline float align_round(float value, float base) @@ -1275,7 +1274,7 @@ WipeTower::ToolChangeResult WipeTower::construct_block_tcr(WipeTowerWriter &writ // BBS const std::map WipeTower::min_depth_per_height = { - {10.f, 10.f}, {100.f, 20.f}, {180.f, 40.f}, {250.f, 50.f}, {350.f, 60.f} + {0.f,0.f}, {100.f, 20.f}, {180.f, 40.f}, {250.f, 50.f}, {350.f, 60.f} }; float WipeTower::get_limit_depth_by_height(float max_height) @@ -1314,6 +1313,11 @@ float WipeTower::get_limit_depth_by_height(float max_height) return min_wipe_tower_depth; } +float WipeTower::get_auto_brim_by_height(float max_height) { + if (max_height < 100) return max_height/100.f * 8.f; + return 8.f; +} + WipeTower::WipeTower(const PrintConfig& config, int plate_idx, Vec3d plate_origin, const float prime_volume, size_t initial_tool, const float wipe_tower_height) : m_semm(config.single_extruder_multi_material.value), m_wipe_tower_pos(config.wipe_tower_x.get_at(plate_idx), config.wipe_tower_y.get_at(plate_idx)), @@ -1471,7 +1475,8 @@ Vec2f WipeTower::get_next_pos(const WipeTower::box_coordinates &cleaning_box, fl Vec2f res; int index = m_cur_layer_id % 4; - Vec2f offset = m_use_gap_wall ? Vec2f(5 * m_perimeter_width, 0) : Vec2f{0, 0}; + //Vec2f offset = m_use_gap_wall ? Vec2f(5 * m_perimeter_width, 0) : Vec2f{0, 0}; + Vec2f offset = Vec2f{0, 0}; switch (index % 4) { case 0: res = offset +cleaning_box.ld + pos_offset; @@ -2700,6 +2705,7 @@ WipeTower::NozzleChangeResult WipeTower::nozzle_change_new(int old_filament_id, } float nozzle_change_speed = 60.0f * m_filpar[m_current_tool].max_e_speed / m_extrusion_flow; + //float nozzle_change_speed = is_first_layer() ? std::min(m_first_layer_speed * 60.f, 4800.f) : 4800.f; if (is_tpu_filament(m_current_tool)) { nozzle_change_speed *= 0.25; } @@ -3195,23 +3201,23 @@ void WipeTower::toolchange_wipe_new(WipeTowerWriter &writer, const box_coordinat float ironing_length = 3.; if (i == 0 && m_use_gap_wall) { // BBS: add ironing after extruding start if (m_left_to_right) { - float dx = xr + wipe_tower_wall_infill_overlap_new * m_perimeter_width - writer.pos().x(); + float dx = xr + wipe_tower_wall_infill_overlap * m_perimeter_width - writer.pos().x(); if (abs(dx) < ironing_length) ironing_length = abs(dx); writer.extrude(writer.x() + ironing_length, writer.y(), wipe_speed); writer.retract(retract_length, retract_speed); writer.travel(writer.x() - 1.5 * ironing_length, writer.y(), 600.); writer.travel(writer.x() + 1.5 * ironing_length, writer.y(), 240.); writer.retract(-retract_length, retract_speed); - writer.extrude(xr + wipe_tower_wall_infill_overlap_new * m_perimeter_width, writer.y(), wipe_speed); + writer.extrude(xr + wipe_tower_wall_infill_overlap * m_perimeter_width, writer.y(), wipe_speed); } else { - float dx = xl - wipe_tower_wall_infill_overlap_new * m_perimeter_width - writer.pos().x(); + float dx = xl - wipe_tower_wall_infill_overlap * m_perimeter_width - writer.pos().x(); if (abs(dx) < ironing_length) ironing_length = abs(dx); writer.extrude(writer.x() - ironing_length, writer.y(), wipe_speed); writer.retract(retract_length, retract_speed); writer.travel(writer.x() + 1.5 * ironing_length, writer.y(), 600.); writer.travel(writer.x() - 1.5 * ironing_length, writer.y(), 240.); writer.retract(-retract_length, retract_speed); - writer.extrude(xl - wipe_tower_wall_infill_overlap_new * m_perimeter_width, writer.y(), wipe_speed); + writer.extrude(xl - wipe_tower_wall_infill_overlap * m_perimeter_width, writer.y(), wipe_speed); } } else { if (m_left_to_right) @@ -3433,6 +3439,7 @@ void WipeTower::generate_wipe_tower_blocks() void WipeTower::plan_tower_new() { + if (m_wipe_tower_brim_width < 0) m_wipe_tower_brim_width = get_auto_brim_by_height(m_wipe_tower_height); if (m_use_rib_wall) { // recalculate wipe_tower_with and layer's depth generate_wipe_tower_blocks(); diff --git a/src/libslic3r/GCode/WipeTower.hpp b/src/libslic3r/GCode/WipeTower.hpp index a6dd1dc67e..2a2a57c56d 100644 --- a/src/libslic3r/GCode/WipeTower.hpp +++ b/src/libslic3r/GCode/WipeTower.hpp @@ -26,6 +26,7 @@ public: // WipeTower height to minimum depth map static const std::map min_depth_per_height; static float get_limit_depth_by_height(float max_height); + static float get_auto_brim_by_height(float max_height); struct Extrusion { diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index f1a313a3a8..bd9e324291 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -2801,18 +2801,17 @@ bool Print::has_wipe_tower() const const WipeTowerData &Print::wipe_tower_data(size_t filaments_cnt) const { // If the wipe tower wasn't created yet, make sure the depth and brim_width members are set to default. - if (!is_step_done(psWipeTower) && filaments_cnt != 0) { + double max_height = 0; + for (size_t obj_idx = 0; obj_idx < m_objects.size(); obj_idx++) { + double object_z = (double) m_objects[obj_idx]->size().z(); + max_height = std::max(unscale_(object_z), max_height); + } + if (max_height < EPSILON) return m_wipe_tower_data; + + if (! is_step_done(psWipeTower) && filaments_cnt !=0) { if (m_config.prime_tower_rib_wall.value) { double layer_height = 0.08f; // hard code layer height double wipe_volume = m_config.prime_volume; - double max_height = 0; - for (size_t obj_idx = 0; obj_idx < m_objects.size(); obj_idx++) { - double object_z = (double) m_objects[obj_idx]->size().z(); - max_height = std::max(unscale_(object_z), max_height); - } - if (max_height < EPSILON) - return m_wipe_tower_data; - layer_height = m_objects.front()->config().layer_height.value; int filament_depth_count = m_config.nozzle_diameter.values.size() == 2 ? filaments_cnt : filaments_cnt - 1; if (filaments_cnt == 1 && enable_timelapse_print()) @@ -2852,7 +2851,7 @@ const WipeTowerData &Print::wipe_tower_data(size_t filaments_cnt) const const_cast(this)->m_wipe_tower_data.brim_width = m_config.prime_tower_brim_width; } } - + if (m_config.prime_tower_brim_width < 0 ) const_cast(this)->m_wipe_tower_data.brim_width = WipeTower::get_auto_brim_by_height(max_height); return m_wipe_tower_data; } diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 0b635d1ad4..2ef76ac791 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -5938,10 +5938,10 @@ void PrintConfigDef::init_fff_params() def = this->add("prime_tower_brim_width", coFloat); def->label = L("Brim width"); - def->tooltip = L("Width of the brim."); + def->tooltip = L("Brim width, -1 means the brim width is automatically calculated based on the height "); def->sidetext = "mm"; // milimeters, don't need translation def->mode = comAdvanced; - def->min = 0.; + def->min = -1; def->set_default_value(new ConfigOptionFloat(3.)); def = this->add("wipe_tower_cone_angle", coFloat); @@ -6038,7 +6038,7 @@ void PrintConfigDef::init_fff_params() def->sidetext = L("mm"); def->mode = comAdvanced; def->min = 0; - def->set_default_value(new ConfigOptionFloat(4)); + def->set_default_value(new ConfigOptionFloat(8)); def = this->add("prime_tower_skip_points", coBool); def->label = L("Skip points"); diff --git a/src/slic3r/GUI/GLCanvas3D.cpp b/src/slic3r/GUI/GLCanvas3D.cpp index 9c71f4241a..a630d03979 100644 --- a/src/slic3r/GUI/GLCanvas3D.cpp +++ b/src/slic3r/GUI/GLCanvas3D.cpp @@ -5313,10 +5313,12 @@ GLCanvas3D::WipeTowerInfo GLCanvas3D::get_wipe_tower_info(int plate_idx) const float wt_brim_width = preset.config.opt_float("prime_tower_brim_width"); const BoundingBoxf3& bb = vol->bounding_box(); + if (wt_brim_width < 0) wt_brim_width = WipeTower::get_auto_brim_by_height((float)bb.max.z()); wti.m_bb = BoundingBoxf{to_2d(bb.min), to_2d(bb.max)}; wti.m_bb.offset(wt_brim_width); float brim_width = wxGetApp().preset_bundle->prints.get_edited_preset().config.opt_float("prime_tower_brim_width"); + if (brim_width < 0) brim_width = WipeTower::get_auto_brim_by_height((float) bb.max.z()); wti.m_bb.offset((brim_width)); // BBS: the wipe tower pos might be outside bed diff --git a/src/slic3r/GUI/PartPlate.cpp b/src/slic3r/GUI/PartPlate.cpp index d875be8ac6..12a7670fb5 100644 --- a/src/slic3r/GUI/PartPlate.cpp +++ b/src/slic3r/GUI/PartPlate.cpp @@ -1929,6 +1929,7 @@ arrangement::ArrangePolygon PartPlate::estimate_wipe_tower_polygon(const Dynamic const ConfigOption* wipe_tower_brim_width_opt = config.option("prime_tower_brim_width"); if (wipe_tower_brim_width_opt) { wp_brim_width = wipe_tower_brim_width_opt->getFloat(); + if (wp_brim_width < 0) wp_brim_width = WipeTower::get_auto_brim_by_height((float) wipe_tower_size.z()); BOOST_LOG_TRIVIAL(info) << __FUNCTION__ << boost::format("arrange wipe_tower: wp_brim_width %1%") % wp_brim_width; }