ictdesigntools.draw.route¶
Orthogonal connector routing: paths of horizontal and vertical runs that go around boxes, and nudging that spreads parallel runs sharing a channel so they do not lie on one another.
orthogonal searches a sparse grid made from the ends and the boxes' sides (pushed out by
margin) with A*, counting length and a penalty per bend, so a route takes few turns and keeps
clear of the boxes. nudge then finds runs of several routes on the same line that overlap
and spaces them spacing apart about it, keeping each route's end points where they are.
This is the usual approach to orthogonal connector routing (a visibility graph, a shortest path
with bend costs, then a nudging pass), in pure Python.
>>> orthogonal((0, 3), (30, 3), [(10, 0, 10, 10)], margin=2) # over the box: nearer
[(0, 3), (0, -2), (30, -2), (30, 3)]
simplify ¶
Drop repeated points and points in the middle of a straight run.
Source code in src/ictdesigntools/draw/route.py
orthogonal ¶
orthogonal(
start: Point,
end: Point,
boxes: list[Box],
margin: float = 4.0,
bend: float | None = None,
lines: tuple[list[float], list[float]] = ([], []),
) -> list[Point]
The shortest route of horizontal and vertical runs from start to end that keeps
out of boxes, with bend (default: twice the margin plus 10) added for each turn.
lines adds x and y lines the route may run along, such as the middle of a channel.
The ends must lie outside the boxes. Raises ValueError when no route exists.
Source code in src/ictdesigntools/draw/route.py
nudge ¶
Routes with their overlapping parallel runs spread spacing apart about the line they
shared, ordered so routes keep their order across the channel. A route's first and last
points stay put, so the runs that end on them are not moved.
Source code in src/ictdesigntools/draw/route.py
s_curve ¶
A smooth S from start to end, leaving and arriving level (a cubic Bézier with
its control points half way across), as points for a polyline: how a cable fans out from a
furcation to its legs, or gathers into a bundle.