Added disallowed areas to arranger

CURA-3239
This commit is contained in:
Jaime van Kessel 2017-04-07 15:14:27 +02:00
parent 552b1ed4e8
commit 2008383118
2 changed files with 14 additions and 0 deletions

View file

@ -13,11 +13,14 @@ import copy
## Return object for bestSpot ## Return object for bestSpot
LocationSuggestion = namedtuple("LocationSuggestion", ["x", "y", "penalty_points", "priority"]) LocationSuggestion = namedtuple("LocationSuggestion", ["x", "y", "penalty_points", "priority"])
## The Arrange classed is used together with ShapeArray. Use it to find ## 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. # 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 # Different priority schemes can be defined so it alters the behavior while using
# the same logic. # the same logic.
class Arrange: class Arrange:
build_volume = None
def __init__(self, x, y, offset_x, offset_y, scale=1): def __init__(self, x, y, offset_x, offset_y, scale=1):
self.shape = (y, x) self.shape = (y, x)
self._priority = numpy.zeros((x, y), dtype=numpy.int32) self._priority = numpy.zeros((x, y), dtype=numpy.int32)
@ -50,6 +53,14 @@ class Arrange:
points = copy.deepcopy(vertices._points) points = copy.deepcopy(vertices._points)
shape_arr = ShapeArray.fromPolygon(points, scale = scale) shape_arr = ShapeArray.fromPolygon(points, scale = scale)
arranger.place(0, 0, shape_arr) 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 return arranger
## Find placement for a node (using offset shape) and place it (using hull shape) ## Find placement for a node (using offset shape) and place it (using hull shape)

View file

@ -593,6 +593,9 @@ class CuraApplication(QtApplication):
# The platform is a child of BuildVolume # The platform is a child of BuildVolume
self._volume = BuildVolume.BuildVolume(root) 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.getRenderer().setBackgroundColor(QColor(245, 245, 245))
self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume) self._physics = PlatformPhysics.PlatformPhysics(controller, self._volume)