Enhance boundary algorithm
This commit is contained in:
@@ -150,8 +150,16 @@ def calculate_boundary(name: str, nodes: list[str]) -> list[tuple[float, float]]
|
|||||||
|
|
||||||
paths: list[str] = []
|
paths: list[str] = []
|
||||||
while True:
|
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)
|
paths.append(cursor)
|
||||||
|
|
||||||
sorted_links = []
|
sorted_links = []
|
||||||
overlapped_link = ''
|
overlapped_link = ''
|
||||||
for link in t_nodes[cursor]['links']:
|
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
|
# work into a branch, return
|
||||||
if len(sorted_links) == 0:
|
if len(sorted_links) == 0:
|
||||||
cursor = paths[-2]
|
cursor = paths[-2]
|
||||||
if cursor == topology.max_x_node():
|
in_angle = _angle_of_node_link(cursor, overlapped_link, t_nodes, t_links)
|
||||||
paths.append(cursor)
|
|
||||||
break
|
|
||||||
in_angle = in_angle = _angle_of_node_link(cursor, overlapped_link, t_nodes, t_links)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
sorted_links = sorted(sorted_links, key=lambda s:s[0])
|
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
|
break
|
||||||
|
|
||||||
cursor = t_links[out_link]['node1'] if cursor == t_links[out_link]['node2'] else t_links[out_link]['node2']
|
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)
|
in_angle = _angle_of_node_link(cursor, out_link, t_nodes, t_links)
|
||||||
|
|
||||||
boundary: list[tuple[float, float]] = []
|
boundary: list[tuple[float, float]] = []
|
||||||
|
|||||||
Reference in New Issue
Block a user