From 2c9a307483002f322128365be22ec62cf1f3b5be Mon Sep 17 00:00:00 2001 From: Thomas Duffin Date: Sun, 25 Oct 2015 23:14:11 +0000 Subject: [PATCH] Fixes #135 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The polygon passed to clear_polygon() is generated using shapely’s buffer() function on line FlatCAMObj.py:1095. When the margin given to the buffer() function is small, a single Polygon object is returned. If the margin is large enough it causes the polygon to be broken into pieces and a Multipolygon is returned instead. A visualisation of this can be seen in the shapely manual in the object.buffer() section. The first thing clear_polygon() does is buffer the polygon again to take the tool diameter into account and the Polygon/Multipolygon generated by this is handled further down the function. The buffer() function used to take the tool diameter into account can be called happily on both Polygon and Multipolygon objects so there is no reason to block Multipolygons being passed to clear_polygon(). Therefore simply adding Multipolygon to the acceptable types in the assert statement on line camlib.py:382 fixes this bug and causes no further issues. --- camlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/camlib.py b/camlib.py index 1a9fa966..b0c51166 100644 --- a/camlib.py +++ b/camlib.py @@ -379,7 +379,7 @@ class Geometry(object): """ log.debug("camlib.clear_polygon()") - assert type(polygon) == Polygon + assert type(polygon) == Polygon or type(polygon) == MultiPolygon ## The toolpaths # Index first and last points in paths