diff options
author | Nino van Hooff <ninovanhooff@gmail.com> | 2019-10-02 14:07:11 +0300 |
---|---|---|
committer | Nino van Hooff <ninovanhooff@gmail.com> | 2019-10-02 14:09:37 +0300 |
commit | 95120300601c5a8391a3909c7291f95248d35052 (patch) | |
tree | 5d9b34864868740756dbdc8d030b1a056cb2066e | |
parent | 7bf2fa3b43d1ffe30af1f6161d37ceb8ed09d905 (diff) |
Check for adhesion area collisions in one-at-a-time ordering
CURA-6785
-rw-r--r-- | cura/OneAtATimeIterator.py | 16 | ||||
-rw-r--r-- | cura/Scene/ConvexHullDecorator.py | 13 |
2 files changed, 26 insertions, 3 deletions
diff --git a/cura/OneAtATimeIterator.py b/cura/OneAtATimeIterator.py index a61ce492a9..4d420f6d05 100644 --- a/cura/OneAtATimeIterator.py +++ b/cura/OneAtATimeIterator.py @@ -92,12 +92,24 @@ class OneAtATimeIterator(Iterator.Iterator): score_b = sum(self._hit_map[self._original_node_list.index(b)]) return score_a - score_b - # Checks if A can be printed before B + ## Checks if A can be printed before B def _checkHit(self, a: SceneNode, b: SceneNode) -> bool: if a == b: return False - overlap = a.callDecoration("getConvexHullBoundary").intersectsPolygon(b.callDecoration("getConvexHullHeadFull")) + a_hit_hull = a.callDecoration("getConvexHullBoundary") + b_hit_hull = b.callDecoration("getConvexHullHeadFull") + overlap = a_hit_hull.intersectsPolygon(b_hit_hull) + + if overlap: + return True + + # Adhesion areas must never overlap, regardless of printing order + # This would cause over-extrusion + a_hit_hull = a.callDecoration("getAdhesionArea") + b_hit_hull = b.callDecoration("getAdhesionArea") + overlap = a_hit_hull.intersectsPolygon(b_hit_hull) + if overlap: return True else: diff --git a/cura/Scene/ConvexHullDecorator.py b/cura/Scene/ConvexHullDecorator.py index bde7cde807..c263726d07 100644 --- a/cura/Scene/ConvexHullDecorator.py +++ b/cura/Scene/ConvexHullDecorator.py @@ -76,7 +76,18 @@ class ConvexHullDecorator(SceneNodeDecorator): def __deepcopy__(self, memo): return ConvexHullDecorator() - ## Get the unmodified 2D projected convex hull of the node (if any) + + ## The polygon representing the 2D adhesion area. + # If no adhesion is used, the regular convex hull is returned + def getAdhesionArea(self) -> Optional[Polygon]: + if self._node is None: + return None + + hull = self._compute2DConvexHull() + return self._add2DAdhesionMargin(hull) + + + ## Get the unmodified 2D projected convex hull with 2D adhesion area of the node (if any) def getConvexHull(self) -> Optional[Polygon]: if self._node is None: return None |