diff --git a/cura/Arrange.py b/cura/Arrange.py index 2ab407205c..2ce9cfe344 100755 --- a/cura/Arrange.py +++ b/cura/Arrange.py @@ -13,11 +13,14 @@ import copy ## Return object for bestSpot LocationSuggestion = namedtuple("LocationSuggestion", ["x", "y", "penalty_points", "priority"]) + ## The Arrange classed is used together with ShapeArray. Use it to find # good locations for objects that you try to put on a build place. # Different priority schemes can be defined so it alters the behavior while using # the same logic. class Arrange: + build_volume = None + def __init__(self, x, y, offset_x, offset_y, scale=1): self.shape = (y, x) self._priority = numpy.zeros((x, y), dtype=numpy.int32) @@ -50,6 +53,14 @@ class Arrange: points = copy.deepcopy(vertices._points) shape_arr = ShapeArray.fromPolygon(points, scale = scale) arranger.place(0, 0, shape_arr) + + # If a build volume was set, add the disallowed areas + if Arrange.build_volume: + disallowed_areas = Arrange.build_volume.getDisallowedAreas() + for area in disallowed_areas: + points = copy.deepcopy(area._points) + shape_arr = ShapeArray.fromPolygon(points, scale = scale) + arranger.place(0, 0, shape_arr) return arranger ## Find placement for a node (using offset shape) and place it (using hull shape) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 30fd7e95a2..636753b632 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -593,6 +593,9 @@ class CuraApplication(QtApplication): # The platform is a child of BuildVolume self._volume = BuildVolume.BuildVolume(root) + # Set the build volume of the arranger to the used build volume + Arrange.build_volume = self._volume + self.getRenderer().setBackgroundColor(QColor(245, 245, 245)) self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume)