Set a property for non-printing-meshes

Remove code duplication
This commit is contained in:
fieldOfView 2017-11-09 12:28:55 +01:00
parent ff14db9133
commit 0b11117d6d
3 changed files with 14 additions and 18 deletions

View File

@ -14,13 +14,6 @@ import numpy
## The convex hull decorator is a scene node decorator that adds the convex hull functionality to a scene node.
# If a scene node has a convex hull decorator, it will have a shadow in which other objects can not be printed.
class ConvexHullDecorator(SceneNodeDecorator):
## Meshes that don't need a convex hull
#
# If these settings are True for any mesh, the mesh does not need to push other meshes away.
# Note that Support Mesh is not in here because it actually generates
# g-code in the volume of the mesh.
_not_printed_mesh_settings = {"anti_overhang_mesh", "infill_mesh", "cutting_mesh"}
def __init__(self):
super().__init__()
@ -63,7 +56,9 @@ class ConvexHullDecorator(SceneNodeDecorator):
if self._node is None:
return None
if (self._node.callDecoration("getStack") and any(self._node.callDecoration("getStack").getProperty(setting, "value") for setting in self._not_printed_mesh_settings)):
if getattr(self._node, "_non_printing_mesh", False):
# infill_mesh, cutting_mesh and anti_overhang_mesh do not need a convex hull
# node._non_printing_mesh is set in SettingOverrideDecorator
return None
hull = self._compute2DConvexHull()

View File

@ -22,6 +22,14 @@ class SettingOverrideDecorator(SceneNodeDecorator):
## Event indicating that the user selected a different extruder.
activeExtruderChanged = Signal()
## Non-printing meshes
#
# If these settings are True for any mesh, the mesh does not need a convex hull,
# and is sent to the slicer regardless of whether it fits inside the build volume.
# Note that Support Mesh is not in here because it actually generates
# g-code in the volume of the mesh.
_non_printing_mesh_settings = {"anti_overhang_mesh", "infill_mesh", "cutting_mesh"}
def __init__(self):
super().__init__()
self._stack = PerObjectContainerStack(stack_id = id(self))
@ -82,6 +90,8 @@ class SettingOverrideDecorator(SceneNodeDecorator):
Application.getInstance().getBackend().needsSlicing()
Application.getInstance().getBackend().tickle()
self._node._non_printing_mesh = any(self._stack.getProperty(setting, "value") for setting in self._non_printing_mesh_settings)
## Makes sure that the stack upon which the container stack is placed is
# kept up to date.
def _updateNextStack(self):

View File

@ -44,14 +44,6 @@ class GcodeStartEndFormatter(Formatter):
## Job class that builds up the message of scene data to send to CuraEngine.
class StartSliceJob(Job):
## Meshes that are sent to the engine regardless of being outside of the
# build volume.
#
# If these settings are True for any mesh, the build volume is ignored.
# Note that Support Mesh is not in here because it actually generates
# g-code in the volume of the mesh.
_not_printed_mesh_settings = {"anti_overhang_mesh", "infill_mesh", "cutting_mesh"}
def __init__(self, slice_message):
super().__init__()
@ -140,8 +132,7 @@ class StartSliceJob(Job):
temp_list = []
for node in DepthFirstIterator(self._scene.getRoot()):
if type(node) is SceneNode and node.getMeshData() and node.getMeshData().getVertices() is not None:
if not getattr(node, "_outside_buildarea", False)\
or (node.callDecoration("getStack") and any(node.callDecoration("getStack").getProperty(setting, "value") for setting in self._not_printed_mesh_settings)):
if not getattr(node, "_outside_buildarea", False) or getattr(node, "_non_printing_mesh", False):
temp_list.append(node)
Job.yieldThread()