From b1317be78aae479be5696017e61e730b5d2f0b60 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 9 May 2022 15:32:57 +0200 Subject: [PATCH] Selectable support tree type --- src/libslic3r/Preset.cpp | 1 + src/libslic3r/PrintConfig.cpp | 19 ++++++++++++++++++- src/libslic3r/PrintConfig.hpp | 3 +++ src/libslic3r/SLA/SupportTreeStrategies.hpp | 2 +- src/libslic3r/SLAPrint.cpp | 2 ++ src/slic3r/GUI/ConfigManipulation.cpp | 1 + src/slic3r/GUI/Tab.cpp | 4 ++-- tests/sla_print/sla_print_tests.cpp | 16 ++++++++-------- 8 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/libslic3r/Preset.cpp b/src/libslic3r/Preset.cpp index 092c0ed9b1..db6ebe62cc 100644 --- a/src/libslic3r/Preset.cpp +++ b/src/libslic3r/Preset.cpp @@ -493,6 +493,7 @@ static std::vector s_Preset_sla_print_options { "layer_height", "faded_layers", "supports_enable", + "support_tree_type", "support_head_front_diameter", "support_head_penetration", "support_head_width", diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index bd4f98dfdd..302a9eb6f1 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -176,6 +176,12 @@ static const t_config_enum_values s_keys_map_SLAMaterialSpeed = { }; CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(SLAMaterialSpeed); +static inline const t_config_enum_values s_keys_map_SLASupportTreeType = { + {"default", int(sla::SupportTreeType::Default)}, + {"branching", int(sla::SupportTreeType::Branching)} +}; +CONFIG_OPTION_ENUM_DEFINE_STATIC_MAPS(SLASupportTreeType); + static const t_config_enum_values s_keys_map_BrimType = { {"no_brim", btNoBrim}, {"outer_only", btOuterOnly}, @@ -3564,6 +3570,17 @@ void PrintConfigDef::init_sla_params() def->mode = comSimple; def->set_default_value(new ConfigOptionBool(true)); + def = this->add("support_tree_type", coEnum); + def->label = L("Support tree type"); + def->tooltip = L("Support tree building strategy"); + def->enum_keys_map = &ConfigOptionEnum::get_enum_values(); + def->enum_values = ConfigOptionEnum::get_enum_names(); + def->enum_labels = ConfigOptionEnum::get_enum_names(); + def->enum_labels[0] = L("Default"); + def->enum_labels[1] = L("Branching"); + def->mode = comAdvanced; + def->set_default_value(new ConfigOptionEnum(sla::SupportTreeType::Default)); + def = this->add("support_head_front_diameter", coFloat); def->label = L("Pinhead front diameter"); def->category = L("Supports"); @@ -3655,7 +3672,7 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->max = 1; def->mode = comExpert; - def->set_default_value(new ConfigOptionFloat(0.0)); + def->set_default_value(new ConfigOptionFloat(0.1)); def = this->add("support_base_diameter", coFloat); def->label = L("Support base diameter"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index 9e1d7989d4..5ec1635725 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -155,6 +155,7 @@ CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(SupportMaterialInterfacePattern) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(SeamPosition) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(SLADisplayOrientation) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(SLAPillarConnectionMode) +CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(SLASupportTreeType) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(BrimType) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(DraftShield) CONFIG_OPTION_ENUM_DECLARE_STATIC_MAPS(GCodeThumbnailsFormat) @@ -829,6 +830,8 @@ PRINT_CONFIG_CLASS_DEFINE( // Enabling or disabling support creation ((ConfigOptionBool, supports_enable)) + ((ConfigOptionEnum, support_tree_type)) + // Diameter in mm of the pointing side of the head. ((ConfigOptionFloat, support_head_front_diameter))/*= 0.2*/ diff --git a/src/libslic3r/SLA/SupportTreeStrategies.hpp b/src/libslic3r/SLA/SupportTreeStrategies.hpp index d04ceaa2d0..487f43575b 100644 --- a/src/libslic3r/SLA/SupportTreeStrategies.hpp +++ b/src/libslic3r/SLA/SupportTreeStrategies.hpp @@ -5,7 +5,7 @@ namespace Slic3r { namespace sla { -enum class SupportTreeType { Default, Clever }; +enum class SupportTreeType { Default, Branching }; enum class PillarConnectionMode { zigzag, cross, dynamic }; }} // namespace Slic3r::sla diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 9ad5453384..d9b8e33df0 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -43,6 +43,7 @@ sla::SupportTreeConfig make_support_cfg(const SLAPrintObjectConfig& c) sla::SupportTreeConfig scfg; scfg.enabled = c.supports_enable.getBool(); + scfg.tree_type = c.support_tree_type.value; scfg.head_front_radius_mm = 0.5*c.support_head_front_diameter.getFloat(); double pillar_r = 0.5 * c.support_pillar_diameter.getFloat(); scfg.head_back_radius_mm = pillar_r; @@ -824,6 +825,7 @@ bool SLAPrintObject::invalidate_state_by_config_options(const std::vectornew_optgroup(L("Supports")); optgroup->append_single_option_line("supports_enable"); + optgroup->append_single_option_line("support_tree_type"); optgroup = page->new_optgroup(L("Support head")); optgroup->append_single_option_line("support_head_front_diameter"); @@ -4650,8 +4651,7 @@ void TabSLAPrint::build() optgroup->append_single_option_line("support_pillar_connection_mode"); optgroup->append_single_option_line("support_buildplate_only"); - // TODO: This parameter is not used at the moment. - // optgroup->append_single_option_line("support_pillar_widening_factor"); + optgroup->append_single_option_line("support_pillar_widening_factor"); optgroup->append_single_option_line("support_base_diameter"); optgroup->append_single_option_line("support_base_height"); optgroup->append_single_option_line("support_base_safety_distance"); diff --git a/tests/sla_print/sla_print_tests.cpp b/tests/sla_print/sla_print_tests.cpp index a5ed0d0291..8ae02c8085 100644 --- a/tests/sla_print/sla_print_tests.cpp +++ b/tests/sla_print/sla_print_tests.cpp @@ -156,37 +156,37 @@ TEST_CASE("DefaultSupports::FloorSupportsDoNotPierceModel", "[SLASupportGenerati test_support_model_collision(fname, supportcfg); } -//TEST_CASE("CleverSupports::ElevatedSupportGeometryIsValid", "[SLASupportGeneration][Clever]") { +//TEST_CASE("BranchingSupports::ElevatedSupportGeometryIsValid", "[SLASupportGeneration][Branching]") { // sla::SupportTreeConfig supportcfg; // supportcfg.object_elevation_mm = 10.; -// supportcfg.tree_type = sla::SupportTreeType::Clever; +// supportcfg.tree_type = sla::SupportTreeType::Branching; // for (auto fname : SUPPORT_TEST_MODELS) test_supports(fname, supportcfg); //} -//TEST_CASE("CleverSupports::FloorSupportGeometryIsValid", "[SLASupportGeneration][Clever]") { +//TEST_CASE("BranchingSupports::FloorSupportGeometryIsValid", "[SLASupportGeneration][Branching]") { // sla::SupportTreeConfig supportcfg; // supportcfg.object_elevation_mm = 0; -// supportcfg.tree_type = sla::SupportTreeType::Clever; +// supportcfg.tree_type = sla::SupportTreeType::Branching; // for (auto &fname: SUPPORT_TEST_MODELS) test_supports(fname, supportcfg); //} -TEST_CASE("CleverSupports::ElevatedSupportsDoNotPierceModel", "[SLASupportGeneration][Clever]") { +TEST_CASE("BranchingSupports::ElevatedSupportsDoNotPierceModel", "[SLASupportGeneration][Branching]") { sla::SupportTreeConfig supportcfg; supportcfg.object_elevation_mm = 10.; - supportcfg.tree_type = sla::SupportTreeType::Clever; + supportcfg.tree_type = sla::SupportTreeType::Branching; for (auto fname : SUPPORT_TEST_MODELS) test_support_model_collision(fname, supportcfg); } -TEST_CASE("CleverSupports::FloorSupportsDoNotPierceModel", "[SLASupportGeneration][Clever]") { +TEST_CASE("BranchingSupports::FloorSupportsDoNotPierceModel", "[SLASupportGeneration][Branching]") { sla::SupportTreeConfig supportcfg; supportcfg.object_elevation_mm = 0; - supportcfg.tree_type = sla::SupportTreeType::Clever; + supportcfg.tree_type = sla::SupportTreeType::Branching; for (auto fname : SUPPORT_TEST_MODELS) test_support_model_collision(fname, supportcfg);