From e2088e651d4e2cd26490d2968f31487d0f80a8fb Mon Sep 17 00:00:00 2001 From: Justin Schuh Date: Sun, 28 Jun 2020 14:29:43 -0700 Subject: [PATCH] Add setting to control when bridge infill is used Adds bridge_infill_threshold setting to control when bridge infill is used. Bridge infill will be applied only if the average area of the voids between infill lines (computed from the infill density and infill extrusion width) is greater than the supplied threshold value. --- src/libslic3r/Layer.hpp | 2 ++ src/libslic3r/LayerRegion.cpp | 11 +++++++++++ src/libslic3r/Print.cpp | 1 + src/libslic3r/PrintConfig.cpp | 10 ++++++++++ src/libslic3r/PrintConfig.hpp | 2 ++ src/libslic3r/PrintObject.cpp | 13 ++++++++++--- src/slic3r/GUI/Preset.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 1 + 8 files changed, 38 insertions(+), 4 deletions(-) diff --git a/src/libslic3r/Layer.hpp b/src/libslic3r/Layer.hpp index c104d46da17..5e1f09c204b 100644 --- a/src/libslic3r/Layer.hpp +++ b/src/libslic3r/Layer.hpp @@ -57,6 +57,8 @@ class LayerRegion void make_perimeters(const SurfaceCollection &slices, SurfaceCollection* fill_surfaces); void process_external_surfaces(const Layer *lower_layer, const Polygons *lower_layer_covered); double infill_area_threshold() const; + // True if infill voids (computed from infill_density) are larger than bridge_infill_threshold. + bool needs_bridge_over_infill() const; // Trim surfaces by trimming polygons. Used by the elephant foot compensation at the 1st layer. void trim_surfaces(const Polygons &trimming_polygons); // Single elephant foot compensation step, used by the elephant foor compensation at the 1st layer. diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp index 5fda69f779e..fc24c719b75 100644 --- a/src/libslic3r/LayerRegion.cpp +++ b/src/libslic3r/LayerRegion.cpp @@ -397,6 +397,17 @@ double LayerRegion::infill_area_threshold() const return ss*ss; } +bool LayerRegion::needs_bridge_over_infill() const +{ + auto region_config = region()->config(); + if (region_config.fill_density <= 0) + return true; + const double infill_extrusion_width = flow(frInfill).width; + // Compute the unsupported area assuming a grid, which is pragmatically good enough for all infill types. + const double bridging_area = pow(2.0 * 100.0 * infill_extrusion_width / region_config.fill_density - infill_extrusion_width, 2); + return bridging_area > region_config.bridge_infill_threshold; +} + void LayerRegion::trim_surfaces(const Polygons &trimming_polygons) { #ifndef NDEBUG diff --git a/src/libslic3r/Print.cpp b/src/libslic3r/Print.cpp index a88b940e8ee..ba5e38038c7 100644 --- a/src/libslic3r/Print.cpp +++ b/src/libslic3r/Print.cpp @@ -74,6 +74,7 @@ bool Print::invalidate_state_by_config_options(const std::vectormode = comAdvanced; def->set_default_value(new ConfigOptionFloat(1)); + def = this->add("bridge_infill_threshold", coFloat); + def->label = L("Bridge infill threshold"); + def->tooltip = L("Forces bridge settings for the layer above infill where voids are larger than the specified area. " + "The infill void area is computed from the infill density and infill extrusion width. " + "Set to zero to force bridge settings for any layer above non-solid infill."); + def->sidetext = L("mm²"); + def->min = 0; + def->mode = comExpert; + def->set_default_value(new ConfigOptionFloat(25.)); + def = this->add("bridge_speed", coFloat); def->label = L("Bridges"); def->category = L("Speed"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index ad7161ad35c..091d2669644 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -490,6 +490,7 @@ class PrintRegionConfig : public StaticPrintConfig ConfigOptionFloat bottom_solid_min_thickness; ConfigOptionFloat bridge_flow_ratio; ConfigOptionFloat bridge_speed; + ConfigOptionFloat bridge_infill_threshold; ConfigOptionBool ensure_vertical_shell_thickness; ConfigOptionEnum top_fill_pattern; ConfigOptionEnum bottom_fill_pattern; @@ -540,6 +541,7 @@ class PrintRegionConfig : public StaticPrintConfig OPT_PTR(bottom_solid_layers); OPT_PTR(bottom_solid_min_thickness); OPT_PTR(bridge_flow_ratio); + OPT_PTR(bridge_infill_threshold); OPT_PTR(bridge_speed); OPT_PTR(ensure_vertical_shell_thickness); OPT_PTR(top_fill_pattern); diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index cc39cbf0aeb..aa684e3057d 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1408,9 +1408,16 @@ void PrintObject::bridge_over_infill() // iterate through regions and collect internal surfaces Polygons lower_internal; - for (LayerRegion *lower_layerm : lower_layer->m_regions) - lower_layerm->fill_surfaces.filter_by_type(stInternal, &lower_internal); - + for (LayerRegion* lower_layerm : lower_layer->m_regions) { + auto surfaces = lower_layerm->fill_surfaces.surfaces; + for (Surfaces::iterator surface = surfaces.begin(); surface != surfaces.end(); ++surface) { + if (surface->surface_type == stInternal && layerm->needs_bridge_over_infill()) { + Polygons pp = surface->expolygon; + lower_internal.insert(lower_internal.end(), pp.begin(), pp.end()); + } + } + } + // intersect such lower internal surfaces with the candidate solid surfaces to_bridge_pp = intersection(to_bridge_pp, lower_internal); } diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 1a715262b03..72d12d3d85a 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -407,7 +407,7 @@ const std::vector& Preset::print_options() "infill_every_layers", "infill_only_where_needed", "solid_infill_every_layers", "fill_angle", "bridge_angle", "solid_infill_below_area", "only_retract_when_crossing_perimeters", "infill_first", "ironing", "ironing_type", "ironing_flowrate", "ironing_speed", "ironing_spacing", - "max_print_speed", "max_volumetric_speed", + "max_print_speed", "max_volumetric_speed", "bridge_infill_threshold", #ifdef HAS_PRESSURE_EQUALIZER "max_volumetric_extrusion_rate_slope_positive", "max_volumetric_extrusion_rate_slope_negative", #endif /* HAS_PRESSURE_EQUALIZER */ diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 09f647b4843..b571f7e14e1 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1345,6 +1345,7 @@ void TabPrint::build() optgroup->append_single_option_line("fill_angle"); optgroup->append_single_option_line("solid_infill_below_area"); optgroup->append_single_option_line("bridge_angle"); + optgroup->append_single_option_line("bridge_infill_threshold"); optgroup->append_single_option_line("only_retract_when_crossing_perimeters"); optgroup->append_single_option_line("infill_first");