From 2677c30a0f210d14586c83016f45e5a75fb9d647 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Thu, 25 Jan 2024 17:54:08 +0100 Subject: Second chance for invalid fill stitch graphs (#2643) --- lib/stitches/guided_fill.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'lib/stitches/guided_fill.py') diff --git a/lib/stitches/guided_fill.py b/lib/stitches/guided_fill.py index 762515f6..6f650028 100644 --- a/lib/stitches/guided_fill.py +++ b/lib/stitches/guided_fill.py @@ -3,6 +3,7 @@ from random import random import numpy as np import shapely.prepared +from networkx import is_empty from shapely import geometry as shgeo from shapely.affinity import translate from shapely.ops import linemerge, nearest_points, unary_union @@ -15,7 +16,7 @@ from ..utils.geometry import (ensure_geometry_collection, from ..utils.threading import check_stop_flag from .auto_fill import (auto_fill, build_fill_stitch_graph, build_travel_graph, collapse_sequential_outline_edges, find_stitch_path, - graph_is_valid, travel) + graph_make_valid, travel) def guided_fill(shape, @@ -39,9 +40,10 @@ def guided_fill(shape, fill_stitch_graph = build_fill_stitch_graph(shape, segments, starting_point, ending_point) - if not graph_is_valid(fill_stitch_graph): + if is_empty(fill_stitch_graph): return fallback(shape, guideline, row_spacing, max_stitch_length, running_stitch_length, running_stitch_tolerance, num_staggers, skip_last, starting_point, ending_point, underpath) + fill_stitch_graph = graph_make_valid(fill_stitch_graph) travel_graph = build_travel_graph(fill_stitch_graph, shape, angle, underpath) path = find_stitch_path(fill_stitch_graph, travel_graph, starting_point, ending_point) -- cgit v1.2.3