MCPcopy Create free account
hub / github.com/SLiCAP/SLiCAP_python / _on_wire_interior

Function _on_wire_interior

SLiCAP/schematic/canvas.py:100–114  ·  view source on GitHub ↗

True if pt_key lies on wire but is not one of its two endpoint vertices.

(pt_key: tuple[int, int], wire)

Source from the content-addressed store, hash-verified

98
99
100def _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
117def _find_junction_points(wires, components) -> set[tuple[int, int]]:

Callers 2

_find_junction_pointsFunction · 0.85
_interior_tapMethod · 0.85

Calls 2

_pt_on_segmentFunction · 0.85
_pt_keyFunction · 0.70

Tested by

no test coverage detected