Skip to content

Commit 642bf79

Browse files
committed
Make the scipy convex hull code a bit more robust just like the pure Python version.
Contributes to CURA-1512
1 parent f8703b4 commit 642bf79

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

UM/Math/Polygon.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,13 @@ def intersectsPolygon(self, other):
258258
# \return \type{Polygon} The convex hull around the points of this polygon.
259259
if has_scipy:
260260
def getConvexHull(self):
261-
hull = scipy.spatial.ConvexHull(self._points)
261+
points = self._points
262+
263+
if len(points) < 1:
264+
return Polygon(numpy.zeros((0, 2), numpy.float64))
265+
if len(points) <= 2:
266+
return Polygon(numpy.array(points, numpy.float64))
267+
hull = scipy.spatial.ConvexHull(points)
262268
return Polygon(numpy.flipud(self._points[hull.vertices]))
263269
else:
264270
def getConvexHull(self):

0 commit comments

Comments
 (0)