From 28a842698d184ec1d887776f323a50e9a46b0c94 Mon Sep 17 00:00:00 2001 From: "salt.wei" Date: Wed, 26 Oct 2022 15:03:16 +0800 Subject: [PATCH] ENH: add bridge direction option In some complicated cases or irregular shape, the direction of external bridge is not good when calculated automaticlly. So user may use modifier to change bridge direction. This is handling for github issue #340 Signed-off-by: salt.wei Change-Id: I3baf313f47925fa7e6aa087f5896b0af560f902d --- src/libslic3r/LayerRegion.cpp | 3 +-- src/libslic3r/Preset.cpp | 2 +- src/libslic3r/PrintConfig.cpp | 11 +++++++++++ src/libslic3r/PrintConfig.hpp | 1 + src/libslic3r/PrintObject.cpp | 3 ++- src/slic3r/GUI/ConfigManipulation.cpp | 2 +- src/slic3r/GUI/GUI_Factories.cpp | 2 +- src/slic3r/GUI/Tab.cpp | 1 + 8 files changed, 19 insertions(+), 6 deletions(-) diff --git a/src/libslic3r/LayerRegion.cpp b/src/libslic3r/LayerRegion.cpp index d674680822d..0c9102dea2b 100644 --- a/src/libslic3r/LayerRegion.cpp +++ b/src/libslic3r/LayerRegion.cpp @@ -295,8 +295,7 @@ void LayerRegion::process_external_surfaces(const Layer *lower_layer, const Poly #ifdef SLIC3R_DEBUG printf("Processing bridge at layer %zu:\n", this->layer()->id()); #endif - //BBS: use 0 as custom angle to enable auto detection all the time - double custom_angle = Geometry::deg2rad(0.0); + double custom_angle = Geometry::deg2rad(this->region().config().bridge_angle.value); if (bd.detect_angle(custom_angle)) { bridges[idx_last].bridge_angle = bd.angle; if (this->layer()->object()->has_support()) { diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 93cbf29ddd3..35dab643269 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -694,7 +694,7 @@ static std::vector s_Preset_print_options { "top_shell_layers", "top_shell_thickness", "bottom_shell_layers", "bottom_shell_thickness", "reduce_crossing_wall", "detect_thin_wall", "detect_overhang_wall", "seam_position", "wall_infill_order", "sparse_infill_density", "sparse_infill_pattern", "top_surface_pattern", "bottom_surface_pattern", - "infill_direction", + "infill_direction", "bridge_angle", "minimum_sparse_infill_area", "reduce_infill_retraction", "ironing_type", "ironing_flow", "ironing_speed", "ironing_spacing", "max_travel_detour_distance", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 06fae3401b9..01da464acbb 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -644,6 +644,17 @@ void PrintConfigDef::init_fff_params() def->enum_labels.emplace_back("95%"); def->set_default_value(new ConfigOptionEnumsGeneric{ (int)Overhang_threshold_bridge }); + def = this->add("bridge_angle", coFloat); + def->label = L("Bridge direction"); + def->category = L("Strength"); + def->tooltip = L("Bridging angle override. If left to zero, the bridging angle will be calculated " + "automatically. Otherwise the provided angle will be used for external bridges. " + "Use 180°for zero angle."); + def->sidetext = L("°"); + def->min = 0; + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionFloat(0.)); + def = this->add("bridge_flow", coFloat); def->label = L("Bridge flow"); def->category = L("Quality"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 1d4bb3b21b6..a7d1010dc54 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -658,6 +658,7 @@ PRINT_CONFIG_CLASS_DEFINE( ((ConfigOptionInt, bottom_shell_layers)) ((ConfigOptionFloat, bottom_shell_thickness)) + ((ConfigOptionFloat, bridge_angle)) ((ConfigOptionFloat, bridge_flow)) ((ConfigOptionFloat, bridge_speed)) ((ConfigOptionEnum, top_surface_pattern)) diff --git a/src/libslic3r/PrintObject.cpp b/src/libslic3r/PrintObject.cpp index 1eb3a81487d..a65d4a01a70 100644 --- a/src/libslic3r/PrintObject.cpp +++ b/src/libslic3r/PrintObject.cpp @@ -769,7 +769,8 @@ bool PrintObject::invalidate_state_by_config_options( || opt_key == "minimum_sparse_infill_area" || opt_key == "sparse_infill_filament" || opt_key == "solid_infill_filament" - || opt_key == "sparse_infill_line_width") { + || opt_key == "sparse_infill_line_width" + || opt_key == "bridge_angle") { steps.emplace_back(posPrepareInfill); } else if ( opt_key == "top_surface_pattern" diff --git a/src/slic3r/GUI/ConfigManipulation.cpp b/src/slic3r/GUI/ConfigManipulation.cpp index 59ae45012b1..e18f51e6eba 100644 --- a/src/slic3r/GUI/ConfigManipulation.cpp +++ b/src/slic3r/GUI/ConfigManipulation.cpp @@ -488,7 +488,7 @@ void ConfigManipulation::toggle_print_fff_options(DynamicPrintConfig *config, co for (auto el : { "top_surface_pattern", "bottom_surface_pattern", "solid_infill_filament"}) toggle_field(el, has_solid_infill); - for (auto el : { "infill_direction", "sparse_infill_line_width", + for (auto el : { "infill_direction", "sparse_infill_line_width", "bridge_angle", "sparse_infill_speed", "bridge_speed" }) toggle_field(el, have_infill || has_solid_infill); diff --git a/src/slic3r/GUI/GUI_Factories.cpp b/src/slic3r/GUI/GUI_Factories.cpp index ff43047f38b..d895e63483d 100644 --- a/src/slic3r/GUI/GUI_Factories.cpp +++ b/src/slic3r/GUI/GUI_Factories.cpp @@ -94,7 +94,7 @@ std::map> SettingsFactory::PART_CAT { L("Strength"), {{"wall_loops", "",1},{"top_shell_layers", L("Top Solid Layers"),1},{"top_shell_thickness", L("Top Minimum Shell Thickness"),1}, {"bottom_shell_layers", L("Bottom Solid Layers"),1}, {"bottom_shell_thickness", L("Bottom Minimum Shell Thickness"),1}, {"sparse_infill_density", "",1},{"sparse_infill_pattern", "",1},{"top_surface_pattern", "",1},{"bottom_surface_pattern", "",1}, - {"infill_combination", "",1}, {"infill_wall_overlap", "",1}, {"infill_direction", "",1}, {"minimum_sparse_infill_area", "",1} + {"infill_combination", "",1}, {"infill_wall_overlap", "",1}, {"infill_direction", "",1}, {"bridge_angle", "",1},{"minimum_sparse_infill_area", "",1} }}, { L("Speed"), {{"outer_wall_speed", "",1},{"inner_wall_speed", "",2},{"sparse_infill_speed", "",3},{"top_surface_speed", "",4}, {"internal_solid_infill_speed", "",5}, {"enable_overhang_speed", "",6}, {"overhang_1_4_speed", "",7}, {"overhang_2_4_speed", "",8}, {"overhang_3_4_speed", "",9}, {"overhang_4_4_speed", "",10}, diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 34e6223dbcd..362c427cc68 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -1805,6 +1805,7 @@ void TabPrint::build() optgroup = page->new_optgroup(L("Advanced"), L"param_advanced"); optgroup->append_single_option_line("infill_wall_overlap"); optgroup->append_single_option_line("infill_direction"); + optgroup->append_single_option_line("bridge_angle"); optgroup->append_single_option_line("minimum_sparse_infill_area"); optgroup->append_single_option_line("infill_combination"); optgroup->append_single_option_line("detect_narrow_internal_solid_infill");