From bef64ecec083a2c2e59bd18e373652c597bd6c35 Mon Sep 17 00:00:00 2001 From: tamasmeszaros Date: Mon, 24 Oct 2022 15:20:45 +0200 Subject: [PATCH] Don't call search_ground_route for every ground point candidate search_ground_route already tries to find a suitable ground point globally from the source. Different destination arguments will not help much but will cause a lot of redundant cpu burning SPE-1303 --- src/libslic3r/BranchingTree/BranchingTree.cpp | 2 +- src/libslic3r/BranchingTree/BranchingTree.hpp | 1 - src/libslic3r/SLA/BranchingTreeSLA.cpp | 14 +++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/libslic3r/BranchingTree/BranchingTree.cpp b/src/libslic3r/BranchingTree/BranchingTree.cpp index 6463a30de..3e5e0a686 100644 --- a/src/libslic3r/BranchingTree/BranchingTree.cpp +++ b/src/libslic3r/BranchingTree/BranchingTree.cpp @@ -5,7 +5,7 @@ #include #include -#include "libslic3r/SLA/SupportTreeUtils.hpp" +#include "libslic3r/TriangleMesh.hpp" namespace Slic3r { namespace branchingtree { diff --git a/src/libslic3r/BranchingTree/BranchingTree.hpp b/src/libslic3r/BranchingTree/BranchingTree.hpp index c88410b3a..b54d47ca2 100644 --- a/src/libslic3r/BranchingTree/BranchingTree.hpp +++ b/src/libslic3r/BranchingTree/BranchingTree.hpp @@ -5,7 +5,6 @@ #include #include "libslic3r/ExPolygon.hpp" -#include "libslic3r/BoundingBox.hpp" namespace Slic3r { namespace branchingtree { diff --git a/src/libslic3r/SLA/BranchingTreeSLA.cpp b/src/libslic3r/SLA/BranchingTreeSLA.cpp index 72314c9d8..59ec05113 100644 --- a/src/libslic3r/SLA/BranchingTreeSLA.cpp +++ b/src/libslic3r/SLA/BranchingTreeSLA.cpp @@ -18,6 +18,8 @@ class BranchingTreeBuilder: public branchingtree::Builder { const SupportableMesh &m_sm; const branchingtree::PointCloud &m_cloud; + std::set m_ground_mem; + // Scaling of the input value 'widening_factor:<0, 1>' to produce resonable // widening behaviour static constexpr double WIDENING_SCALE = 0.02; @@ -156,11 +158,21 @@ bool BranchingTreeBuilder::add_merger(const branchingtree::Node &node, bool BranchingTreeBuilder::add_ground_bridge(const branchingtree::Node &from, const branchingtree::Node &to) { - bool ret = search_ground_route(ex_tbb, m_builder, m_sm, + bool ret = false; + + auto it = m_ground_mem.find(from.id); + if (it == m_ground_mem.end()) { + ret = search_ground_route(ex_tbb, m_builder, m_sm, sla::Junction{from.pos.cast(), get_radius(from)}, get_radius(to)).first; + // Remember that this node was tested if can go to ground, don't + // test it with any other destination ground point because + // it is unlikely that search_ground_route would find a better solution + m_ground_mem.insert(from.id); + } + if (ret) { build_subtree(from.id); }