Avoid FloatingPointError (fill) (#2959)

pull/2960/head dev-build-kaalleen-multicolor_satin_color_panel
Kaalleen 2024-06-03 06:52:03 +02:00 zatwierdzone przez GitHub
rodzic 4cf85797bc
commit 7f9ae2ca1e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: B5690EEEBB952194
2 zmienionych plików z 5 dodań i 3 usunięć

Wyświetl plik

@ -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)

Wyświetl plik

@ -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))