Merge pull request #7971 from Ultimaker/CURA-7106-Speedup-multiple-objects-on-build-plate

CURA-7106 Speedup multiple objects on build plate
This commit is contained in:
Konstantinos Karmas 2020-06-29 12:36:02 +02:00 committed by GitHub
commit c6fd25e7e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 229 additions and 158 deletions

View file

@ -204,49 +204,50 @@ class ExtruderManager(QObject):
# If no extruders are registered in the extruder manager yet, return an empty array
if len(self.extruderIds) == 0:
return []
number_active_extruders = len([extruder for extruder in self.getActiveExtruderStacks() if extruder.isEnabled])
# Get the extruders of all printable meshes in the scene
meshes = [node for node in DepthFirstIterator(scene_root) if isinstance(node, SceneNode) and node.isSelectable()] #type: ignore #Ignore type error because iter() should get called automatically by Python syntax.
nodes = [node for node in DepthFirstIterator(scene_root) if node.isSelectable() and not node.callDecoration("isAntiOverhangMesh") and not node.callDecoration("isSupportMesh")] #type: ignore #Ignore type error because iter() should get called automatically by Python syntax.
# Exclude anti-overhang meshes
mesh_list = []
for mesh in meshes:
stack = mesh.callDecoration("getStack")
if stack is not None and (stack.getProperty("anti_overhang_mesh", "value") or stack.getProperty("support_mesh", "value")):
continue
mesh_list.append(mesh)
for mesh in mesh_list:
extruder_stack_id = mesh.callDecoration("getActiveExtruder")
for node in nodes:
extruder_stack_id = node.callDecoration("getActiveExtruder")
if not extruder_stack_id:
# No per-object settings for this node
extruder_stack_id = self.extruderIds["0"]
used_extruder_stack_ids.add(extruder_stack_id)
if len(used_extruder_stack_ids) == number_active_extruders:
# We're already done. Stop looking.
# Especially with a lot of models on the buildplate, this will speed up things rather dramatically.
break
# Get whether any of them use support.
stack_to_use = mesh.callDecoration("getStack") # if there is a per-mesh stack, we use it
stack_to_use = node.callDecoration("getStack") # if there is a per-mesh stack, we use it
if not stack_to_use:
# if there is no per-mesh stack, we use the build extruder for this mesh
stack_to_use = container_registry.findContainerStacks(id = extruder_stack_id)[0]
support_enabled |= stack_to_use.getProperty("support_enable", "value")
support_bottom_enabled |= stack_to_use.getProperty("support_bottom_enable", "value")
support_roof_enabled |= stack_to_use.getProperty("support_roof_enable", "value")
if not support_enabled:
support_enabled |= stack_to_use.getProperty("support_enable", "value")
if not support_bottom_enabled:
support_bottom_enabled |= stack_to_use.getProperty("support_bottom_enable", "value")
if not support_roof_enabled:
support_roof_enabled |= stack_to_use.getProperty("support_roof_enable", "value")
# Check limit to extruders
limit_to_extruder_feature_list = ["wall_0_extruder_nr",
"wall_x_extruder_nr",
"roofing_extruder_nr",
"top_bottom_extruder_nr",
"infill_extruder_nr",
]
for extruder_nr_feature_name in limit_to_extruder_feature_list:
extruder_nr = int(global_stack.getProperty(extruder_nr_feature_name, "value"))
if extruder_nr == -1:
continue
if str(extruder_nr) not in self.extruderIds:
extruder_nr = int(self._application.getMachineManager().defaultExtruderPosition)
used_extruder_stack_ids.add(self.extruderIds[str(extruder_nr)])
# Check limit to extruders
limit_to_extruder_feature_list = ["wall_0_extruder_nr",
"wall_x_extruder_nr",
"roofing_extruder_nr",
"top_bottom_extruder_nr",
"infill_extruder_nr",
]
for extruder_nr_feature_name in limit_to_extruder_feature_list:
extruder_nr = int(global_stack.getProperty(extruder_nr_feature_name, "value"))
if extruder_nr == -1:
continue
if str(extruder_nr) not in self.extruderIds:
extruder_nr = int(self._application.getMachineManager().defaultExtruderPosition)
used_extruder_stack_ids.add(self.extruderIds[str(extruder_nr)])
# Check support extruders
if support_enabled:

View file

