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/utils/clamp_path.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/utils/clamp_path.py') diff --git a/lib/utils/clamp_path.py b/lib/utils/clamp_path.py index 432f618a..f6db66a8 100644 --- a/lib/utils/clamp_path.py +++ b/lib/utils/clamp_path.py @@ -56,8 +56,10 @@ def adjust_line_end(line, end): def find_border(polygon, point): + """Finds subpath of polygon which intersects with the point. + Ignores small border fragments""" for border in polygon.interiors: - if border.intersects(point): + if border.length > 0.1 and border.intersects(point): return border else: return polygon.exterior @@ -76,7 +78,10 @@ def clamp_path_to_polygon(path, polygon): # This splits the path at the points where it intersects with the polygon # border and returns the pieces in the same order as the original path. - split_path = ensure_geometry_collection(LineString(path).difference(polygon.boundary)) + try: + split_path = ensure_geometry_collection(LineString(path).difference(polygon.boundary)) + except FloatingPointError: + return path if len(split_path.geoms) == 1: # The path never intersects with the polygon, so it's entirely inside. -- cgit v1.2.3