mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-05-17 10:32:20 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user