Fix error after refactor, added comments

This commit is contained in:
Jack Ha 2017-04-04 09:52:07 +02:00
parent 1ebf947ff2
commit 1df9066340
3 changed files with 12 additions and 7 deletions

View file

@ -1031,20 +1031,24 @@ class CuraApplication(QtApplication):
min_offset = 8
arranger = Arrange.create(fixed_nodes = fixed_nodes)
# Collect nodes to be placed
nodes_arr = [] # fill with (size, node, offset_shape_arr, hull_shape_arr)
for node in nodes:
offset_shape_arr, hull_shape_arr = ShapeArray.fromNode(node, min_offset = min_offset)
nodes_arr.append((offset_shape_arr.arr.shape[0] * offset_shape_arr.arr.shape[1], node, offset_shape_arr, hull_shape_arr))
# Sort nodes biggest area first
nodes_arr.sort(key = lambda item: item[0])
nodes_arr.reverse()
# Place nodes one at a time
start_prio = 0
for size, node, offset_shape_arr, hull_shape_arr in nodes_arr:
# we assume that when a location does not fit, it will also not fit for the next
# object (while what can be untrue). That saves a lot of time.
best_spot = arranger.bestSpot(
offset_shape_arr, start_prio = start_prio)
# For performance reasons, we assume that when a location does not fit,
# it will also not fit for the next object (while what can be untrue).
# We also skip possibilities by slicing through the possibilities (step = 10)
best_spot = arranger.bestSpot(offset_shape_arr, start_prio = start_prio, step = 10)
x, y = best_spot.x, best_spot.y
start_prio = best_spot.priority
if x is not None: # We could find a place