diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2024-06-03 06:52:03 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-03 06:52:03 +0200 |
| commit | 7f9ae2ca1eb5b89b0705363911bab242486642db (patch) | |
| tree | 8aa8d8f48efa707176a77a5135f5744303958941 /lib | |
| parent | 4cf85797bc18c2f0b78a401c112c4cc183ca881f (diff) | |
Avoid FloatingPointError (fill) (#2959)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/elements/fill_stitch.py | 4 | ||||
| -rw-r--r-- | lib/stitches/auto_fill.py | 4 |
2 files changed, 5 insertions, 3 deletions
diff --git a/lib/elements/fill_stitch.py b/lib/elements/fill_stitch.py index 6bf52d95..7d96fd14 100644 --- a/lib/elements/fill_stitch.py +++ b/lib/elements/fill_stitch.py @@ -9,6 +9,7 @@ import re import numpy as np from inkex import LinearGradient, Transform from shapely import geometry as shgeo +from shapely import set_precision from shapely.errors import GEOSException from shapely.ops import nearest_points from shapely.validation import explain_validity, make_valid @@ -726,7 +727,8 @@ class FillStitch(EmbroideryElement): @property @cache def shape(self): - shape = self._get_clipped_path() + # avoid FloatingPointError while keeping a decent precision necessary for clamp path + shape = set_precision(self._get_clipped_path(), 0.0000000001) if shape.is_valid: return ensure_multi_polygon(shape, 3) diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py index 85543cea..a277e000 100644 --- a/lib/stitches/auto_fill.py +++ b/lib/stitches/auto_fill.py @@ -15,7 +15,6 @@ from shapely import segmentize from shapely.ops import snap from shapely.strtree import STRtree - from ..debug.debug import debug from ..stitch_plan import Stitch from ..svg import PIXELS_PER_MM @@ -24,9 +23,9 @@ from ..utils.clamp_path import clamp_path_to_polygon from ..utils.geometry import Point as InkstitchPoint from ..utils.geometry import (ensure_multi_line_string, line_string_to_point_list) +from ..utils.prng import join_args from ..utils.smoothing import smooth_path from ..utils.threading import check_stop_flag -from ..utils.prng import join_args from .fill import intersect_region_with_grating, stitch_row from .running_stitch import even_running_stitch @@ -143,6 +142,7 @@ def project(shape, coords, outline_index): """ outline = ensure_multi_line_string(shape.boundary).geoms[outline_index] + return outline.project(shgeo.Point(*coords)) |
