From b1af926ea6018b869d2401aeece46318b88d9a5d Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 7 Aug 2021 12:34:07 -0400 Subject: add tags to fill stitches --- lib/stitches/fill.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib/stitches') diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index 5aead9c7..0ac15657 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -7,6 +7,7 @@ import math import shapely +from ..stitch_plan import Stitch from ..svg import PIXELS_PER_MM from ..utils import Point as InkstitchPoint from ..utils import cache @@ -65,8 +66,8 @@ def stitch_row(stitches, beg, end, angle, row_spacing, max_stitch_length, stagge # tile with each other. That's important because we often get # abutting fill regions from pull_runs(). - beg = InkstitchPoint(*beg) - end = InkstitchPoint(*end) + beg = Stitch(*beg, tags=('fill_row_start',)) + end = Stitch(*end, tags=('fill_row_end')) row_direction = (end - beg).unit() segment_length = (end - beg).length() @@ -85,11 +86,13 @@ def stitch_row(stitches, beg, end, angle, row_spacing, max_stitch_length, stagge offset = (first_stitch - beg).length() while offset < segment_length: - stitches.append(beg + offset * row_direction) + stitches.append(Stitch(beg + offset * row_direction, tags=('fill_row'))) offset += max_stitch_length if (end - stitches[-1]).length() > 0.1 * PIXELS_PER_MM and not skip_last: stitches.append(end) + else: + stitches[-1].add_tag('fill_row_end') def intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing=None, flip=False): -- cgit v1.2.3 From b411305c6742ff07dbddbdec07f1338f5beaf31b Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 7 Aug 2021 18:38:57 -0400 Subject: use tags to decide which stitches to keep --- lib/stitches/fill.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'lib/stitches') diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py index 0ac15657..d134be32 100644 --- a/lib/stitches/fill.py +++ b/lib/stitches/fill.py @@ -67,15 +67,12 @@ def stitch_row(stitches, beg, end, angle, row_spacing, max_stitch_length, stagge # abutting fill regions from pull_runs(). beg = Stitch(*beg, tags=('fill_row_start',)) - end = Stitch(*end, tags=('fill_row_end')) + end = Stitch(*end, tags=('fill_row_end',)) row_direction = (end - beg).unit() segment_length = (end - beg).length() - # only stitch the first point if it's a reasonable distance away from the - # last stitch - if not stitches or (beg - stitches[-1]).length() > 0.5 * PIXELS_PER_MM: - stitches.append(beg) + stitches.append(beg) first_stitch = adjust_stagger(beg, angle, row_spacing, max_stitch_length, staggers) @@ -91,8 +88,6 @@ def stitch_row(stitches, beg, end, angle, row_spacing, max_stitch_length, stagge if (end - stitches[-1]).length() > 0.1 * PIXELS_PER_MM and not skip_last: stitches.append(end) - else: - stitches[-1].add_tag('fill_row_end') def intersect_region_with_grating(shape, angle, row_spacing, end_row_spacing=None, flip=False): -- cgit v1.2.3 From dd865008356d1e04b29a5eb59a8480900f255628 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sun, 15 Aug 2021 17:24:59 -0400 Subject: keep underlay, underpath, and border travel --- lib/stitches/auto_fill.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/stitches') diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py index 07361f13..160d927e 100644 --- a/lib/stitches/auto_fill.py +++ b/lib/stitches/auto_fill.py @@ -14,6 +14,7 @@ from shapely.ops import snap from shapely.strtree import STRtree from ..debug import debug +from ..stitch_plan import Stitch from ..svg import PIXELS_PER_MM from ..utils.geometry import Point as InkstitchPoint from ..utils.geometry import line_string_to_point_list @@ -592,9 +593,12 @@ def travel(travel_graph, start, end, running_stitch_length, skip_last): """Create stitches to get from one point on an outline of the shape to another.""" path = networkx.shortest_path(travel_graph, start, end, weight='weight') - path = [InkstitchPoint(*p) for p in path] + path = [Stitch(*p) for p in path] stitches = running_stitch(path, running_stitch_length) + for stitch in stitches: + stitch.add_tag('auto_fill_travel') + # The path's first stitch will start at the end of a row of stitches. We # don't want to double that last stitch, so we'd like to skip it. if skip_last and len(path) > 2: @@ -619,7 +623,7 @@ def path_to_stitches(path, travel_graph, fill_stitch_graph, angle, row_spacing, # If the very first stitch is travel, we'll omit it in travel(), so add it here. if not path[0].is_segment(): - stitches.append(InkstitchPoint(*path[0].nodes[0])) + stitches.append(Stitch(*path[0].nodes[0])) for edge in path: if edge.is_segment(): -- cgit v1.2.3