mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-10 22:01:48 +08:00
Try routing unsuccessful branches to ground recursively
This helps to avoid huge branches being discarded where there is an obvious route to ground for a sub-branch. Should improve SPE-1311
This commit is contained in:
parent
31fb0ae049
commit
f5c1623642
@ -259,9 +259,9 @@ template<class PC, class Fn> void traverse(PC &&pc, size_t root, Fn &&fn)
|
||||
{
|
||||
if (auto nodeptr = pc.find(root); nodeptr != nullptr) {
|
||||
auto &nroot = *nodeptr;
|
||||
fn(nroot);
|
||||
if (nroot.left >= 0) traverse(pc, nroot.left, fn);
|
||||
if (nroot.right >= 0) traverse(pc, nroot.right, fn);
|
||||
bool r = fn(nroot);
|
||||
if (r && nroot.left >= 0) traverse(pc, nroot.left, fn);
|
||||
if (r && nroot.right >= 0) traverse(pc, nroot.right, fn);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -61,22 +61,41 @@ class BranchingTreeBuilder: public branchingtree::Builder {
|
||||
toR);
|
||||
m_builder.add_junction(tod, toR);
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
void discard_subtree(size_t root)
|
||||
{
|
||||
// Discard all the support points connecting to this branch.
|
||||
// As a last resort, try to route child nodes to ground and stop
|
||||
// traversing if any child branch succeeds.
|
||||
traverse(m_cloud, root, [this](const branchingtree::Node &node) {
|
||||
bool ret = true;
|
||||
|
||||
int suppid_parent = m_cloud.get_leaf_id(node.id);
|
||||
int suppid_left = m_cloud.get_leaf_id(node.left);
|
||||
int suppid_right = m_cloud.get_leaf_id(node.right);
|
||||
int suppid_left = branchingtree::Node::ID_NONE;
|
||||
int suppid_right = branchingtree::Node::ID_NONE;
|
||||
|
||||
if (node.left >= 0 && add_ground_bridge(m_cloud.get(node.left), node))
|
||||
ret = false;
|
||||
else
|
||||
suppid_left = m_cloud.get_leaf_id(node.left);
|
||||
|
||||
if (node.right >= 0 && add_ground_bridge(m_cloud.get(node.right), node))
|
||||
ret = false;
|
||||
else
|
||||
suppid_right = m_cloud.get_leaf_id(node.right);
|
||||
|
||||
if (suppid_parent >= 0)
|
||||
m_unroutable_pinheads.emplace_back(suppid_parent);
|
||||
if (suppid_left >= 0)
|
||||
m_unroutable_pinheads.emplace_back(suppid_left);
|
||||
if (suppid_right >= 0)
|
||||
m_unroutable_pinheads.emplace_back(suppid_right);
|
||||
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user