From 216dcd33e061886a573f73decc98729b1cf33401 Mon Sep 17 00:00:00 2001 From: ChrisTerBeke Date: Tue, 10 Oct 2017 16:27:14 +0200 Subject: [PATCH] Make sure we do not have a crash when model is very small - CURA-4431 --- cura/CuraApplication.py | 4 ++++ cura/ShapeArray.py | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index ab348ae471..7d3e851b70 100755 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -1359,6 +1359,10 @@ class CuraApplication(QtApplication): # Find node location offset_shape_arr, hull_shape_arr = ShapeArray.fromNode(node, min_offset = min_offset) + # If a model is to small then it will not contain any points + if offset_shape_arr is None and hull_shape_arr is None: + return + # Step is for skipping tests to make it a lot faster. it also makes the outcome somewhat rougher node, _ = arranger.findNodePlacement(node, offset_shape_arr, hull_shape_arr, step = 10) diff --git a/cura/ShapeArray.py b/cura/ShapeArray.py index 95d0201c38..73fc2023e3 100755 --- a/cura/ShapeArray.py +++ b/cura/ShapeArray.py @@ -46,6 +46,10 @@ class ShapeArray: # For one_at_a_time printing you need the convex hull head. hull_head_verts = node.callDecoration("getConvexHullHead") or hull_verts + # If a model is to small then it will not contain any points + if not hull_verts.getPoints().any(): + return None, None + offset_verts = hull_head_verts.getMinkowskiHull(Polygon.approximatedCircle(min_offset)) offset_points = copy.deepcopy(offset_verts._points) # x, y offset_points[:, 0] = numpy.add(offset_points[:, 0], -transform_x)