mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
Merge branch '3.2'
This commit is contained in:
commit
b0d0b75662
7 changed files with 66 additions and 58 deletions
|
@ -1,8 +1,9 @@
|
|||
# Copyright (c) 2018 Ultimaker B.V.
|
||||
# Copyright (c) 2017 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from cura.Scene.CuraSceneNode import CuraSceneNode
|
||||
from cura.Settings.ExtruderManager import ExtruderManager
|
||||
from UM.Settings.ContainerRegistry import ContainerRegistry
|
||||
from UM.i18n import i18nCatalog
|
||||
from UM.Scene.Platform import Platform
|
||||
from UM.Scene.Iterator.BreadthFirstIterator import BreadthFirstIterator
|
||||
|
@ -194,51 +195,52 @@ class BuildVolume(SceneNode):
|
|||
|
||||
return True
|
||||
|
||||
## For every sliceable node, update node._outside_buildarea.
|
||||
def updateAllBoundaryChecks(self):
|
||||
self.updateNodeBoundaryCheck(Application.getInstance().getController().getScene().getRoot())
|
||||
|
||||
## For a single node, update _outside_buildarea.
|
||||
## For every sliceable node, update node._outside_buildarea
|
||||
#
|
||||
# If the node is a group node, the child nodes will also get updated.
|
||||
# \param node The node to update the boundary checks of.
|
||||
def updateNodeBoundaryCheck(self, node: SceneNode):
|
||||
if not node.callDecoration("isSliceable") and not node.callDecoration("isGroup"):
|
||||
for child in node.getChildren(): #Still update the children! For instance, the root is not sliceable.
|
||||
self.updateNodeBoundaryCheck(child)
|
||||
return #Don't compute for non-sliceable nodes.
|
||||
def updateNodeBoundaryCheck(self):
|
||||
root = Application.getInstance().getController().getScene().getRoot()
|
||||
nodes = list(BreadthFirstIterator(root))
|
||||
group_nodes = []
|
||||
|
||||
#Mark the node as outside the build volume if the bounding box test fails.
|
||||
build_volume = self.getBoundingBox()
|
||||
if build_volume is None:
|
||||
#No bounding box. This is triggered when running Cura from command line with a model for the first time.
|
||||
#In that situation there is a model, but no machine (and therefore no build volume).
|
||||
build_volume_bounding_box = self.getBoundingBox()
|
||||
if build_volume_bounding_box:
|
||||
# It's over 9000!
|
||||
build_volume_bounding_box = build_volume_bounding_box.set(bottom=-9001)
|
||||
else:
|
||||
# No bounding box. This is triggered when running Cura from command line with a model for the first time
|
||||
# In that situation there is a model, but no machine (and therefore no build volume.
|
||||
return
|
||||
build_volume = build_volume.set(bottom = -999999) #Allow models to clip the build plate. This should allow printing but remove the bottom side of the model underneath the build plate.
|
||||
bounding_box = node.getBoundingBox()
|
||||
if build_volume.intersectsBox(bounding_box) != AxisAlignedBox.IntersectionResult.FullIntersection:
|
||||
node._outside_buildarea = True
|
||||
else:
|
||||
|
||||
#Check for collisions between disallowed areas and the object.
|
||||
convex_hull = node.callDecoration("getConvexHull")
|
||||
if not convex_hull or not convex_hull.isValid():
|
||||
return
|
||||
for area in self.getDisallowedAreas():
|
||||
overlap = convex_hull.intersectsPolygon(area)
|
||||
if overlap is not None:
|
||||
node._outside_buildarea = True
|
||||
break
|
||||
else:
|
||||
for node in nodes:
|
||||
# Need to check group nodes later
|
||||
if node.callDecoration("isGroup"):
|
||||
group_nodes.append(node) # Keep list of affected group_nodes
|
||||
|
||||
if node.callDecoration("isSliceable") or node.callDecoration("isGroup"):
|
||||
node._outside_buildarea = False
|
||||
bbox = node.getBoundingBox()
|
||||
|
||||
#Group nodes should override the _outside_buildarea property of their children.
|
||||
if node.callDecoration("isGroup"):
|
||||
for child in node.getAllChildren():
|
||||
child._outside_buildarea = node._outside_buildarea
|
||||
else:
|
||||
for child in node.getChildren():
|
||||
self.updateNodeBoundaryCheck(child)
|
||||
# Mark the node as outside the build volume if the bounding box test fails.
|
||||
if build_volume_bounding_box.intersectsBox(bbox) != AxisAlignedBox.IntersectionResult.FullIntersection:
|
||||
node._outside_buildarea = True
|
||||
continue
|
||||
|
||||
convex_hull = node.callDecoration("getConvexHull")
|
||||
if convex_hull:
|
||||
if not convex_hull.isValid():
|
||||
return
|
||||
# Check for collisions between disallowed areas and the object
|
||||
for area in self.getDisallowedAreas():
|
||||
overlap = convex_hull.intersectsPolygon(area)
|
||||
if overlap is None:
|
||||
continue
|
||||
node._outside_buildarea = True
|
||||
continue
|
||||
|
||||
# Group nodes should override the _outside_buildarea property of their children.
|
||||
for group_node in group_nodes:
|
||||
for child_node in group_node.getAllChildren():
|
||||
child_node._outside_buildarea = group_node._outside_buildarea
|
||||
|
||||
## Update the outsideBuildArea of a single node, given bounds or current build volume
|
||||
def checkBoundsAndUpdate(self, node: CuraSceneNode, bounds: Optional[AxisAlignedBox] = None):
|
||||
|
@ -461,7 +463,7 @@ class BuildVolume(SceneNode):
|
|||
|
||||
Application.getInstance().getController().getScene()._maximum_bounds = scale_to_max_bounds
|
||||
|
||||
self.updateAllBoundaryChecks()
|
||||
self.updateNodeBoundaryCheck()
|
||||
|
||||
def getBoundingBox(self) -> AxisAlignedBox:
|
||||
return self._volume_aabb
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue