summaryrefslogtreecommitdiff
path: root/lib/stitches/meander_fill.py
diff options
context:
space:
mode:
authorKaalleen <36401965+kaalleen@users.noreply.github.com>2023-03-09 18:57:55 +0100
committerGitHub <noreply@github.com>2023-03-09 18:57:55 +0100
commitfd6e43cf00548f78daf8ae855f691279e3c90a3b (patch)
tree44774d59038213fb81e8906e61dfbd309aa17da8 /lib/stitches/meander_fill.py
parentda1cd33f3b7fa6b85a6cdfcb855dc8a16cf3f92c (diff)
Various fixes (#2125)
* add unit info to scale value in ripple stitch * fix apply threadlist with empty description * fix satin type ripple with unequal nodes * fix legacy auto_fill conversion * inform about too small meander shapes
Diffstat (limited to 'lib/stitches/meander_fill.py')
-rw-r--r--lib/stitches/meander_fill.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/stitches/meander_fill.py b/lib/stitches/meander_fill.py
index 6043b4bc..0a59da72 100644
--- a/lib/stitches/meander_fill.py
+++ b/lib/stitches/meander_fill.py
@@ -1,18 +1,21 @@
from itertools import combinations
import networkx as nx
+from inkex import errormsg
from shapely.geometry import MultiPoint, Point
from shapely.ops import nearest_points
-from .running_stitch import running_stitch
from .. import tiles
from ..debug import debug
+from ..i18n import _
from ..utils.clamp_path import clamp_path_to_polygon
-from ..utils.geometry import Point as InkStitchPoint, ensure_geometry_collection
+from ..utils.geometry import Point as InkStitchPoint
+from ..utils.geometry import ensure_geometry_collection
from ..utils.list import poprandom
from ..utils.prng import iter_uniform_floats
from ..utils.smoothing import smooth_path
from ..utils.threading import check_stop_flag
+from .running_stitch import running_stitch
def meander_fill(fill, shape, shape_index, starting_point, ending_point):
@@ -25,6 +28,13 @@ def meander_fill(fill, shape, shape_index, starting_point, ending_point):
debug.log_line_strings(lambda: ensure_geometry_collection(shape.boundary).geoms, 'Meander shape')
graph = tile.to_graph(shape, fill.meander_scale)
+
+ if not graph:
+ label = fill.node.label or fill.node.get_id()
+ errormsg(_('%s: Could not build graph for meander stitching. Try to enlarge your shape or '
+ 'scale your meander pattern down.') % label)
+ return []
+
debug.log_graph(graph, 'Meander graph')
ensure_connected(graph)
start, end = find_starting_and_ending_nodes(graph, shape, starting_point, ending_point)