summaryrefslogtreecommitdiff
path: root/lib/stitches
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2023-11-10 16:41:36 +0100
committerGitHub <noreply@github.com>2023-11-10 16:41:36 +0100
commit7edebd60f93f1c8fda01e90c4ff9a7a75a59b76e (patch)
tree336184d92377048e5b0c31c5052523d044276139 /lib/stitches
parente1a1e887ff94ae39a5254338c6ae57496186e14b (diff)
fix invalid clip path (#2577)
use fallback if shape has grating issues (too small)
Diffstat (limited to 'lib/stitches')
-rw-r--r--lib/stitches/auto_fill.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py
index b4d63224..83ff226b 100644
--- a/lib/stitches/auto_fill.py
+++ b/lib/stitches/auto_fill.py
@@ -25,6 +25,10 @@ from ..utils.smoothing import smooth_path
from ..utils.threading import check_stop_flag
+class NoGratingsError(Exception):
+ pass
+
+
class PathEdge(object):
OUTLINE_KEYS = ("outline", "extra", "initial")
SEGMENT_KEY = "segment"
@@ -78,6 +82,10 @@ def auto_fill(shape,
return fallback(shape, running_stitch_length, running_stitch_tolerance)
travel_graph = build_travel_graph(fill_stitch_graph, shape, angle, underpath)
+
+ if not travel_graph:
+ return fallback(shape, running_stitch_length, running_stitch_tolerance)
+
path = find_stitch_path(fill_stitch_graph, travel_graph, starting_point, ending_point)
result = path_to_stitches(shape, path, travel_graph, fill_stitch_graph, angle, row_spacing,
max_stitch_length, running_stitch_length, running_stitch_tolerance,
@@ -314,7 +322,10 @@ def build_travel_graph(fill_stitch_graph, shape, fill_stitch_angle, underpath):
graph.add_nodes_from(fill_stitch_graph.nodes(data=True))
if underpath:
- boundary_points, travel_edges = build_travel_edges(shape, fill_stitch_angle)
+ try:
+ boundary_points, travel_edges = build_travel_edges(shape, fill_stitch_angle)
+ except NoGratingsError:
+ return
# This will ensure that a path traveling inside the shape can reach its
# target on the outline, which will be one of the points added above.
@@ -459,6 +470,9 @@ def build_travel_edges(shape, fill_angle):
for ls in mls.geoms
for coord in ls.coords]
+ if grating1.is_empty or grating2.is_empty:
+ raise NoGratingsError()
+
diagonal_edges = ensure_multi_line_string(grating1.symmetric_difference(grating2))
check_stop_flag()