From 5a714f3a24c7df08ed2696ad18e3e12ac66426a5 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 6 Aug 2019 14:03:59 +0200 Subject: [PATCH] Fix arranging of nested group nodes causing a crash CURA-6688 --- cura/Arranging/ShapeArray.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cura/Arranging/ShapeArray.py b/cura/Arranging/ShapeArray.py index 9227e446fb..403db5e706 100644 --- a/cura/Arranging/ShapeArray.py +++ b/cura/Arranging/ShapeArray.py @@ -1,5 +1,5 @@ -#Copyright (c) 2019 Ultimaker B.V. -#Cura is released under the terms of the LGPLv3 or higher. +# Copyright (c) 2019 Ultimaker B.V. +# Cura is released under the terms of the LGPLv3 or higher. import numpy import copy @@ -10,6 +10,7 @@ from UM.Math.Polygon import Polygon if TYPE_CHECKING: from UM.Scene.SceneNode import SceneNode + ## Polygon representation as an array for use with Arrange class ShapeArray: def __init__(self, arr: numpy.array, offset_x: float, offset_y: float, scale: float = 1) -> None: @@ -101,7 +102,9 @@ class ShapeArray: # Create check array for each edge segment, combine into fill array for k in range(vertices.shape[0]): - fill = numpy.all([fill, cls._check(vertices[k - 1], vertices[k], base_array)], axis=0) + check_array = cls._check(vertices[k - 1], vertices[k], base_array) + if check_array is not None: + fill = numpy.all([fill, check_array], axis=0) # Set all values inside polygon to one base_array[fill] = 1 @@ -117,9 +120,9 @@ class ShapeArray: # \param p2 2-tuple with x, y for point 2 # \param base_array boolean array to project the line on @classmethod - def _check(cls, p1: numpy.array, p2: numpy.array, base_array: numpy.array) -> bool: + def _check(cls, p1: numpy.array, p2: numpy.array, base_array: numpy.array) -> Optional[numpy.array]: if p1[0] == p2[0] and p1[1] == p2[1]: - return False + return None idxs = numpy.indices(base_array.shape) # Create 3D array of indices p1 = p1.astype(float)