summaryrefslogtreecommitdiff
path: root/lib/stitches
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stitches')
-rw-r--r--lib/stitches/PointTransfer.py3
-rw-r--r--lib/stitches/auto_fill.py8
-rw-r--r--lib/stitches/fill.py31
3 files changed, 32 insertions, 10 deletions
diff --git a/lib/stitches/PointTransfer.py b/lib/stitches/PointTransfer.py
index b4c6c004..da73aea0 100644
--- a/lib/stitches/PointTransfer.py
+++ b/lib/stitches/PointTransfer.py
@@ -409,6 +409,9 @@ def transfer_points_to_surrounding_graph(fill_stitch_graph, current_edge, used_o
prev_spacing = math.sqrt(normalized_vector_prev_x*normalized_vector_prev_x +
normalized_vector_prev_y*normalized_vector_prev_y)
+ # if prev_spacing == 0:
+ # print("HIER FEHLER")
+
normalized_vector_prev_x /= prev_spacing
normalized_vector_prev_y /= prev_spacing
diff --git a/lib/stitches/auto_fill.py b/lib/stitches/auto_fill.py
index a0d9637a..95cc9103 100644
--- a/lib/stitches/auto_fill.py
+++ b/lib/stitches/auto_fill.py
@@ -165,6 +165,10 @@ def build_fill_stitch_graph(shape, line, angle, row_spacing, end_row_spacing, st
for i in range(len(rows_of_segments)):
for segment in rows_of_segments[i]:
+ if abs(segment[0][0]-396.5081896849414) < 0.01:
+ print("HIER")
+ if segment[0][0] == segment[-1][0] and segment[0][1] == segment[-1][1]:
+ print("FEHLER HIER!")
# First, add the grating segments as edges. We'll use the coordinates
# of the endpoints as nodes, which networkx will add automatically.
@@ -674,7 +678,7 @@ def stitch_line(stitches, stitching_direction, geometry, projected_points, max_s
geometry, geometry.length, 0.0, max_stitch_length, projected_points, abs(row_spacing), offset_by_half, True)
stitches.append(Stitch(*stitched_line[0], tags=('fill_row_start',)))
- for i in range(1, len(stitched_line)):
+ for i in range(1, len(stitched_line)-1):
stitches.append(Stitch(*stitched_line[i], tags=('fill_row')))
if not skip_last:
@@ -684,6 +688,8 @@ def stitch_line(stitches, stitching_direction, geometry, projected_points, max_s
else:
stitches.append(
Stitch(*geometry.coords[0], tags=('fill_row_end',)))
+ if stitches[-1].x == stitches[-2].x and stitches[-1].y == stitches[-2].y:
+ print("FEHLER")
@debug.time
diff --git a/lib/stitches/fill.py b/lib/stitches/fill.py
index 55ce09a4..01bfdc20 100644
--- a/lib/stitches/fill.py
+++ b/lib/stitches/fill.py
@@ -113,6 +113,19 @@ def extend_line(line, minx, maxx, miny, maxy):
line.coords[1:-1]+[new_ending_point.as_tuple()])
+def repair_multiple_parallel_offset_curves(multi_line):
+ lines = linemerge(multi_line)
+ lines = list(multi_line.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
+ # need simplify to avoid doubled points caused by linemerge
+ return lines[max_length_idx].simplify(0.01, False)
+
+
def intersect_region_with_grating_line(shape, line, row_spacing, end_row_spacing=None, flip=False):
row_spacing = abs(row_spacing)
@@ -141,17 +154,12 @@ def intersect_region_with_grating_line(shape, line, row_spacing, end_row_spacing
rows.append(runs)
else:
rows.insert(0, runs)
+ # if len(runs) > 1:
+ # print("HIERRRR!")
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]
+ line_offsetted = repair_multiple_parallel_offset_curves(
+ line_offsetted)
if row_spacing < 0:
line_offsetted.coords = line_offsetted.coords[::-1]
@@ -162,10 +170,15 @@ def intersect_region_with_grating_line(shape, line, row_spacing, end_row_spacing
row_spacing = -row_spacing
# print("Set to right")
line_offsetted = line.parallel_offset(row_spacing, 'left', 5)
+ if line_offsetted.geom_type == 'MultiLineString': # if we got multiple lines take the longest
+ line_offsetted = repair_multiple_parallel_offset_curves(
+ line_offsetted)
# using negative row spacing leads as a side effect to reversed offsetted lines - here we undo this
line_offsetted.coords = line_offsetted.coords[::-1]
line_offsetted = line_offsetted.simplify(0.01, False)
res = line_offsetted.intersection(shape)
+ # if res.geom_type != 'LineString':
+ # print("HIER!!")
return rows