@ -35,7 +35,7 @@ class SettingOverrideDecorator(SceneNodeDecorator):
"""
_non_thumbnail_visible_settings = {"anti_overhang_mesh", "infill_mesh", "cutting_mesh", "support_mesh"}
def __init__(self):
def __init__(self, *, force_update = True):
super().__init__()
self._stack = PerObjectContainerStack(container_id = "per_object_stack_" + str(id(self)))
self._stack.setDirty(False) # This stack does not need to be saved.
@ -46,6 +46,10 @@ class SettingOverrideDecorator(SceneNodeDecorator):
self._is_non_printing_mesh = False
self._is_non_thumbnail_visible_mesh = False
self._is_support_mesh = False
self._is_cutting_mesh = False
self._is_infill_mesh = False
self._is_anti_overhang_mesh = False
self._stack.propertyChanged.connect(self._onSettingChanged)
@ -53,13 +57,14 @@ class SettingOverrideDecorator(SceneNodeDecorator):
Application.getInstance().globalContainerStackChanged.connect(self._updateNextStack)
self.activeExtruderChanged.connect(self._updateNextStack)
self._updateNextStack()
if force_update:
self._updateNextStack()
def _generateUniqueName(self):
return "SettingOverrideInstanceContainer-%s" % uuid.uuid1()
def __deepcopy__(self, memo):
deep_copy = SettingOverrideDecorator()
deep_copy = SettingOverrideDecorator(force_update = False)
"""Create a fresh decorator object"""
instance_container = copy.deepcopy(self._stack.getContainer(0), memo)
@ -74,11 +79,6 @@ class SettingOverrideDecorator(SceneNodeDecorator):
# Properly set the right extruder on the copy
deep_copy.setActiveExtruder(self._extruder_stack)
# use value from the stack because there can be a delay in signal triggering and "_is_non_printing_mesh"
# has not been updated yet.
deep_copy._is_non_printing_mesh = self._evaluateIsNonPrintingMesh()
deep_copy._is_non_thumbnail_visible_mesh = self._evaluateIsNonThumbnailVisibleMesh()
return deep_copy
def getActiveExtruder(self):
@ -104,7 +104,7 @@ class SettingOverrideDecorator(SceneNodeDecorator):
"""
# for support_meshes, always use the support_extruder
if self.getStack().getProperty("support_mesh", "value"):
if self._is_support_mesh:
global_container_stack = Application.getInstance().getGlobalContainerStack()
if global_container_stack:
return str(global_container_stack.getProperty("support_extruder_nr", "value"))
@ -114,6 +114,30 @@ class SettingOverrideDecorator(SceneNodeDecorator):
container_stack = containers[0]
return container_stack.getMetaDataEntry("position", default=None)
def isCuttingMesh(self):
return self._is_cutting_mesh
def isSupportMesh(self):
return self._is_support_mesh
def isInfillMesh(self):
return self._is_infill_mesh
def isAntiOverhangMesh(self):
return self._is_anti_overhang_mesh
def _evaluateAntiOverhangMesh(self):
return bool(self._stack.userChanges.getProperty("anti_overhang_mesh", "value"))
def _evaluateIsCuttingMesh(self):
return bool(self._stack.userChanges.getProperty("cutting_mesh", "value"))
def _evaluateIsSupportMesh(self):
return bool(self._stack.userChanges.getProperty("support_mesh", "value"))
def _evaluateInfillMesh(self):
return bool(self._stack.userChanges.getProperty("infill_mesh", "value"))
def isNonPrintingMesh(self):
return self._is_non_printing_mesh
@ -132,6 +156,16 @@ class SettingOverrideDecorator(SceneNodeDecorator):
# Trigger slice/need slicing if the value has changed.
self._is_non_printing_mesh = self._evaluateIsNonPrintingMesh()
self._is_non_thumbnail_visible_mesh = self._evaluateIsNonThumbnailVisibleMesh()
if setting_key == "anti_overhang_mesh":
self._is_anti_overhang_mesh = self._evaluateAntiOverhangMesh()
elif setting_key == "support_mesh":
self._is_support_mesh = self._evaluateIsSupportMesh()
elif setting_key == "cutting_mesh":
self._is_cutting_mesh = self._evaluateIsCuttingMesh()
elif setting_key == "infill_mesh":
self._is_infill_mesh = self._evaluateInfillMesh()
Application.getInstance().getBackend().needsSlicing()
Application.getInstance().getBackend().tickle()