Pynest2d.Point requires integer coordinates

These were floats. Rounding numpy-floats still results in floats so I'm just using int(). The result is rounded down instead of nearest, but the difference is at most 50 nanometres anyway.

Contributes to issue CURA-7501.
This commit is contained in:
Ghostkeeper 2020-10-30 18:12:18 +01:00
parent 95f1b11c45
commit 39287264d9
No known key found for this signature in database
GPG Key ID: D2A8871EE34EC59A

View File

@ -1,3 +1,6 @@
# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
import numpy import numpy
from pynest2d import Point, Box, Item, NfpConfig, nest from pynest2d import Point, Box, Item, NfpConfig, nest
from typing import List, TYPE_CHECKING, Optional, Tuple from typing import List, TYPE_CHECKING, Optional, Tuple
@ -50,7 +53,7 @@ def findNodePlacement(nodes_to_arrange: List["SceneNode"], build_volume: "BuildV
continue continue
converted_points = [] converted_points = []
for point in hull_polygon.getPoints(): for point in hull_polygon.getPoints():
converted_points.append(Point(point[0] * factor, point[1] * factor)) converted_points.append(Point(int(point[0] * factor), int(point[1] * factor)))
item = Item(converted_points) item = Item(converted_points)
node_items.append(item) node_items.append(item)
@ -74,7 +77,7 @@ def findNodePlacement(nodes_to_arrange: List["SceneNode"], build_volume: "BuildV
if clipped_area.getPoints() is not None: # numpy array has to be explicitly checked against None if clipped_area.getPoints() is not None: # numpy array has to be explicitly checked against None
for point in clipped_area.getPoints(): for point in clipped_area.getPoints():
converted_points.append(Point(point[0] * factor, point[1] * factor)) converted_points.append(Point(int(point[0] * factor), int(point[1] * factor)))
disallowed_area = Item(converted_points) disallowed_area = Item(converted_points)
disallowed_area.markAsDisallowedAreaInBin(0) disallowed_area.markAsDisallowedAreaInBin(0)