Add minimum flow rates for spiral vase transitsions (#8333)

Add minimum flow ratios for spiral vase transitsions

Currently when starting the spiral vase the extrusion rate is ramped
from 0 to 100% on the first layer and from 100% to 0% on the last layer.
In some cases it can lead to underextrusion at the beginning and end of
the spiral.

This change adds minimum flow ratio options for the beginning and the end
of the vase. This means that instead of ramping from 0% to 100% it
instead ramps from for example 20% to 100%.

This issue has been reported in SuperSlicer
https://github.com/supermerill/SuperSlicer/issues/4195
This commit is contained in:
Kaarel Pärtel 2025-02-17 02:55:23 +02:00 committed by GitHub
parent a4289139b0
commit 830c1ac928
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 41 additions and 7 deletions

View file

@ -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, &current_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, &current_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

View file

@ -781,7 +781,7 @@ bool Preset::has_cali_lines(PresetBundle* preset_bundle)
}
static std::vector<std::string> 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",

View file

@ -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. "

View file

@ -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))

View file

@ -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;

View file

@ -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");