From 9afbf02384400f53e9fb762b3a986b65e4e9b75e Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Mon, 25 Dec 2023 08:48:20 +0100 Subject: [PATCH] Ignore multipoints in intersect regions with gratings (#2647) --- lib/stitches/fill.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index 2c5cdffc3..9e9ff7909 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -149,14 +149,13 @@ def intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing=Non res = grating_line.intersection(shape) - if (isinstance(res, shapely.geometry.MultiLineString) or isinstance(res, shapely.geometry.GeometryCollection)): - runs = [line_string.coords for line_string in res.geoms if isinstance(line_string, shapely.geometry.LineString)] + if res.geom_type in ["MultiLineString", "GeometryCollection"]: + runs = [line_string.coords for line_string in res.geoms if line_string.geom_type == "LineString"] + elif res.geom_type in ["Point", "MultiPoint"] or res.is_empty: + # ignore if we intersected at a single point or no points + runs = [] else: - if res.is_empty or len(res.coords) == 1: - # ignore if we intersected at a single point or no points - runs = [] - else: - runs = [res.coords] + runs = [res.coords] if runs: runs.sort(key=lambda seg: (InkstitchPoint(*seg[0]) - upper_left).length())