diff options
| author | Lex Neva <lexelby@users.noreply.github.com> | 2023-02-16 22:58:10 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-02-16 22:58:10 -0500 |
| commit | 7aee0979be4f39cde7a6396cdc0d1d2cc4222d90 (patch) | |
| tree | 1123050a6ba7428dbcc8b72bd074161bdb3e014f /lib/stitches/ripple_stitch.py | |
| parent | 30c73dc39c1ac814d0c63ec102c7f8c2b993fdd0 (diff) | |
| parent | f6c2aa89197c82cedfb31465fc4b2acffaeb8f25 (diff) | |
Merge pull request #2045 from inkstitch/lexelby/interruptible-threads
make simulator threads interruptible
Diffstat (limited to 'lib/stitches/ripple_stitch.py')
| -rw-r--r-- | lib/stitches/ripple_stitch.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/stitches/ripple_stitch.py b/lib/stitches/ripple_stitch.py index a66eff74..33054119 100644 --- a/lib/stitches/ripple_stitch.py +++ b/lib/stitches/ripple_stitch.py @@ -9,6 +9,7 @@ from .running_stitch import running_stitch from ..elements import SatinColumn from ..utils import Point as InkstitchPoint from ..utils.geometry import line_string_to_point_list +from ..utils.threading import check_stop_flag def ripple_stitch(stroke): @@ -80,6 +81,8 @@ def _get_satin_ripple_helper_lines(stroke): helper_lines = [] for point0, point1 in rail_pairs: + check_stop_flag() + helper_lines.append([]) helper_line = LineString((point0, point1)) for step in steps: @@ -95,6 +98,8 @@ def _converge_helper_line_points(helper_lines, point_edge=False): num_lines = len(helper_lines) steps = _get_steps(num_lines) for i, line in enumerate(helper_lines): + check_stop_flag() + points = [] for j in range(len(line) - 1): if point_edge and j % 2 == 1: @@ -133,6 +138,8 @@ def _target_point_helper_lines(stroke, outline): target = stroke.get_ripple_target() steps = _get_steps(stroke.get_line_count(), exponent=stroke.exponent, flip=stroke.flip_exponent) for i, point in enumerate(outline.coords): + check_stop_flag() + line = LineString([point, target]) for step in steps: @@ -193,6 +200,8 @@ def _generate_guided_helper_lines(stroke, outline, max_distance, guide_line): previous_guide_point = None for i in range(stroke.get_line_count()): + check_stop_flag() + guide_point = InkstitchPoint.from_shapely_point(guide_line.interpolate(outline_steps[i], normalized=True)) translation = guide_point - start_point scaling = scale_steps[i] @@ -232,6 +241,8 @@ def _generate_satin_guide_helper_lines(stroke, outline, guide_line): # add scaled and rotated outlines along the satin column guide line for i, (point0, point1) in enumerate(zip(*rail_points)): + check_stop_flag() + guide_center = (point0 + point1) / 2 translation = guide_center - outline_center if stroke.rotate_ripples: |
