From 7a5746b1ae290797c9fdb4a88ad919fb9dbc0fee Mon Sep 17 00:00:00 2001 From: Vovodroid Date: Thu, 23 Jan 2025 12:01:38 +0200 Subject: [PATCH] Support threshold overlap (#6606) * Support threshold overlap * Update tooltip --- src/libslic3r/Preset.cpp | 2 +- src/libslic3r/PrintConfig.cpp | 13 ++++++++++++- src/libslic3r/PrintConfig.hpp | 1 + src/libslic3r/PrintObject.cpp | 1 + src/libslic3r/Support/SupportMaterial.cpp | 4 ++-- src/libslic3r/Support/TreeSupport3D.cpp | 2 +- src/slic3r/GUI/ConfigManipulation.cpp | 1 + src/slic3r/GUI/GUI_Factories.cpp | 6 +++--- src/slic3r/GUI/Tab.cpp | 1 + 9 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index cfc777c8c..d4610cc96 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -785,7 +785,7 @@ static std::vector s_Preset_print_options { "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", "outer_wall_acceleration", "initial_layer_acceleration", "top_surface_acceleration", "default_acceleration", "skirt_type", "skirt_loops", "skirt_speed","min_skirt_length", "skirt_distance", "skirt_start_angle", "skirt_height", "draft_shield", - "brim_width", "brim_object_gap", "brim_type", "brim_ears_max_angle", "brim_ears_detection_length", "enable_support", "support_type", "support_threshold_angle", "enforce_support_layers", + "brim_width", "brim_object_gap", "brim_type", "brim_ears_max_angle", "brim_ears_detection_length", "enable_support", "support_type", "support_threshold_angle", "support_threshold_overlap","enforce_support_layers", "raft_layers", "raft_first_layer_density", "raft_first_layer_expansion", "raft_contact_distance", "raft_expansion", "support_base_pattern", "support_base_pattern_spacing", "support_expansion", "support_style", "independent_support_layer_height", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 0fd8c91b7..1c259a028 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -4722,11 +4722,22 @@ void PrintConfigDef::init_fff_params() def->category = L("Support"); def->tooltip = L("Support will be generated for overhangs whose slope angle is below the threshold."); def->sidetext = L("°"); - def->min = 1; + def->min = 0; def->max = 90; def->mode = comSimple; def->set_default_value(new ConfigOptionInt(30)); + def = this->add("support_threshold_overlap", coFloatOrPercent); + def->label = L("Threshold overlap"); + def->category = L("Support"); + def->tooltip = L("If threshold angle is zero, support will be generated for overhangs whose overlap is below the threshold. The smaller this value is, the steeper the overhang that can be printed without support."); + def->sidetext = L("mm or %"); + def->min = 0; + def->max = 100; + def->max_literal = 0.5; + def->mode = comSimple; + def->set_default_value(new ConfigOptionFloatOrPercent(50., true)); + def = this->add("tree_support_branch_angle", coFloat); def->label = L("Tree support branch angle"); def->category = L("Support"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index dc222603b..88cc8438b 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -820,6 +820,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionEnum, dont_filter_internal_bridges)) // Overhang angle threshold. ((ConfigOptionInt, support_threshold_angle)) + ((ConfigOptionFloatOrPercent, support_threshold_overlap)) ((ConfigOptionFloat, support_object_xy_distance)) ((ConfigOptionFloat, xy_hole_compensation)) ((ConfigOptionFloat, xy_contour_compensation)) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 01d7e242c..0c5d78de7 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -1019,6 +1019,7 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "support_expansion" //|| opt_key == "independent_support_layer_height" // BBS || opt_key == "support_threshold_angle" + || opt_key == "support_threshold_overlap" || opt_key == "raft_expansion" || opt_key == "raft_first_layer_density" || opt_key == "raft_first_layer_expansion" diff --git a/src/libslic3r/Support/SupportMaterial.cpp b/src/libslic3r/Support/SupportMaterial.cpp index 4d0aafcff..3050bd7f6 100644 --- a/src/libslic3r/Support/SupportMaterial.cpp +++ b/src/libslic3r/Support/SupportMaterial.cpp @@ -1517,8 +1517,8 @@ static inline ExPolygons detect_overhangs( (threshold_rad > 0. ? // Overhang defined by an angle. float(scale_(lower_layer.height / tan(threshold_rad))) : - // Overhang defined by half the extrusion width. - 0.5f * fw); + // Overhang defined by overlap. + fw - float(scale_(object_config.support_threshold_overlap.get_abs_value(unscale_(fw))))); // Overhang polygons for this layer and region. Polygons diff_polygons; Polygons layerm_polygons = to_polygons(layerm->slices.surfaces); diff --git a/src/libslic3r/Support/TreeSupport3D.cpp b/src/libslic3r/Support/TreeSupport3D.cpp index c96801e00..fb4dcb2c9 100644 --- a/src/libslic3r/Support/TreeSupport3D.cpp +++ b/src/libslic3r/Support/TreeSupport3D.cpp @@ -239,7 +239,7 @@ static std::vector>> group_me for (const LayerRegion *layerm : lower_layer.regions()) external_perimeter_width += layerm->flow(frExternalPerimeter).scaled_width(); external_perimeter_width /= lower_layer.region_count(); - lower_layer_offset = float(0.5 * external_perimeter_width); + lower_layer_offset = external_perimeter_width - float(scale_(config.support_threshold_overlap.get_abs_value(unscale_(external_perimeter_width)))); } else lower_layer_offset = scaled(lower_layer.height / tan_threshold); overhangs = lower_layer_offset == 0 ? diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 4bfcf18cf..44ed3da01 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -599,6 +599,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co "support_object_xy_distance"/*, "independent_support_layer_height"*/}) toggle_field(el, have_support_material); toggle_field("support_threshold_angle", have_support_material && is_auto(support_type)); + toggle_field("support_threshold_overlap", config->opt_int("support_threshold_angle") == 0 && have_support_material && is_auto(support_type)); //toggle_field("support_closing_radius", have_support_material && support_style == smsSnug); bool support_is_tree = config->opt_bool("enable_support") && is_tree(support_type); diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index 8d1452a0f..416c26990 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -61,7 +61,7 @@ static SettingsFactory::Bundle FREQ_SETTINGS_BUNDLE_FFF = { L("Shell"), { "wall_loops", "top_shell_layers", "bottom_shell_layers"} }, { L("Infill") , { "sparse_infill_density", "sparse_infill_pattern" } }, // BBS - { L("Support") , { "enable_support", "support_type", "support_threshold_angle", + { L("Support") , { "enable_support", "support_type", "support_threshold_angle", "support_threshold_overlap", "support_base_pattern", "support_on_build_plate_only","support_critical_regions_only", "support_remove_small_overhang", "support_base_pattern_spacing", "support_expansion"}}, @@ -88,7 +88,7 @@ std::map> SettingsFactory::OBJECT_C }}, { L("Support"), {{"brim_type", "",1},{"brim_width", "",2},{"brim_object_gap", "",3}, - {"enable_support", "",4},{"support_type", "",5},{"support_threshold_angle", "",6},{"support_on_build_plate_only", "",7}, + {"enable_support", "",4},{"support_type", "",5},{"support_threshold_angle", "",6}, {"support_threshold_overlap", "",6}, {"support_on_build_plate_only", "",7}, {"support_filament", "",8},{"support_interface_filament", "",9},{"support_expansion", "",24},{"support_style", "",25}, {"tree_support_brim_width", "",26}, {"tree_support_branch_angle", "",10},{"tree_support_branch_angle_organic","",10}, {"tree_support_wall_count", "",11},//tree support {"support_top_z_distance", "",13},{"support_bottom_z_distance", "",12},{"support_base_pattern", "",14},{"support_base_pattern_spacing", "",15}, @@ -150,7 +150,7 @@ std::vector SettingsFactory::get_visible_options(const std::s //Quality "layer_height", "initial_layer_print_height", "adaptive_layer_height", "seam_position", "xy_hole_compensation", "xy_contour_compensation", "elefant_foot_compensation", "support_line_width", //Support - "enable_support", "support_type", "support_threshold_angle", "support_on_build_plate_only", "support_critical_regions_only", "enforce_support_layers", + "enable_support", "support_type", "support_threshold_angle", "support_threshold_overlap", "support_on_build_plate_only", "support_critical_regions_only", "enforce_support_layers", //tree support "tree_support_wall_count", //support diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 7ec6d1b97..8005d4ee6 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -2227,6 +2227,7 @@ void TabPrint::build() optgroup->append_single_option_line("support_type", "support#support-types"); optgroup->append_single_option_line("support_style", "support#support-styles"); optgroup->append_single_option_line("support_threshold_angle", "support#threshold-angle"); + optgroup->append_single_option_line("support_threshold_overlap", "support#threshold-angle"); optgroup->append_single_option_line("raft_first_layer_density"); optgroup->append_single_option_line("raft_first_layer_expansion"); optgroup->append_single_option_line("support_on_build_plate_only");