Making the is_connected logic more understandable, Add spurious altium .NET file to ignore
parent
6963b9a8cc
commit
478ea80e62
|
@ -55,3 +55,4 @@ Temporary Items
|
||||||
*.OutJob
|
*.OutJob
|
||||||
*.SchDoc.Zip
|
*.SchDoc.Zip
|
||||||
*.OutJob.Zip
|
*.OutJob.Zip
|
||||||
|
*.NET
|
||||||
|
|
41
parse.py
41
parse.py
|
@ -122,30 +122,29 @@ def find_neighbors(wire, schematic):
|
||||||
return neighbors
|
return neighbors
|
||||||
|
|
||||||
def is_connected(wire_a, wire_b):
|
def is_connected(wire_a, wire_b):
|
||||||
a_vertex_pairs = [(wire_a['coords'][i], wire_a['coords'][i + 1]) for i in
|
a_line_segments = [(wire_a['coords'][i], wire_a['coords'][i + 1]) for i in
|
||||||
range(len(wire_a['coords']) - 1)]
|
range(len(wire_a['coords']) - 1)]
|
||||||
b_vertex_pairs = [(wire_b['coords'][i], wire_b['coords'][i + 1]) for i in
|
b_line_segments = [(wire_b['coords'][i], wire_b['coords'][i + 1]) for i in
|
||||||
range(len(wire_b['coords']) - 1)]
|
range(len(wire_b['coords']) - 1)]
|
||||||
|
|
||||||
for a_vx_pair in a_vertex_pairs:
|
# check if any vertices in wire_a lie on wire_b
|
||||||
for b_vx_pair in b_vertex_pairs:
|
for vertex in [vx for line in a_line_segments for vx in line]:
|
||||||
if (((a_vx_pair[0][0] <= b_vx_pair[0][0] <= a_vx_pair[1][0])
|
for b_line in b_line_segments:
|
||||||
and (a_vx_pair[0][1] <= b_vx_pair[0][1] <= a_vx_pair[1][1]))
|
b_xs = sorted(list(zip(*b_line))[0])
|
||||||
or ((a_vx_pair[0][0] >= b_vx_pair[0][0] >= a_vx_pair[1][0])
|
b_ys = sorted(list(zip(*b_line))[1])
|
||||||
and (a_vx_pair[0][1] >= b_vx_pair[0][1] >= a_vx_pair[1][1]))
|
|
||||||
or ((a_vx_pair[0][0] <= b_vx_pair[1][0] <= a_vx_pair[1][0])
|
if ((min(b_xs) <= vertex[0] <= max(b_xs))
|
||||||
and (a_vx_pair[0][1] <= b_vx_pair[1][1] <= a_vx_pair[1][1]))
|
and (min(b_ys) <= vertex[1] <= max(b_ys))):
|
||||||
or ((a_vx_pair[0][0] >= b_vx_pair[1][0] >= a_vx_pair[1][0])
|
return True
|
||||||
and (a_vx_pair[0][1] >= b_vx_pair[1][1] >= a_vx_pair[1][1])))\
|
|
||||||
or (((b_vx_pair[0][0] <= a_vx_pair[0][0] <= b_vx_pair[1][0])
|
# check if any vertices in wire_b lie on wire_a
|
||||||
and (b_vx_pair[0][1] <= a_vx_pair[0][1] <= b_vx_pair[1][1]))
|
for vertex in [vx for line in b_line_segments for vx in line]:
|
||||||
or ((b_vx_pair[0][0] >= a_vx_pair[0][0] >= b_vx_pair[1][0])
|
for a_line in a_line_segments:
|
||||||
and (b_vx_pair[0][1] >= a_vx_pair[0][1] >= b_vx_pair[1][1]))
|
a_xs = sorted(list(zip(*a_line))[0])
|
||||||
or ((b_vx_pair[0][0] <= a_vx_pair[1][0] <= b_vx_pair[1][0])
|
a_ys = sorted(list(zip(*a_line))[1])
|
||||||
and (b_vx_pair[0][1] <= a_vx_pair[1][1] <= b_vx_pair[1][1]))
|
|
||||||
or ((b_vx_pair[0][0] >= a_vx_pair[1][0] >= b_vx_pair[1][0])
|
if ((min(a_xs) <= vertex[0] <= max(a_xs))
|
||||||
and (b_vx_pair[0][1] >= a_vx_pair[1][1] >= b_vx_pair[1][1]))):
|
and (min(a_ys) <= vertex[1] <= max(a_ys))):
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue