From 73a912d76d6513a675742967f491eb53af6260ce Mon Sep 17 00:00:00 2001 From: igiannakas Date: Wed, 6 Nov 2024 18:19:08 +0000 Subject: [PATCH 1/3] Optimisation: Reduce volume of output gcode commands for pressure equalizer --- src/libslic3r/GCode/PressureEqualizer.cpp | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/GCode/PressureEqualizer.cpp b/src/libslic3r/GCode/PressureEqualizer.cpp index 806ef768e71..c3d54ae81d1 100644 --- a/src/libslic3r/GCode/PressureEqualizer.cpp +++ b/src/libslic3r/GCode/PressureEqualizer.cpp @@ -482,11 +482,25 @@ void PressureEqualizer::output_gcode_line(const size_t line_idx) if (*comment != ';') comment = nullptr; - // Emit the line with lowered extrusion rates. + // get the gcode line length float l = line.dist_xyz(); - if (auto nSegments = size_t(ceil(l / m_max_segment_length)); nSegments == 1) { // Just update this segment. + // number of segments this line can be broken down to + auto nSegments = size_t(ceil(l / m_max_segment_length)); + + // Orca: + // Calculate the absolute difference in volumetric extrusion rate between the start and end point of the line. + // Quantize it to 1mm3/min (0.016mm3/sec). + int delta_volumetric_rate = std::round(fabs(line.volumetric_extrusion_rate_end - line.volumetric_extrusion_rate_start)); + + // Emit the line with lowered extrusion rates. + // Orca: + // First, check if the change in volumetric extrusion rate is negligible. + // Or if the line size is equal in length with the smallest segment. + // If so, then emit the line as a single extrusion, i.e. dont split into segments. + if ( nSegments == 1 || delta_volumetric_rate == 0) { push_line_to_output(line_idx, line.feedrate() * line.volumetric_correction_avg(), comment); - } else { + } else // The line needs to be split the line into segments and apply extrusion rate smoothing + { bool accelerating = line.volumetric_extrusion_rate_start < line.volumetric_extrusion_rate_end; // Update the initial and final feed rate values. line.pos_start[4] = line.volumetric_extrusion_rate_start * line.pos_end[4] / line.volumetric_extrusion_rate; @@ -769,7 +783,8 @@ void PressureEqualizer::push_line_to_output(const size_t line_idx, float new_fee // Orca: sanity check, 1 mm/s is the minimum feedrate. if (new_feedrate < 60) new_feedrate = 60; - new_feedrate = std::round(new_feedrate); + // Quantize speed changes to a minimum of 1mm/sec, to reduce gcode volume for trivial speed changes. + new_feedrate = std::round(new_feedrate / 60.0) * 60.0; const GCodeLine &line = m_gcode_lines[line_idx]; if (line_idx > 0 && output_buffer_length > 0) { const std::string prev_line_str = std::string(output_buffer.begin() + int(this->output_buffer_prev_length), From a1811b24b864fb3c274ff013df227fe1422db30b Mon Sep 17 00:00:00 2001 From: igiannakas Date: Wed, 6 Nov 2024 19:00:48 +0000 Subject: [PATCH 2/3] Update thresholds --- src/libslic3r/GCode/PressureEqualizer.cpp | 4 ++-- src/libslic3r/PrintConfig.cpp | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/libslic3r/GCode/PressureEqualizer.cpp b/src/libslic3r/GCode/PressureEqualizer.cpp index c3d54ae81d1..d5ddc50d919 100644 --- a/src/libslic3r/GCode/PressureEqualizer.cpp +++ b/src/libslic3r/GCode/PressureEqualizer.cpp @@ -494,10 +494,10 @@ void PressureEqualizer::output_gcode_line(const size_t line_idx) // Emit the line with lowered extrusion rates. // Orca: - // First, check if the change in volumetric extrusion rate is negligible. + // First, check if the change in volumetric extrusion rate is trivial (less than 10mm3/min -> 0.16mm3/sec (5mm/sec speed for a 0.25 mm nozzle). // Or if the line size is equal in length with the smallest segment. // If so, then emit the line as a single extrusion, i.e. dont split into segments. - if ( nSegments == 1 || delta_volumetric_rate == 0) { + if ( nSegments == 1 || delta_volumetric_rate < 10) { push_line_to_output(line_idx, line.feedrate() * line.volumetric_correction_avg(), comment); } else // The line needs to be split the line into segments and apply extrusion rate smoothing { diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index b93e7920d31..c62eea9da73 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3330,6 +3330,7 @@ void PrintConfigDef::init_fff_params() "Allowed values: 1-5"); def->min = 1; def->max = 5; + def->sidetext = L("mm"); def->mode = comAdvanced; def->set_default_value(new ConfigOptionInt(3)); From b2f222dcc2e2170c93fa58b724300b1682585630 Mon Sep 17 00:00:00 2001 From: igiannakas Date: Wed, 6 Nov 2024 19:01:26 +0000 Subject: [PATCH 3/3] Update PrintConfig.cpp --- src/libslic3r/PrintConfig.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index c62eea9da73..b93e7920d31 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -3330,7 +3330,6 @@ void PrintConfigDef::init_fff_params() "Allowed values: 1-5"); def->min = 1; def->max = 5; - def->sidetext = L("mm"); def->mode = comAdvanced; def->set_default_value(new ConfigOptionInt(3));