pull/1548/head
Andreas 2021-11-10 17:23:24 +01:00 zatwierdzone przez Kaalleen
rodzic 1a1939b5da
commit 3caaae6938
3 zmienionych plików z 18 dodań i 5 usunięć

Wyświetl plik

@ -456,7 +456,8 @@ class AutoFill(EmbroideryElement):
stitches=path)
stitch_groups.append(stitch_group)
elif self.fill_method == 2: # Guided Auto Fill
lines = get_patterns(self.node, "#inkstitch-guide-line-marker")
lines = get_patterns(
self.node, "#inkstitch-guide-line-marker", False, True)
lines = lines['stroke_patterns']
if not lines or lines[0].is_empty:
inkex.errormsg(

Wyświetl plik

@ -65,7 +65,7 @@ def _apply_fill_patterns(patterns, patches):
patch.stitches = patch_points
def get_patterns(node, marker_id):
def get_patterns(node, marker_id, get_fills=True, get_strokes=True):
from .elements import EmbroideryElement
from .elements.auto_fill import auto_fill
from .elements.stroke import Stroke
@ -88,7 +88,7 @@ def get_patterns(node, marker_id):
for ring in linear_rings:
fills.append(shgeo.Polygon(ring))
if stroke is not None:
if get_strokes and stroke is not None:
stroke_pattern = Stroke(pattern).paths
line_strings = [shgeo.LineString(path) for path in stroke_pattern]
strokes.append(shgeo.MultiLineString(line_strings))

Wyświetl plik

@ -7,6 +7,7 @@ import math
import shapely
from shapely.geometry.linestring import LineString
from shapely.ops import linemerge
from ..svg import PIXELS_PER_MM
from ..utils import Point as InkstitchPoint
from ..utils import cache
@ -108,7 +109,7 @@ def extend_line(line, minx, maxx, miny, maxy):
point4 = InkstitchPoint(*line.coords[-1])
new_ending_point = point4+(point4-point3).unit()*length
line = LineString([new_starting_point.as_tuple()] +
return LineString([new_starting_point.as_tuple()] +
line.coords[1:-1]+[new_ending_point.as_tuple()])
@ -119,7 +120,7 @@ def intersect_region_with_grating_line(shape, line, row_spacing, end_row_spacing
upper_left = InkstitchPoint(minx, miny)
rows = []
# extend the line towards the ends to increase probability that all offsetted curves cross the shape
extend_line(line, minx, maxx, miny, maxy)
line = extend_line(line, minx, maxx, miny, maxy)
line_offsetted = line
res = line_offsetted.intersection(shape)
@ -141,6 +142,17 @@ def intersect_region_with_grating_line(shape, line, row_spacing, end_row_spacing
else:
rows.insert(0, runs)
line_offsetted = line_offsetted.parallel_offset(row_spacing, 'left', 5)
if line_offsetted.geom_type == 'MultiLineString': # if we got multiple lines take the longest
lines = linemerge(line_offsetted)
lines = list(line_offsetted.geoms)
max_length = -1
max_length_idx = -1
for idx, subline in enumerate(lines):
if subline.length > max_length:
max_length = subline.length
max_length_idx = idx
line_offsetted = lines[max_length_idx]
if row_spacing < 0:
line_offsetted.coords = line_offsetted.coords[::-1]
line_offsetted = line_offsetted.simplify(0.01, False)