Enhance boundary algorithm

This commit is contained in:
WQY\qiong
2023-06-08 22:00:15 +08:00
parent 6dbf701318
commit 2bd314cc91

View File

@@ -150,8 +150,16 @@ def calculate_boundary(name: str, nodes: list[str]) -> list[tuple[float, float]]
paths: list[str] = []
while True:
#print(cursor)
# prevent duplicated node
if len(paths) > 0 and cursor == paths[-1]:
break
# prevent duplicated path
if len(paths) >= 3 and paths[0] == paths[-1] and paths[1] == cursor:
break
paths.append(cursor)
sorted_links = []
overlapped_link = ''
for link in t_nodes[cursor]['links']:
@@ -164,10 +172,7 @@ def calculate_boundary(name: str, nodes: list[str]) -> list[tuple[float, float]]
# work into a branch, return
if len(sorted_links) == 0:
cursor = paths[-2]
if cursor == topology.max_x_node():
paths.append(cursor)
break
in_angle = in_angle = _angle_of_node_link(cursor, overlapped_link, t_nodes, t_links)
in_angle = _angle_of_node_link(cursor, overlapped_link, t_nodes, t_links)
continue
sorted_links = sorted(sorted_links, key=lambda s:s[0])
@@ -178,11 +183,6 @@ def calculate_boundary(name: str, nodes: list[str]) -> list[tuple[float, float]]
break
cursor = t_links[out_link]['node1'] if cursor == t_links[out_link]['node2'] else t_links[out_link]['node2']
# end up trip :)
if cursor == topology.max_x_node():
paths.append(cursor)
break
in_angle = _angle_of_node_link(cursor, out_link, t_nodes, t_links)
boundary: list[tuple[float, float]] = []