vibesketcher.render.orthogonal¶
Orthogonal connector routing around boxes (#247).
The method is that of M. Wybrow, K. Marriott and P. J. Stuckey, “Orthogonal connector routing”, in Graph Drawing 2009, LNCS 5849, 219-231 (2010), doi:10.1007/978-3-642-11805-0_22:
Orthogonal visibility graph (section 3). Every box is an obstacle, grown by a clearance. The interesting points are the corners of the grown boxes and the connection points just outside each box side. From each interesting point a horizontal and a vertical visibility segment run until they meet an obstacle or the drawing’s bounding rectangle; the graph’s vertices are the intersections of those segments, and its edges join neighbouring vertices along a segment. A path in this graph never enters a grown box.
Shortest path with a bend penalty (section 4). Each connector is the cheapest path from a connection point of its source box to one of its target box, where the cost is the length plus a fixed penalty per bend. It is Dijkstra’s algorithm over (vertex, heading) states, so a bend is an edge of the search, and a U-turn is never taken. Ties are broken by the order the states were reached in, which is fixed, so the same boxes always give the same routes.
Nudging (section 5, simplified). Segments of different connectors that lie on the same line and overlap are spread across the channel, ordered by the side their connectors turn to at both ends so they do not cross needlessly. The spread stays inside the clearance, so a nudged segment still keeps out of every box. The paper solves a separation problem over all channels; here each shared run is spread on its own.
A connector leaves its source box perpendicular to a side, at the side’s midpoint, and ends perpendicular to a side of its target box, so its last segment carries the arrowhead straight into the box.
Everything is in drawing points with y down. route() raises
NoRoute when the boxes leave no orthogonal path; it never falls back
to a line through a box.
Functions
|
The number of bends of a polyline. |
|
Orthogonal polylines from box |
Exceptions
|
No orthogonal path joins two boxes without entering another; |
- exception vibesketcher.render.orthogonal.NoRoute(edge)[source]¶
Bases:
ValueErrorNo orthogonal path joins two boxes without entering another;
edgeis its index.- Parameters:
edge (int)
- Return type:
None
- vibesketcher.render.orthogonal.route(boxes, edges, *, clearance, bend, spacing, prefer='down')[source]¶
Orthogonal polylines from box
sourceto boxtargetfor each edge.Each starts on a side of the source box and ends on a side of the target box, perpendicular to both, and keeps
clearancefrom every other box.bendis the cost of one bend in points of length;spacingis the widest gap between nudged parallel segments. RaisesNoRoute.