diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index d56a971ad0..92230a48ed 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -5177,6 +5177,25 @@ double GCode::get_overhang_degree_corr_speed(float normal_speed, double path_deg return speed_out; } +bool GCode::_needSAFC(const ExtrusionPath &path) +{ + if (!m_small_area_infill_flow_compensator || !m_config.small_area_infill_flow_compensation.value) + return false; + + static const InfillPattern supported_patterns[] = { + InfillPattern::ipRectilinear, + InfillPattern::ipAlignedRectilinear, + InfillPattern::ipMonotonic, + InfillPattern::ipMonotonicLine, + }; + + return std::any_of(std::begin(supported_patterns), std::end(supported_patterns), [&](const InfillPattern pattern) { + return this->on_first_layer() && this->config().bottom_surface_pattern == pattern || + path.role() == erSolidInfill && this->config().internal_solid_infill_pattern == pattern || + path.role() == erTopSolidInfill && this->config().top_surface_pattern == pattern; + }); +} + std::string GCode::_extrude(const ExtrusionPath &path, std::string description, double speed) { std::string gcode; @@ -5731,8 +5750,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, continue; path_length += line_length; auto dE = e_per_mm * line_length; - if (!this->on_first_layer() && m_small_area_infill_flow_compensator - && m_config.small_area_infill_flow_compensation.value) { + if (_needSAFC(path)) { auto oldE = dE; dE = m_small_area_infill_flow_compensator->modify_flow(line_length, dE, path.role()); @@ -5773,8 +5791,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, if (line_length < EPSILON) continue; auto dE = e_per_mm * line_length; - if (!this->on_first_layer() && m_small_area_infill_flow_compensator - && m_config.small_area_infill_flow_compensation.value) { + if (_needSAFC(path)) { auto oldE = dE; dE = m_small_area_infill_flow_compensator->modify_flow(line_length, dE, path.role()); @@ -5797,8 +5814,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, continue; const Vec2d center_offset = this->point_to_gcode(arc.center) - this->point_to_gcode(arc.start_point); auto dE = e_per_mm * arc_length; - if (!this->on_first_layer() && m_small_area_infill_flow_compensator - && m_config.small_area_infill_flow_compensation.value) { + if (_needSAFC(path)) { auto oldE = dE; dE = m_small_area_infill_flow_compensator->modify_flow(arc_length, dE, path.role()); @@ -5952,8 +5968,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description, last_set_speed = F; } auto dE = e_per_mm * line_length; - if (!this->on_first_layer() && m_small_area_infill_flow_compensator - && m_config.small_area_infill_flow_compensation.value) { + if (_needSAFC(path)) { auto oldE = dE; dE = m_small_area_infill_flow_compensator->modify_flow(line_length, dE, path.role()); @@ -6334,7 +6349,8 @@ std::string GCode::retract(bool toolchange, bool is_last_retraction, LiftType li (the extruder might be already retracted fully or partially). We call these methods even if we performed wipe, since this will ensure the entire retraction length is honored in case wipe path was too short. */ - if (role != erTopSolidInfill || EXTRUDER_CONFIG(retract_on_top_layer)) + if ((!this->on_first_layer() || this->config().bottom_surface_pattern != InfillPattern::ipHilbertCurve) && + (role != erTopSolidInfill || this->config().top_surface_pattern != InfillPattern::ipHilbertCurve)) gcode += toolchange ? m_writer.retract_for_toolchange() : m_writer.retract(); gcode += m_writer.reset_e(); diff --git a/src/libslic3r/GCode.hpp b/src/libslic3r/GCode.hpp index b41228059c..749d929dd6 100644 --- a/src/libslic3r/GCode.hpp +++ b/src/libslic3r/GCode.hpp @@ -602,6 +602,7 @@ private: int get_bed_temperature(const int extruder_id, const bool is_first_layer, const BedType bed_type) const; std::string _extrude(const ExtrusionPath &path, std::string description = "", double speed = -1); + bool _needSAFC(const ExtrusionPath &path); double get_overhang_degree_corr_speed(float speed, double path_degree); void print_machine_envelope(GCodeOutputStream &file, Print &print); void _print_first_layer_bed_temperature(GCodeOutputStream &file, Print &print, const std::string &gcode, unsigned int first_printing_extruder_id, bool wait); diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index 89d9773b18..cae5c63dd4 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -150,7 +150,6 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n "retraction_minimum_travel", "retract_before_wipe", "retract_when_changing_layer", - "retract_on_top_layer", "retraction_length", "retract_length_toolchange", "z_hop", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b02f0ad021..6528034fbc 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3993,12 +3993,6 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionBools { false }); - def = this->add("retract_on_top_layer", coBools); - def->label = L("Retract on top layer"); - def->tooltip = L("Force a retraction on top layer. Disabling could prevent clog on very slow patterns with small movements, like Hilbert curve."); - def->mode = comAdvanced; - def->set_default_value(new ConfigOptionBools { true }); - def = this->add("retraction_length", coFloats); def->label = L("Length"); def->full_label = L("Retraction Length"); @@ -5745,7 +5739,7 @@ void PrintConfigDef::init_fff_params() // BBS: floats "wipe_distance", // bools - "retract_when_changing_layer", "retract_on_top_layer", "wipe", + "retract_when_changing_layer", "wipe", // percents "retract_before_wipe", "long_retractions_when_cut", @@ -5797,7 +5791,7 @@ void PrintConfigDef::init_extruder_option_keys() "nozzle_diameter", "min_layer_height", "max_layer_height", "extruder_offset", "retraction_length", "z_hop", "z_hop_types", "travel_slope", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", - "retract_when_changing_layer", "retract_on_top_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", + "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "extruder_colour", "default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut" }; @@ -5808,7 +5802,6 @@ void PrintConfigDef::init_extruder_option_keys() "retract_lift_above", "retract_lift_below", "retract_lift_enforce", - "retract_on_top_layer", "retract_restart_extra", "retract_when_changing_layer", "retraction_distances_when_cut", @@ -5830,7 +5823,7 @@ void PrintConfigDef::init_filament_option_keys() "filament_diameter", "min_layer_height", "max_layer_height", "retraction_length", "z_hop", "z_hop_types", "retract_lift_above", "retract_lift_below", "retract_lift_enforce", "retraction_speed", "deretraction_speed", "retract_before_wipe", "retract_restart_extra", "retraction_minimum_travel", "wipe", "wipe_distance", - "retract_when_changing_layer", "retract_on_top_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour", + "retract_when_changing_layer", "retract_length_toolchange", "retract_restart_extra_toolchange", "filament_colour", "default_filament_profile","retraction_distances_when_cut","long_retractions_when_cut"/*,"filament_seam_gap"*/ }; @@ -5843,7 +5836,6 @@ void PrintConfigDef::init_filament_option_keys() "retract_lift_enforce", "retract_restart_extra", "retract_when_changing_layer", - "retract_on_top_layer", "retraction_distances_when_cut", "retraction_length", "retraction_minimum_travel", diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 09f81e7f2b..81e2884f7b 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1295,7 +1295,6 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionFloat, resolution)) ((ConfigOptionFloats, retraction_minimum_travel)) ((ConfigOptionBools, retract_when_changing_layer)) - ((ConfigOptionBools, retract_on_top_layer)) ((ConfigOptionFloat, skirt_distance)) ((ConfigOptionInt, skirt_height)) ((ConfigOptionInt, skirt_loops)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 34b42a8d0a..a486fbefc0 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -4424,7 +4424,6 @@ if (is_marlin_flavor) optgroup->append_single_option_line("deretraction_speed", "", extruder_idx); optgroup->append_single_option_line("retraction_minimum_travel", "", extruder_idx); optgroup->append_single_option_line("retract_when_changing_layer", "", extruder_idx); - optgroup->append_single_option_line("retract_on_top_layer", "", extruder_idx); optgroup->append_single_option_line("wipe", "", extruder_idx); optgroup->append_single_option_line("wipe_distance", "", extruder_idx); optgroup->append_single_option_line("retract_before_wipe", "", extruder_idx); @@ -4644,7 +4643,7 @@ void TabPrinter::toggle_options() // user can customize other retraction options if retraction is enabled //BBS bool retraction = have_retract_length || use_firmware_retraction; - std::vector vec = {"z_hop", "retract_when_changing_layer", "retract_on_top_layer"}; + std::vector vec = {"z_hop", "retract_when_changing_layer"}; for (auto el : vec) toggle_option(el, retraction, i);