From 86fbd247b74435baad5c2a2db391ffad3bca1619 Mon Sep 17 00:00:00 2001 From: supermerill Date: Tue, 29 Oct 2019 16:44:00 +0100 Subject: [PATCH] #101 add ratio /distribution for the smoothing flow in ironing (see tooltip) --- resources/profiles/PrusaResearch.ini | 2 +- src/libslic3r/Fill/FillSmooth.cpp | 15 ++++++++++----- src/libslic3r/Fill/FillSmooth.hpp | 4 ++-- src/libslic3r/PrintConfig.cpp | 12 +++++++++++- src/libslic3r/PrintConfig.hpp | 2 ++ src/libslic3r/PrintObject.cpp | 1 + src/slic3r/GUI/ConfigManipulation.cpp | 2 +- src/slic3r/GUI/Preset.cpp | 1 + src/slic3r/GUI/Tab.cpp | 1 + 9 files changed, 30 insertions(+), 10 deletions(-) diff --git a/resources/profiles/PrusaResearch.ini b/resources/profiles/PrusaResearch.ini index 45b6c7231..37931275c 100644 --- a/resources/profiles/PrusaResearch.ini +++ b/resources/profiles/PrusaResearch.ini @@ -96,7 +96,7 @@ bridge_acceleration = 1000 bridge_angle = 0 bridge_flow_ratio = 80% over_bridge_flow_ratio = 120% -fill_top_flow_ratio = 120% +fill_top_flow_ratio = 100% bridge_speed = 20 brim_width = 0 clip_multipart_objects = 1 diff --git a/src/libslic3r/Fill/FillSmooth.cpp b/src/libslic3r/Fill/FillSmooth.cpp index 3525923e1..eabc0fd2c 100644 --- a/src/libslic3r/Fill/FillSmooth.cpp +++ b/src/libslic3r/Fill/FillSmooth.cpp @@ -18,6 +18,7 @@ namespace Slic3r { return polylines_out; } + /// @idx: the index of the step (0 = first step, 1 = second step, ...) The first lay down the volume and the others smoothen the surface. void FillSmooth::perform_single_fill(const int idx, ExtrusionEntityCollection &eecroot, const Surface &srf_source, const FillParams ¶ms, const double volume){ if (srf_source.expolygon.empty()) return; @@ -26,14 +27,18 @@ namespace Slic3r { ExtrusionEntityCollection *eec = new ExtrusionEntityCollection(); eec->no_sort = false; FillParams params_modifided = params; - if (params.config != NULL && rolePass[idx] == ExtrusionRole::erTopSolidInfill) params_modifided.density /= (float)params.config->fill_smooth_width.get_abs_value(1); + if (params.config != NULL && idx > 0) params_modifided.density /= (float)params.config->fill_smooth_width.get_abs_value(1); + else if (params.config != NULL && idx == 0) params_modifided.density *= 1; else params_modifided.density *= (float)percentWidth[idx]; // reduce flow for each increase in density params_modifided.flow_mult *= params.density; params_modifided.flow_mult /= params_modifided.density; // split the flow between steps - params_modifided.flow_mult *= (float)percentFlow[idx]; - + if (params.config != NULL && idx > 0) params_modifided.flow_mult *= (float)params.config->fill_smooth_distribution.get_abs_value(1); + else if (params.config != NULL && idx == 0) params_modifided.flow_mult *= (1.f - (float)params.config->fill_smooth_distribution.get_abs_value(1)); + else params_modifided.flow_mult *= (float)percentFlow[idx]; + + //choose if we are going to extrude with or without overlap if ((params.flow->bridge && idx == 0) || has_overlap[idx]){ this->fill_expolygon(idx, *eec, srf_source, params_modifided, volume); } @@ -86,11 +91,11 @@ namespace Slic3r { good_role = params.flow->bridge && idx == 0 ? erBridgeInfill : rolePass[idx]; } // print - float mult_flow = (params.fill_exactly && idx == 0 ? std::min(2., volume / extrudedVolume) : 1); + float mult_flow = (params.fill_exactly /*&& idx == 0*/ ? std::min(2., volume / extrudedVolume) : 1); extrusion_entities_append_paths( eec.entities, std::move(polylines_layer), good_role, - params.flow_mult * params.flow->mm3_per_mm() * mult_flow, + params.flow->mm3_per_mm() * params.flow_mult * mult_flow, //min-reduced flow width for a better view (it's only a gui thing) (float)(params.flow->width * (params.flow_mult* mult_flow < 0.1 ? 0.1 : params.flow_mult * mult_flow)), (float)params.flow->height); } diff --git a/src/libslic3r/Fill/FillSmooth.hpp b/src/libslic3r/Fill/FillSmooth.hpp index efc982d57..e5d97f4db 100644 --- a/src/libslic3r/Fill/FillSmooth.hpp +++ b/src/libslic3r/Fill/FillSmooth.hpp @@ -44,7 +44,7 @@ protected: int nbPass=2; // this parameter is now erased by fill_smooth_width when available. double percentWidth[3]; - // this parameter is now modified by fill_top_flow_ratio when available. + // this parameter is now modified by fill_smooth_distribution when available. (note that fill_top_flow_ratio can also increasse the params.flow_mult passed by fill.cpp) double percentFlow[3]; //angle to add to base angle float anglePass[3]; @@ -76,7 +76,7 @@ public: rolePass[0] = erTopSolidInfill;//erSolidInfill rolePass[1] = erSolidInfill; rolePass[2] = erTopSolidInfill; - percentWidth[0] = 1.4; //0.8 + percentWidth[0] = 1; //0.8 percentWidth[1] = 1.5; percentWidth[2] = 2.8; percentFlow[0] = 1; //0.7 diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 4937cfd2e..a4a1b76a6 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -1164,11 +1164,21 @@ void PrintConfigDef::init_fff_params() def = this->add("fill_smooth_width", coFloatOrPercent); def->label = L("width"); def->full_label = L("Ironing width"); - def->tooltip = L("This is the width of the ironing pass, in a % of the top width, should be no more than 50%."); + def->tooltip = L("This is the width of the ironing pass, in a % of the top extrusion width, should not be more than 50%."); def->min = 0; def->mode = comExpert; def->set_default_value(new ConfigOptionFloatOrPercent(50, true)); + def = this->add("fill_smooth_distribution", coFloatOrPercent); + def->label = L("distribution"); + def->full_label = L("Ironing flow distribution"); + def->tooltip = L("This is the percentage of the flow that is used for the second ironing pass. Typical 0-20%. " + "Should not be lower than 20%, unless you have your top extrusion width greatly superior to your nozzle width."); + def->min = 0; + def->max = 0.9; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloatOrPercent(10, true)); + def = this->add("first_layer_acceleration", coFloat); def->label = L("First layer"); def->full_label = L("First layer acceleration"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index eb9a26779..10e434de4 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -592,6 +592,7 @@ public: ConfigOptionPercent fill_density; ConfigOptionEnum fill_pattern; ConfigOptionFloatOrPercent fill_top_flow_ratio; + ConfigOptionFloatOrPercent fill_smooth_distribution; ConfigOptionFloatOrPercent fill_smooth_width; ConfigOptionBool gap_fill; ConfigOptionFloatOrPercent gap_fill_min_area; @@ -659,6 +660,7 @@ protected: OPT_PTR(fill_density); OPT_PTR(fill_pattern); OPT_PTR(fill_top_flow_ratio); + OPT_PTR(fill_smooth_distribution); OPT_PTR(fill_smooth_width); OPT_PTR(gap_fill); OPT_PTR(gap_fill_min_area); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 1304a1cf3..0e949a35c 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -560,6 +560,7 @@ bool PrintObject::invalidate_state_by_config_options(const std::vectoropt_bool("gap_fill")); - for (auto el : {"fill_smooth_width" }) + for (auto el : {"fill_smooth_width, fill_smooth_distribution" }) toggle_field(el, config->opt_enum("top_fill_pattern") == InfillPattern::ipSmooth); bool have_top_solid_infill = config->opt_int("top_solid_layers") > 0; diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index bfb124a3b..6229f4d84 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -385,6 +385,7 @@ const std::vector& Preset::print_options() , "fill_pattern" , "fill_top_flow_ratio" , "fill_smooth_width" + , "fill_smooth_distribution" , "top_fill_pattern" , "bottom_fill_pattern" , "solid_fill_pattern", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index f02c14536..dd2e6021f 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1145,6 +1145,7 @@ void TabPrint::build() optgroup = page->new_optgroup(_(L("Advanced Infill"))); line.append_option(optgroup->get_option("fill_smooth_width")); + line.append_option(optgroup->get_option("fill_smooth_distribution")); optgroup->append_line(line); page = add_options_page(_(L("Skirt and brim")), "skirt+brim");