True if pt_key lies on wire but is not one of its two endpoint vertices.
(pt_key: tuple[int, int], wire)
| 98 | |
| 99 | |
| 100 | def _on_wire_interior(pt_key: tuple[int, int], wire) -> bool: |
| 101 | """True if pt_key lies on wire but is not one of its two endpoint vertices.""" |
| 102 | if len(wire.points) < 2: |
| 103 | return False |
| 104 | end_keys = {_pt_key(wire.points[0]), _pt_key(wire.points[-1])} |
| 105 | if pt_key in end_keys: |
| 106 | return False |
| 107 | for pt in wire.points[1:-1]: # intermediate elbow vertices |
| 108 | if _pt_key(pt) == pt_key: |
| 109 | return True |
| 110 | x, y = pt_key |
| 111 | for i in range(len(wire.points) - 1): |
| 112 | if _pt_on_segment(x, y, wire.points[i], wire.points[i + 1]): |
| 113 | return True |
| 114 | return False |
| 115 | |
| 116 | |
| 117 | def _find_junction_points(wires, components) -> set[tuple[int, int]]: |
no test coverage detected