kopia lustrzana https://github.com/inkstitch/inkstitch
minor changes
rodzic
3caaae6938
commit
e15bce1401
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -19,6 +19,8 @@ stringcase
|
|||
tinycss2
|
||||
flask
|
||||
fonttools
|
||||
anytree
|
||||
depq
|
||||
|
||||
pywinutils; sys.platform == 'win32'
|
||||
pywin32; sys.platform == 'win32'
|
||||
|
|
Ładowanie…
Reference in New Issue