Removed count from findNodePlacement

CURA-3239
This commit is contained in:
Jaime van Kessel 2017-04-07 16:16:38 +02:00
parent 04eca9073a
commit f42efcb7e0
3 changed files with 25 additions and 34 deletions

View file

@ -69,10 +69,7 @@ class Arrange:
# \param node # \param node
# \param offset_shape_arr ShapeArray with offset, used to find location # \param offset_shape_arr ShapeArray with offset, used to find location
# \param hull_shape_arr ShapeArray without offset, for placing the shape # \param hull_shape_arr ShapeArray without offset, for placing the shape
# \param count Number of objects def findNodePlacement(self, node, offset_shape_arr, hull_shape_arr, step = 1):
def findNodePlacements(self, node, offset_shape_arr, hull_shape_arr, count = 1, step = 1):
nodes = []
for i in range(count):
new_node = copy.deepcopy(node) new_node = copy.deepcopy(node)
best_spot = self.bestSpot( best_spot = self.bestSpot(
offset_shape_arr, start_prio = self._start_priority, step = step) offset_shape_arr, start_prio = self._start_priority, step = step)
@ -90,10 +87,8 @@ class Arrange:
self.place(x, y, hull_shape_arr) # place the object in arranger self.place(x, y, hull_shape_arr) # place the object in arranger
else: else:
Logger.log("d", "Could not find spot!") Logger.log("d", "Could not find spot!")
new_node.setPosition(Vector(200, center_y, 100 - i * 20)) new_node.setPosition(Vector(200, center_y, 100))
return new_node
nodes.append(new_node)
return nodes
## Fill priority, center is best. Lower value is better ## Fill priority, center is best. Lower value is better
# This is a strategy for the arranger. # This is a strategy for the arranger.

View file

@ -1280,18 +1280,14 @@ class CuraApplication(QtApplication):
node.addDecorator(ConvexHullDecorator()) node.addDecorator(ConvexHullDecorator())
if node.callDecoration("isSliceable"): if node.callDecoration("isSliceable"):
# find node location # Find node location
offset_shape_arr, hull_shape_arr = ShapeArray.fromNode(node, min_offset = min_offset) offset_shape_arr, hull_shape_arr = ShapeArray.fromNode(node, min_offset = min_offset)
# step is for skipping tests to make it a lot faster. it also makes the outcome somewhat rougher
nodes = arranger.findNodePlacements(node, offset_shape_arr, hull_shape_arr, count = 1, step = 10)
for new_node in nodes: # Step is for skipping tests to make it a lot faster. it also makes the outcome somewhat rougher
op = AddSceneNodeOperation(new_node, scene.getRoot()) node = arranger.findNodePlacement(node, offset_shape_arr, hull_shape_arr, step = 10)
op.push()
else:
op = AddSceneNodeOperation(node, scene.getRoot()) op = AddSceneNodeOperation(node, scene.getRoot())
op.push() op.push()
scene.sceneChanged.emit(node) scene.sceneChanged.emit(node)
def addNonSliceableExtension(self, extension): def addNonSliceableExtension(self, extension):

View file

@ -52,7 +52,7 @@ class MultiplyObjectsJob(Job):
for i in range(self._count): for i in range(self._count):
# We do place the nodes one by one, as we want to yield in between. # We do place the nodes one by one, as we want to yield in between.
nodes.extend(arranger.findNodePlacements(current_node, offset_shape_arr, hull_shape_arr, count = 1)) nodes.append(arranger.findNodePlacement(current_node, offset_shape_arr, hull_shape_arr))
Job.yieldThread() Job.yieldThread()
status_message.setProgress((i + 1) / self._count * 100) status_message.setProgress((i + 1) / self._count * 100)