From 1cb1c12812316b3950af395bccbc1c9b403a0522 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Fri, 8 Mar 2019 11:39:34 +0100 Subject: [PATCH] Fine tuning the new parameters and adding max_pillar_link_distance --- src/libslic3r/PrintConfig.cpp | 9 +++++++++ src/libslic3r/PrintConfig.hpp | 4 ++++ src/libslic3r/SLA/SLASupportTree.cpp | 23 +++++++++++++++-------- src/libslic3r/SLA/SLASupportTree.hpp | 5 ++++- src/libslic3r/SLAPrint.cpp | 2 ++ src/libslic3r/SLAPrint.hpp | 7 +++++-- src/slic3r/GUI/Preset.cpp | 1 + src/slic3r/GUI/Tab.cpp | 1 + 8 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/libslic3r/PrintConfig.cpp b/src/libslic3r/PrintConfig.cpp index 1c78a3e310..d6e66cd678 100644 --- a/src/libslic3r/PrintConfig.cpp +++ b/src/libslic3r/PrintConfig.cpp @@ -2672,6 +2672,15 @@ void PrintConfigDef::init_sla_params() def->min = 0; def->default_value = new ConfigOptionFloat(15.0); + def = this->add("support_max_pillar_link_distance", coFloat); + def->label = L("Max pillar linking distance"); + def->category = L("Supports"); + def->tooltip = L("The max distance of two pillars to get linked with each other."); + def->sidetext = L("mm"); + def->cli = ""; + def->min = 0; // 0 means no linking + def->default_value = new ConfigOptionFloat(10.0); + def = this->add("support_object_elevation", coFloat); def->label = L("Object elevation"); def->category = L("Supports"); diff --git a/src/libslic3r/PrintConfig.hpp b/src/libslic3r/PrintConfig.hpp index f4d9053a6b..7ddc3b8d6d 100644 --- a/src/libslic3r/PrintConfig.hpp +++ b/src/libslic3r/PrintConfig.hpp @@ -1006,6 +1006,9 @@ public: // The max length of a bridge in mm ConfigOptionFloat support_max_bridge_length /*= 15.0*/; + // The max distance of two pillars to get cross linked. + ConfigOptionFloat support_max_pillar_link_distance; + // The elevation in Z direction upwards. This is the space between the pad // and the model object's bounding box bottom. Units in mm. ConfigOptionFloat support_object_elevation /*= 5.0*/; @@ -1053,6 +1056,7 @@ protected: OPT_PTR(support_base_height); OPT_PTR(support_critical_angle); OPT_PTR(support_max_bridge_length); + OPT_PTR(support_max_pillar_link_distance); OPT_PTR(support_points_density_relative); OPT_PTR(support_points_minimal_distance); OPT_PTR(support_object_elevation); diff --git a/src/libslic3r/SLA/SLASupportTree.cpp b/src/libslic3r/SLA/SLASupportTree.cpp index e145cf64a3..c52f82654d 100644 --- a/src/libslic3r/SLA/SLASupportTree.cpp +++ b/src/libslic3r/SLA/SLASupportTree.cpp @@ -71,7 +71,7 @@ const double SupportConfig::normal_cutoff_angle = 150.0 * M_PI / 180.0; // The shortest distance of any support structure from the model surface const double SupportConfig::safety_distance_mm = 0.1; -const double SupportConfig::max_solo_pillar_height_mm = 5.0; +const double SupportConfig::max_solo_pillar_height_mm = 15.0; const double SupportConfig::max_dual_pillar_height_mm = 35.0; const double SupportConfig::optimizer_rel_score_diff = 1e-6; const unsigned SupportConfig::optimizer_max_iterations = 500; @@ -678,11 +678,15 @@ public: } void increment_bridges(const Pillar& pillar) { + assert(pillar.id >= 0 && size_t(pillar.id) < m_pillars.size()); + if(pillar.id >= 0 && size_t(pillar.id) < m_pillars.size()) m_pillars[size_t(pillar.id)].bridges++; } void increment_links(const Pillar& pillar) { + assert(pillar.id >= 0 && size_t(pillar.id) < m_pillars.size()); + if(pillar.id >= 0 && size_t(pillar.id) < m_pillars.size()) m_pillars[size_t(pillar.id)].links++; } @@ -1169,8 +1173,8 @@ class SLASupportTree::Algorithm { double bridge_distance = pillar_dist / std::cos(-m_cfg.bridge_slope); double zstep = pillar_dist * std::tan(-m_cfg.bridge_slope); - if(pillar_dist < 2*m_cfg.head_back_radius_mm) return false; - if(bridge_distance > m_cfg.max_bridge_length_mm) return false; + if(pillar_dist < 2 * m_cfg.head_back_radius_mm || + pillar_dist > m_cfg.max_pillar_link_distance_mm) return false; if(supper(Z) < slower(Z)) supper.swap(slower); if(eupper(Z) < elower(Z)) eupper.swap(elower); @@ -1659,8 +1663,8 @@ public: // Could not find a pillar, create one auto& pillar = m_result.add_pillar(unsigned(sidehead.id), pend, pradius) - .add_base(m_cfg.base_height_mm, - m_cfg.base_radius_mm); + .add_base(m_cfg.base_height_mm, + m_cfg.base_radius_mm); // connects to ground, eligible for bridging m_pillar_index.insert(pend, unsigned(pillar.id)); @@ -1962,7 +1966,7 @@ public: alpha += 0.1 * PI; } - std::vector> newpills; + std::vector newpills; newpills.reserve(needpillars); if(found) for(unsigned n = 0; n < needpillars; n++) { @@ -1982,13 +1986,16 @@ public: if(pillar.endpoint()(Z) > m_result.ground_level) m_result.add_junction(pillar.endpoint(), pillar.r); - newpills.emplace_back(pp); + newpills.emplace_back(pp.id); } } if(!newpills.empty()) for(auto it = newpills.begin(), nx = std::next(it); - nx != newpills.end(); ++it, ++nx) interconnect(*it, *nx); + nx != newpills.end(); ++it, ++nx) { + interconnect(m_result.pillars()[size_t(*it)], + m_result.pillars()[size_t(*nx)]); + } } } diff --git a/src/libslic3r/SLA/SLASupportTree.hpp b/src/libslic3r/SLA/SLASupportTree.hpp index fb54252502..74d7da9cad 100644 --- a/src/libslic3r/SLA/SLASupportTree.hpp +++ b/src/libslic3r/SLA/SLASupportTree.hpp @@ -72,7 +72,10 @@ struct SupportConfig { double bridge_slope = M_PI/4; // The max length of a bridge in mm - double max_bridge_length_mm = 15.0; + double max_bridge_length_mm = 10.0; + + // The max distance of a pillar to pillar link. + double max_pillar_link_distance_mm = 10.0; // The elevation in Z direction upwards. This is the space between the pad // and the model object's bounding box bottom. diff --git a/src/libslic3r/SLAPrint.cpp b/src/libslic3r/SLAPrint.cpp index 469e7a8fff..82b499ec75 100644 --- a/src/libslic3r/SLAPrint.cpp +++ b/src/libslic3r/SLAPrint.cpp @@ -546,6 +546,7 @@ sla::SupportConfig make_support_cfg(const SLAPrintObjectConfig& c) { scfg.object_elevation_mm = c.support_object_elevation.getFloat(); scfg.bridge_slope = c.support_critical_angle.getFloat() * PI / 180.0 ; scfg.max_bridge_length_mm = c.support_max_bridge_length.getFloat(); + scfg.max_pillar_link_distance_mm = c.support_max_pillar_link_distance.getFloat(); switch(c.support_pillar_connection_mode.getInt()) { case slapcmZigZag: scfg.pillar_connection_mode = sla::PillarConnectionMode::zigzag; break; @@ -1386,6 +1387,7 @@ bool SLAPrintObject::invalidate_state_by_config_options(const std::vector &opt_keys); + std::vector calculate_heights(const BoundingBoxf3& bb, + float elevation, + float initial_layer_height, + float layer_height) const; + void fill_statistics(); SLAPrintConfig m_print_config; @@ -270,8 +275,6 @@ private: lref(std::cref(lyr)), copies(std::cref(cp)) {} }; - std::vector calculate_heights(const BoundingBoxf3& bb, float elevation, float initial_layer_height, float layer_height) const; - // One level may contain multiple slices from multiple objects and their // supports using LayerRefs = std::vector; diff --git a/src/slic3r/GUI/Preset.cpp b/src/slic3r/GUI/Preset.cpp index 37b495a363..4902b5552e 100644 --- a/src/slic3r/GUI/Preset.cpp +++ b/src/slic3r/GUI/Preset.cpp @@ -457,6 +457,7 @@ const std::vector& Preset::sla_print_options() "support_base_height", "support_critical_angle", "support_max_bridge_length", + "support_max_pillar_link_distance", "support_object_elevation", "support_points_density_relative", "support_points_minimal_distance", diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index 060eb13833..a7b1af75de 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3277,6 +3277,7 @@ void TabSLAPrint::build() optgroup = page->new_optgroup(_(L("Connection of the support sticks and junctions"))); optgroup->append_single_option_line("support_critical_angle"); optgroup->append_single_option_line("support_max_bridge_length"); + optgroup->append_single_option_line("support_max_pillar_link_distance"); optgroup = page->new_optgroup(_(L("Automatic generation"))); optgroup->append_single_option_line("support_points_density_relative");