diff options
| author | Andreas <v.andreas.1@web.de> | 2022-01-14 20:51:38 +0100 |
|---|---|---|
| committer | Kaalleen <reni@allenka.de> | 2022-05-04 18:59:11 +0200 |
| commit | cc051bcdba88c985a040a508be2ccc8878e09181 (patch) | |
| tree | a57ddfe0047777367f6dfe8628a5c2eeee8a0416 /lib/stitches | |
| parent | b5c7f637c14beaf9ba075c0c4445fbd3541a8270 (diff) | |
removed double points at spirals
Diffstat (limited to 'lib/stitches')
| -rw-r--r-- | lib/stitches/ConnectAndSamplePattern.py | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/lib/stitches/ConnectAndSamplePattern.py b/lib/stitches/ConnectAndSamplePattern.py index 2c538e5d..33a1ba6d 100644 --- a/lib/stitches/ConnectAndSamplePattern.py +++ b/lib/stitches/ConnectAndSamplePattern.py @@ -443,7 +443,7 @@ def calculate_replacing_middle_point(line_segment, abs_offset, max_stitch_distan """ Takes a line segment (consisting of 3 points!) and calculates a new middle point if the line_segment is - straight enough to be resampled by points max_stitch_distance apart. + straight enough to be resampled by points max_stitch_distance apart FROM THE END OF line_segment. Returns None if the middle point is not needed. """ angles = LineStringSampling.calculate_line_angles(line_segment) @@ -840,7 +840,7 @@ def connect_raster_tree_spiral( Takes the offsetted curves organized as tree, connects and samples them as a spiral. It expects that each node in the tree has max. one child Input: - -tree: contains the offsetted curves in a hierachical organized + -tree: contains the offsetted curves in a hierarchical organized data structure. -used_offset: used offset when the offsetted curves were generated -stitch_distance: maximum allowed distance between two points @@ -917,12 +917,35 @@ def connect_raster_tree_spiral( transfer_to_sibling=False, transfer_to_child=True) - result_coords.extend(own_coords) - result_coords_origin.extend(own_coords_origin) - - # make sure the next section starts where this - # section of the curve ends - starting_point = own_coords[-1] + # Check whether starting of own_coords or end of result_coords can be removed + if not result_coords: + result_coords.extend(own_coords) + result_coords_origin.extend(own_coords_origin) + elif len(own_coords) > 0: + if Point(result_coords[-1]).distance(Point(own_coords[0])) > constants.line_lengh_seen_as_one_point: + lineseg = LineString( + [result_coords[-2], result_coords[-1], own_coords[0], own_coords[1]]) + else: + lineseg = LineString( + [result_coords[-2], result_coords[-1], own_coords[1]]) + (temp_coords, _) = LineStringSampling.raster_line_string_with_priority_points(lineseg, 0, lineseg.length, stitch_distance, + DEPQ(), abs_offset, offset_by_half, False) + if len(temp_coords) == 2: # only start and end point of lineseg was needed + result_coords.pop() + result_coords_origin.pop() + result_coords.extend(own_coords[1:]) + result_coords_origin.extend(own_coords_origin[1:]) + elif len(temp_coords) == 3: # one middle point within lineseg was needed + result_coords.pop() + result_coords.append(temp_coords[1]) + result_coords.extend(own_coords[1:]) + result_coords_origin.extend(own_coords_origin[1:]) + else: # all points were needed + result_coords.extend(own_coords) + result_coords_origin.extend(own_coords_origin) + # make sure the next section starts where this + # section of the curve ends + starting_point = result_coords[-1] assert len(result_coords) == len(result_coords_origin) return result_coords, result_coords_origin |
