From 8ec8e999ecdae9b2671c1865bac6ab4cbd5f39ae Mon Sep 17 00:00:00 2001 From: igiannakas <59056762+igiannakas@users.noreply.github.com> Date: Sun, 17 Sep 2023 19:06:17 +0300 Subject: [PATCH] Further commits --- src/libslic3r/GCode.cpp | 13 +++++++++---- src/libslic3r/GCode/PressureEqualizer.cpp | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 30ae1312f0..1ca547f90d 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -2606,8 +2606,7 @@ void GCode::process_layers( // Pressure equalizer need insert empty input. Because it returns one layer back. // Insert NOP (no operation) layer; ++layer_to_print_idx; - return {}; // IG TO CHANGE - // return LayerResult::make_nop_layer_result(); + return LayerResult::make_nop_layer_result(); } //fc.stop(); //return {}; @@ -2626,6 +2625,9 @@ void GCode::process_layers( const auto spiral_mode = tbb::make_filter(slic3r_tbb_filtermode::serial_in_order, [&spiral_mode = *this->m_spiral_vase.get()](LayerResult in) -> LayerResult { + if (in.nop_layer_result) + return in; + spiral_mode.enable(in.spiral_vase_enable); return { spiral_mode.process_layer(std::move(in.gcode)), in.layer_id, in.spiral_vase_enable, in.cooling_buffer_flush }; }); @@ -2635,6 +2637,8 @@ void GCode::process_layers( }); const auto cooling = tbb::make_filter(slic3r_tbb_filtermode::serial_in_order, [&cooling_buffer = *this->m_cooling_buffer.get()](LayerResult in) -> std::string { + if (in.nop_layer_result) + return in.gcode; return cooling_buffer.process_layer(std::move(in.gcode), in.layer_id, in.cooling_buffer_flush); }); const auto output = tbb::make_filter(slic3r_tbb_filtermode::serial_in_order, @@ -2643,6 +2647,7 @@ void GCode::process_layers( const auto fan_mover = tbb::make_filter(slic3r_tbb_filtermode::serial_in_order, [&fan_mover = this->m_fan_mover, &config = this->config(), &writer = this->m_writer](std::string in)->std::string { + CNumericLocalesSetter locales_setter; if (config.fan_speedup_time.value != 0 || config.fan_kickstart.value > 0) { @@ -2662,9 +2667,9 @@ void GCode::process_layers( // The pipeline elements are joined using const references, thus no copying is performed. if (m_spiral_vase) - tbb::parallel_pipeline(12, generator & spiral_mode & cooling & fan_mover & output); + tbb::parallel_pipeline(12, generator & spiral_mode & pressure_equalizer & cooling & fan_mover & output); else - tbb::parallel_pipeline(12, generator & cooling & fan_mover & output); + tbb::parallel_pipeline(12, generator & pressure_equalizer & cooling & fan_mover & output); } // Process all layers of a single object instance (sequential mode) with a parallel pipeline: diff --git a/src/libslic3r/GCode/PressureEqualizer.cpp b/src/libslic3r/GCode/PressureEqualizer.cpp index c2ad3a2ed7..ec7eef8929 100644 --- a/src/libslic3r/GCode/PressureEqualizer.cpp +++ b/src/libslic3r/GCode/PressureEqualizer.cpp @@ -25,13 +25,19 @@ static const std::string EXTERNAL_PERIMETER_TAG = ";_EXTERNAL_PERIMETER"; // Maximum segment length to split a long segment if the initial and the final flow rate differ. // Smaller value means a smoother transition between two different flow rates. -static constexpr float max_segment_length = 5.f; +static constexpr float max_segment_length = 1.f; // For how many GCode lines back will adjust a flow rate from the latest line. // Bigger values affect the GCode export speed a lot, and smaller values could // affect how distant will be propagated a flow rate adjustment. static constexpr int max_look_back_limit = 128; +// Max non-extruding XY distance (travel move) in mm between two continous extrusions where we pretend +// its all one continous extruded line. Above this distance we assume extruder pressure hits 0 +// This exists because often there's tiny travel moves between stuff like infill +// lines where some extruder pressure will remain (so we should equalize between these small travels) +static constexpr long max_ignored_gap_between_extruding_segments = 3; + PressureEqualizer::PressureEqualizer(const Slic3r::GCodeConfig &config) : m_use_relative_e_distances(config.use_relative_e_distances.value) { // Preallocate some data, so that output_buffer.data() will return an empty string. @@ -58,8 +64,11 @@ PressureEqualizer::PressureEqualizer(const Slic3r::GCodeConfig &config) : m_use_ // Slope of the volumetric rate, changing from 20mm/s to 60mm/s over 2 seconds: (5.4-1.8)*60*60/2=60*60*1.8 = 6480 mm^3/min^2 = 1.8 mm^3/s^2 //---IG - m_max_volumetric_extrusion_rate_slope_positive = 0.1;//float(config.max_volumetric_extrusion_rate_slope_positive.value) * 60.f * 60.f; - m_max_volumetric_extrusion_rate_slope_negative = 0.1;//float(config.max_volumetric_extrusion_rate_slope_negative.value) * 60.f * 60.f; + //m_max_volumetric_extrusion_rate_slope_positive = float(config.max_volumetric_extrusion_rate_slope_positive.value) * 60.f * 60.f; + //m_max_volumetric_extrusion_rate_slope_negative = float(config.max_volumetric_extrusion_rate_slope_negative.value) * 60.f * 60.f; + + m_max_volumetric_extrusion_rate_slope_positive = float(10) * 60.f * 60.f; + m_max_volumetric_extrusion_rate_slope_negative = float(10) * 60.f * 60.f; for (ExtrusionRateSlope &extrusion_rate_slope : m_max_volumetric_extrusion_rate_slopes) { extrusion_rate_slope.negative = m_max_volumetric_extrusion_rate_slope_negative;