mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-19 12:47:49 -06:00
Fix error after refactor, added comments
This commit is contained in:
parent
1ebf947ff2
commit
1df9066340
3 changed files with 12 additions and 7 deletions
|
@ -58,8 +58,10 @@ class Arrange:
|
|||
for i in range(count):
|
||||
new_node = copy.deepcopy(node)
|
||||
|
||||
x, y = self.bestSpot(
|
||||
best_spot = self.bestSpot(
|
||||
offset_shape_arr, start_prio = start_prio, step = step)
|
||||
x, y = best_spot.x, best_spot.y
|
||||
start_prio = best_spot.priority
|
||||
transformation = new_node._transformation
|
||||
if x is not None: # We could find a place
|
||||
transformation._data[0][3] = x
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -31,10 +31,9 @@ class ShapeArray:
|
|||
arr = cls.arrayFromPolygon(shape, flip_vertices)
|
||||
return cls(arr, offset_x, offset_y)
|
||||
|
||||
## Return an offset and hull ShapeArray from a scenenode.
|
||||
## Return an offset and hull ShapeArray from a scene node.
|
||||
@classmethod
|
||||
def fromNode(cls, node, min_offset, scale = 0.5):
|
||||
# hacky way to undo transformation
|
||||
transform = node._transformation
|
||||
transform_x = transform._data[0][3]
|
||||
transform_y = transform._data[2][3]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue