diff --git a/src/libslic3r/GCode/SpiralVase.cpp b/src/libslic3r/GCode/SpiralVase.cpp index 8ffe7ef95..908411f9c 100644 --- a/src/libslic3r/GCode/SpiralVase.cpp +++ b/src/libslic3r/GCode/SpiralVase.cpp @@ -121,9 +121,13 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer) // layer. bool transition_in = m_transition_layer && m_config.use_relative_e_distances.value; bool transition_out = last_layer && m_config.use_relative_e_distances.value; + + float starting_flowrate = float(m_config.spiral_starting_flow_ratio.value); + float finishing_flowrate = float(m_config.spiral_finishing_flow_ratio.value); + float len = 0.f; SpiralVase::SpiralPoint last_point = previous_layer != NULL && previous_layer->size() >0? previous_layer->at(previous_layer->size()-1): SpiralVase::SpiralPoint(0,0); - m_reader.parse_buffer(gcode, [&new_gcode, &z, total_layer_length, layer_height, transition_in, &len, ¤t_layer, &previous_layer, &transition_gcode, transition_out, smooth_spiral, &max_xy_dist_for_smoothing, &last_point] + m_reader.parse_buffer(gcode, [&new_gcode, &z, total_layer_length, layer_height, transition_in, &len, ¤t_layer, &previous_layer, &transition_gcode, transition_out, smooth_spiral, &max_xy_dist_for_smoothing, &last_point, starting_flowrate, finishing_flowrate] (GCodeReader &reader, GCodeReader::GCodeLine line) { if (line.cmd_is("G1")) { // Orca: Filter out retractions at layer change @@ -140,15 +144,18 @@ std::string SpiralVase::process_layer(const std::string &gcode, bool last_layer) if (dist_XY > 0 && line.extruding(reader)) { // Exclude wipe and retract len += dist_XY; float factor = len / total_layer_length; - if (transition_in) - // Transition layer, interpolate the amount of extrusion from zero to the final value. - line.set(E, line.e() * factor, 5 /*decimal_digits*/); - else if (transition_out) { + if (transition_in){ + // Transition layer, interpolate the amount of extrusion starting from spiral_vase_starting_flow_rate to 100%. + float starting_e_factor = starting_flowrate + (factor * (1.f - starting_flowrate)); + line.set(E, line.e() * starting_e_factor, 5 /*decimal_digits*/); + } else if (transition_out) { // We want the last layer to ramp down extrusion, but without changing z height! // So clone the line before we mess with its Z and duplicate it into a new layer that ramps down E // We add this new layer at the very end + // As with transition_in, the amount is ramped down from 100% to spiral_vase_finishing_flow_rate GCodeReader::GCodeLine transitionLine(line); - transitionLine.set(E, line.e() * (1 - factor), 5 /*decimal_digits*/); + float finishing_e_factor = finishing_flowrate + ((1.f -factor) * (1.f - finishing_flowrate)); + transitionLine.set(E, line.e() * finishing_e_factor, 5 /*decimal_digits*/); transition_gcode += transitionLine.raw() + '\n'; } // This line is the core of Spiral Vase mode, ramp up the Z smoothly diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 1d124b019..7d6e76e34 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -781,7 +781,7 @@ bool Preset::has_cali_lines(PresetBundle* preset_bundle) } static std::vector s_Preset_print_options { - "layer_height", "initial_layer_print_height", "wall_loops", "alternate_extra_wall", "slice_closing_radius", "spiral_mode", "spiral_mode_smooth", "spiral_mode_max_xy_smoothing", "slicing_mode", + "layer_height", "initial_layer_print_height", "wall_loops", "alternate_extra_wall", "slice_closing_radius", "spiral_mode", "spiral_mode_smooth", "spiral_mode_max_xy_smoothing", "spiral_starting_flow_ratio", "spiral_finishing_flow_ratio", "slicing_mode", "top_shell_layers", "top_shell_thickness", "bottom_shell_layers", "bottom_shell_thickness", "extra_perimeters_on_overhangs", "ensure_vertical_shell_thickness", "reduce_crossing_wall", "detect_thin_wall", "detect_overhang_wall", "overhang_reverse", "overhang_reverse_threshold","overhang_reverse_internal_only", "wall_direction", "seam_position", "staggered_inner_seams", "wall_sequence", "is_infill_first", "sparse_infill_density", "sparse_infill_pattern", "lattice_angle_1", "lattice_angle_2", "top_surface_pattern", "bottom_surface_pattern", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 2fe0e3b55..2878ca735 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4421,6 +4421,26 @@ void PrintConfigDef::init_fff_params() def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloatOrPercent(200, true)); + def = this->add("spiral_starting_flow_ratio", coFloat); + def->label = "Spiral starting flow ratio"; + def->tooltip = L("Sets the starting flow ratio while transitioning from the last bottom layer to the spiral. " + "Normally the spiral transition scales the flow ratio from 0% to 100% during the first loop " + "which can in some cases lead to under extrusion at the start of the spiral."); + def->min = 0; + def->max = 1; + def->set_default_value(new ConfigOptionFloat(0)); + def->mode = comAdvanced; + + def = this->add("spiral_finishing_flow_ratio", coFloat); + def->label = "Spiral finishing flow ratio"; + def->tooltip = L("Sets the finishing flow ratio while ending the spiral. " + "Normally the spiral transition scales the flow ratio from 100% to 0% during the last loop " + "which can in some cases lead to under extrusion at the end of the spiral."); + def->min = 0; + def->max = 1; + def->set_default_value(new ConfigOptionFloat(0)); + def->mode = comAdvanced; + def = this->add("timelapse_type", coEnum); def->label = L("Timelapse"); def->tooltip = L("If smooth or traditional mode is selected, a timelapse video will be generated for each print. " diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 288c9e9c7..3a8bbd8a4 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1290,6 +1290,8 @@ PRINT_CONFIG_CLASS_DERIVED_DEFINE( ((ConfigOptionBool, spiral_mode)) ((ConfigOptionBool, spiral_mode_smooth)) ((ConfigOptionFloatOrPercent, spiral_mode_max_xy_smoothing)) + ((ConfigOptionFloat, spiral_finishing_flow_ratio)) + ((ConfigOptionFloat, spiral_starting_flow_ratio)) ((ConfigOptionInt, standby_temperature_delta)) ((ConfigOptionFloat, preheat_time)) ((ConfigOptionInt, preheat_steps)) diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index dd56478b6..d36690ad8 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -527,6 +527,8 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co bool has_spiral_vase = config->opt_bool("spiral_mode"); toggle_line("spiral_mode_smooth", has_spiral_vase); toggle_line("spiral_mode_max_xy_smoothing", has_spiral_vase && config->opt_bool("spiral_mode_smooth")); + toggle_line("spiral_starting_flow_ratio", has_spiral_vase); + toggle_line("spiral_finishing_flow_ratio", has_spiral_vase); bool has_top_solid_infill = config->opt_int("top_shell_layers") > 0; bool has_bottom_solid_infill = config->opt_int("bottom_shell_layers") > 0; bool has_solid_infill = has_top_solid_infill || has_bottom_solid_infill; diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index f66937d88..a5fdd2b1c 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2362,6 +2362,9 @@ page = add_options_page(L("Others"), "custom-gcode_other"); // ORCA: icon only v optgroup->append_single_option_line("spiral_mode", "spiral-vase"); optgroup->append_single_option_line("spiral_mode_smooth", "spiral-vase#smooth"); optgroup->append_single_option_line("spiral_mode_max_xy_smoothing", "spiral-vase#max-xy-smoothing"); + optgroup->append_single_option_line("spiral_starting_flow_ratio", "spiral-vase#starting-flow-ratio"); + optgroup->append_single_option_line("spiral_finishing_flow_ratio", "spiral-vase#finishing-flow-ratio"); + optgroup->append_single_option_line("timelapse_type", "Timelapse"); optgroup->append_single_option_line("fuzzy_skin");