diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2023-11-10 16:41:36 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-10 16:41:36 +0100 |
| commit | 7edebd60f93f1c8fda01e90c4ff9a7a75a59b76e (patch) | |
| tree | 336184d92377048e5b0c31c5052523d044276139 /lib/elements/fill_stitch.py | |
| parent | e1a1e887ff94ae39a5254338c6ae57496186e14b (diff) | |
fix invalid clip path (#2577)
use fallback if shape has grating issues (too small)
Diffstat (limited to 'lib/elements/fill_stitch.py')
| -rw-r--r-- | lib/elements/fill_stitch.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index c7c3c640..b20407f9 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -10,7 +10,7 @@ import re import numpy as np from inkex import Transform from shapely import geometry as shgeo -from shapely.errors import TopologicalError +from shapely.errors import GEOSException from shapely.validation import explain_validity, make_valid from .. import tiles @@ -562,16 +562,20 @@ class FillStitch(EmbroideryElement): polygons.append(polygon) if isinstance(polygon, shgeo.MultiPolygon): polygons.extend(polygon.geoms) - return shgeo.MultiPolygon(polygons) def _get_clipped_path(self): if self.node.clip is None: return self.original_shape clip_path = get_clip_path(self.node) + + # make sure clip path and shape are valid + clip_path = make_valid(clip_path) + shape = make_valid(self.original_shape) + try: - intersection = clip_path.intersection(self.original_shape) - except TopologicalError: + intersection = clip_path.intersection(shape) + except GEOSException: return self.original_shape if isinstance(intersection, shgeo.Polygon): |
