From d663947a0cec3de7a4c2e52a796b40540511813c Mon Sep 17 00:00:00 2001 From: igiannakas <59056762+igiannakas@users.noreply.github.com> Date: Mon, 18 Sep 2023 01:16:09 +0300 Subject: [PATCH] First complete working version --- src/libslic3r/GCode.cpp | 41 ++++++++-------------- src/libslic3r/GCode/PressureEqualizer.cpp | 12 +++---- src/libslic3r/Preset.cpp | 2 -- src/libslic3r/PrintConfig.cpp | 42 +++++++++++------------ src/libslic3r/PrintConfig.hpp | 4 +-- src/slic3r/GUI/Tab.cpp | 4 +-- 6 files changed, 42 insertions(+), 63 deletions(-) diff --git a/src/libslic3r/GCode.cpp b/src/libslic3r/GCode.cpp index 1ca547f90d..50c3352f20 100644 --- a/src/libslic3r/GCode.cpp +++ b/src/libslic3r/GCode.cpp @@ -1873,15 +1873,14 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato if (print.config().spiral_mode.value) m_spiral_vase = make_unique(print.config()); -//#ifdef HAS_PRESSURE_EQUALIZER - //if (print.config().max_volumetric_extrusion_rate_slope_positive.value > 0 || - // print.config().max_volumetric_extrusion_rate_slope_negative.value > 0) - const GCodeConfig& tmp_config = print.config(); - m_pressure_equalizer = make_unique(print.config()); - m_enable_extrusion_role_markers = (bool)m_pressure_equalizer; -//#else /* HAS_PRESSURE_EQUALIZER */ -// m_enable_extrusion_role_markers = false; -//#endif /* HAS_PRESSURE_EQUALIZER */ + + if (print.config().max_volumetric_extrusion_rate_slope_positive.value > 0 || + print.config().max_volumetric_extrusion_rate_slope_negative.value > 0){ + m_pressure_equalizer = make_unique(print.config()); + m_enable_extrusion_role_markers = (bool)m_pressure_equalizer; + } else + m_enable_extrusion_role_markers = false; + file.write_format("; HEADER_BLOCK_START\n"); // Write information on the generator. @@ -2389,10 +2388,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato file.write("M1003 S0\n"); } } - #ifdef HAS_PRESSURE_EQUALIZER - if (m_pressure_equalizer) - file.write(m_pressure_equalizer->process("", true)); - #endif /* HAS_PRESSURE_EQUALIZER */ ++ finished_objects; // Flag indicating whether the nozzle temperature changes from 1st to 2nd layer were performed. // Reset it when starting another object from 1st layer. @@ -2460,10 +2455,6 @@ void GCode::_do_export(Print& print, GCodeOutputStream &file, ThumbnailsGenerato file.write("M1003 S0\n"); } } - #ifdef HAS_PRESSURE_EQUALIZER - if (m_pressure_equalizer) - file.write(m_pressure_equalizer->process("", true)); - #endif /* HAS_PRESSURE_EQUALIZER */ if (m_wipe_tower) // Purge the extruder, pull out the active filament. file.write(m_wipe_tower->finalize(*this)); @@ -2666,10 +2657,14 @@ void GCode::process_layers( }); // The pipeline elements are joined using const references, thus no copying is performed. - if (m_spiral_vase) + if (m_spiral_vase && m_pressure_equalizer) tbb::parallel_pipeline(12, generator & spiral_mode & pressure_equalizer & cooling & fan_mover & output); - else + else if (m_spiral_vase) + tbb::parallel_pipeline(12, generator & spiral_mode & cooling & fan_mover & output); + else if (m_pressure_equalizer) tbb::parallel_pipeline(12, generator & pressure_equalizer & cooling & fan_mover & output); + else + tbb::parallel_pipeline(12, generator & cooling & fan_mover & output); } // Process all layers of a single object instance (sequential mode) with a parallel pipeline: @@ -3899,14 +3894,6 @@ LayerResult GCode::process_layer( // Flush the cooling buffer at each object layer or possibly at the last layer, even if it contains just supports (This should not happen). object_layer || last_layer); -#ifdef HAS_PRESSURE_EQUALIZER - // Apply pressure equalization if enabled; - // printf("G-code before filter:\n%s\n", gcode.c_str()); - if (m_pressure_equalizer) - gcode = m_pressure_equalizer->process(gcode.c_str(), false); - // printf("G-code after filter:\n%s\n", out.c_str()); -#endif /* HAS_PRESSURE_EQUALIZER */ - file.write(gcode); #endif diff --git a/src/libslic3r/GCode/PressureEqualizer.cpp b/src/libslic3r/GCode/PressureEqualizer.cpp index 856885f0a5..7b85f5b84d 100644 --- a/src/libslic3r/GCode/PressureEqualizer.cpp +++ b/src/libslic3r/GCode/PressureEqualizer.cpp @@ -26,7 +26,7 @@ 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 = 0.5f; +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 @@ -64,12 +64,10 @@ PressureEqualizer::PressureEqualizer(const Slic3r::GCodeConfig &config) : m_use_ // Volumetric rate of a 0.45mm x 0.2mm extrusion at 20mm/s XY movement: 0.45*0.2*20*60=1.8*60 = 108 mm^3/min // 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 = 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(320) * 60.f * 60.f; - m_max_volumetric_extrusion_rate_slope_negative = float(320) * 60.f * 60.f; + if(config.max_volumetric_extrusion_rate_slope_positive.value > 0 || config.max_volumetric_extrusion_rate_slope_negative.value > 0){ + 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; + } for (ExtrusionRateSlope &extrusion_rate_slope : m_max_volumetric_extrusion_rate_slopes) { extrusion_rate_slope.negative = m_max_volumetric_extrusion_rate_slope_negative; diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index f640524ad9..5e3baad3a3 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -725,9 +725,7 @@ static std::vector s_Preset_print_options { "ironing_type", "ironing_pattern", "ironing_flow", "ironing_speed", "ironing_spacing", "max_travel_detour_distance", "fuzzy_skin", "fuzzy_skin_thickness", "fuzzy_skin_point_distance", -#ifdef HAS_PRESSURE_EQUALIZER "max_volumetric_extrusion_rate_slope_positive", "max_volumetric_extrusion_rate_slope_negative", -#endif /* HAS_PRESSURE_EQUALIZER */ "inner_wall_speed", "outer_wall_speed", "sparse_infill_speed", "internal_solid_infill_speed", "top_surface_speed", "support_speed", "support_object_xy_distance", "support_interface_speed", "bridge_speed", "internal_bridge_speed", "gap_infill_speed", "travel_speed", "travel_speed_z", "initial_layer_speed", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 2b2c8ba9bf..dab4502946 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2470,29 +2470,27 @@ def = this->add("filament_loading_speed", coFloats); def->mode = comAdvanced; def->set_default_value(new ConfigOptionFloats { 0. }); -#ifdef HAS_PRESSURE_EQUALIZER - //def = this->add("max_volumetric_extrusion_rate_slope_positive", coFloat); - //def->label = L("Max volumetric slope positive"); - //def->tooltip = L("This experimental setting is used to limit the speed of change in extrusion rate. " - // "A value of 1.8 mm³/s² ensures, that a change from the extrusion rate " - // "of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) " - // "to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds."); - //def->sidetext = L("mm³/s²"); - //def->min = 0; - //def->mode = comAdvanced; - //def->set_default_value(new ConfigOptionFloat(0)); + def = this->add("max_volumetric_extrusion_rate_slope_positive", coFloat); + def->label = L("Max volumetric slope positive"); + def->tooltip = L("This experimental setting is used to limit the speed of change in extrusion rate. " + "A value of 1.8 mm³/s² ensures, that a change from the extrusion rate " + "of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) " + "to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds."); + def->sidetext = L("mm³/s²"); + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloat(0)); - //def = this->add("max_volumetric_extrusion_rate_slope_negative", coFloat); - //def->label = L("Max volumetric slope negative"); - //def->tooltip = L("This experimental setting is used to limit the speed of change in extrusion rate. " - // "A value of 1.8 mm³/s² ensures, that a change from the extrusion rate " - // "of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) " - // "to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds."); - //def->sidetext = L("mm³/s²"); - //def->min = 0; - //def->mode = comAdvanced; - //def->set_default_value(new ConfigOptionFloat(0)); -#endif /* HAS_PRESSURE_EQUALIZER */ + def = this->add("max_volumetric_extrusion_rate_slope_negative", coFloat); + def->label = L("Max volumetric slope negative"); + def->tooltip = L("This experimental setting is used to limit the speed of change in extrusion rate. " + "A value of 1.8 mm³/s² ensures, that a change from the extrusion rate " + "of 1.8 mm³/s (0.45mm extrusion width, 0.2mm extrusion height, feedrate 20 mm/s) " + "to 5.4 mm³/s (feedrate 60 mm/s) will take at least 2 seconds."); + def->sidetext = L("mm³/s²"); + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloat(0)); def = this->add("fan_min_speed", coInts); def->label = L("Fan speed"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 3d518f625f..dead6a4960 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -884,8 +884,8 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionString, layer_change_gcode)) //#ifdef HAS_PRESSURE_EQUALIZER -// ((ConfigOptionFloat, max_volumetric_extrusion_rate_slope_positive)) -// ((ConfigOptionFloat, max_volumetric_extrusion_rate_slope_negative)) + ((ConfigOptionFloat, max_volumetric_extrusion_rate_slope_positive)) + ((ConfigOptionFloat, max_volumetric_extrusion_rate_slope_negative)) //#endif ((ConfigOptionPercents, retract_before_wipe)) ((ConfigOptionFloats, retraction_length)) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 7d369a3fae..a1cad06ed6 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1995,11 +1995,9 @@ void TabPrint::build() optgroup->append_single_option_line("top_surface_jerk"); optgroup->append_single_option_line("initial_layer_jerk"); optgroup->append_single_option_line("travel_jerk"); - -#ifdef HAS_PRESSURE_EQUALIZER + optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_positive"); optgroup->append_single_option_line("max_volumetric_extrusion_rate_slope_negative"); -#endif /* HAS_PRESSURE_EQUALIZER */ page = add_options_page(L("Support"), "support"); optgroup = page->new_optgroup(L("Support"), L"param_support");