diff --git a/src/libslic3r/BranchingTree/BranchingTree.cpp b/src/libslic3r/BranchingTree/BranchingTree.cpp index 3026c3d75..b101f38aa 100644 --- a/src/libslic3r/BranchingTree/BranchingTree.cpp +++ b/src/libslic3r/BranchingTree/BranchingTree.cpp @@ -20,7 +20,7 @@ void build_tree(PointCloud &nodes, Builder &builder) auto distances = reserve_vector(ReachablesToExamine); double prev_dist_max = 0.; - while (!ptsqueue.empty()) { + while (!ptsqueue.empty() && builder.is_valid()) { size_t node_id = ptsqueue.top(); Node node = nodes.get(node_id); @@ -49,7 +49,7 @@ void build_tree(PointCloud &nodes, Builder &builder) auto closest_it = distances.begin(); bool routed = false; - while (closest_it != distances.end() && !routed) { + while (closest_it != distances.end() && !routed && builder.is_valid()) { size_t closest_node_id = closest_it->node_id; Node closest_node = nodes.get(closest_node_id); diff --git a/src/libslic3r/BranchingTree/BranchingTree.hpp b/src/libslic3r/BranchingTree/BranchingTree.hpp index d2eabc7ee..c88410b3a 100644 --- a/src/libslic3r/BranchingTree/BranchingTree.hpp +++ b/src/libslic3r/BranchingTree/BranchingTree.hpp @@ -102,6 +102,9 @@ public: // Report nodes that can not be routed to an endpoint (model or ground) virtual void report_unroutable(const Node &j) = 0; + + // If returns false, the tree building process shall stop + virtual bool is_valid() const { return true; } }; // Build the actual tree. diff --git a/src/libslic3r/SLA/BranchingTreeSLA.cpp b/src/libslic3r/SLA/BranchingTreeSLA.cpp index f90ba58fb..3f5e61b87 100644 --- a/src/libslic3r/SLA/BranchingTreeSLA.cpp +++ b/src/libslic3r/SLA/BranchingTreeSLA.cpp @@ -111,6 +111,8 @@ public: { return m_unroutable_pinheads; } + + bool is_valid() const override { return !m_builder.ctl().stopcondition(); } }; bool BranchingTreeBuilder::add_bridge(const branchingtree::Node &from,