def pieces_under_over(path, segs_to_points, xings):
"""Produce all the pieces of the path, with a bool indicating if each leads to under or over."""
pieces = list(path_pieces(path, segs_to_points))
for i, piece in enumerate(pieces):
xing = xings.get(piece[-1])
if xing is None:
continue
if xing.under is not None:
over = (xing.under != path)
else:
assert xing.over is not None
over = (xing.over == path)
ou = [over, not over]
if i % 2:
ou = ou[::-1]
break
else:
ou = [True, False]
yield from zip(pieces, itertools.cycle(ou))
评论列表
文章目录