pub struct RouterNG {
pub(crate) bounds: Bounds,
pub(crate) blocks: Vec<Block>,
pub(crate) block_index: BlockAxisIndex,
pub(crate) h_segments: BTreeMap<CoordY, Vec<HSegment>>,
pub(crate) v_segments: BTreeMap<CoordX, Vec<VSegment>>,
pub(crate) nodes: BTreeSet<Point>,
pub(crate) graph: UnGraph<Point, Cost>,
pub(crate) node_to_index: FxHashMap<Point, NodeIndex>,
pub(crate) dirty: bool,
pub(crate) requested: Requests,
}Fields§
§bounds: BoundsWhat this lattice covers. Channels are clipped to it.
blocks: Vec<Block>The blocking rectangles - not mutable
block_index: BlockAxisIndexPer-axis index of blocks for channel seeding (built from blocks).
h_segments: BTreeMap<CoordY, Vec<HSegment>>Horizontal segments, keyed by their vertical coordinate
v_segments: BTreeMap<CoordX, Vec<VSegment>>Vertical segments, keyed by their horizontal coordinate
nodes: BTreeSet<Point>Nodes: the intersection points of the segments
graph: UnGraph<Point, Cost>The graph to be used for pathfinding, built from the segments and nodes
node_to_index: FxHashMap<Point, NodeIndex>A map from node to index in the graph, for quick lookup
dirty: boolDirty flag that indicates h_segments or v_segments have been modified and the graph needs to be rebuilt.
requested: RequestsThe channels and seed points this lattice was asked for, kept because a
segment does not remember where its channel was seeded. Clipping is by
blocks at seeding time — a channel becomes the gap its seed point
falls in — so a block added later cannot be applied to the segments that
came out; the requests have to be seeded again against the new block
set. See ClosedRouter::extended.
Implementations§
Source§impl RouterNG
impl RouterNG
Sourcepub fn debug_marks(&self) -> Vec<Mark>
pub fn debug_marks(&self) -> Vec<Mark>
The channel graph drawn as debug marks.
§Panics
If the graph has unbuilt segments: what the marks show would not be what a route would be found on.
pub fn is_accessible(&self, test: impl Into<Point>) -> bool
pub(crate) fn seed_horiz_channel( &mut self, center: impl Into<Point>, cost: impl Into<Cost>, )
pub(crate) fn seed_vert_channel( &mut self, center: impl Into<Point>, cost: impl Into<Cost>, )
pub fn seed_channels(&mut self, center: impl Into<Point>, cost: impl Into<Cost>)
pub fn add_horiz_segment( &mut self, vert: impl Into<CoordY>, left: impl Into<CoordX>, right: impl Into<CoordX>, cost: impl Into<Cost>, )
pub fn add_vert_segment( &mut self, horiz: impl Into<CoordX>, top: impl Into<CoordY>, bottom: impl Into<CoordY>, cost: impl Into<Cost>, )
Sourcepub(crate) fn reseed(&mut self)
pub(crate) fn reseed(&mut self)
Throw the derived segments away and seed them again from the requests, against the current block set. The only way to apply a block that arrived after the channels it clips.
pub fn update(&mut self)
pub(crate) fn iter_hsegs(&self) -> impl Iterator<Item = (CoordY, HSegment)> + '_
pub(crate) fn iter_vsegs(&self) -> impl Iterator<Item = (CoordX, VSegment)> + '_
pub(crate) fn rebuild_graph(&mut self)
Sourcepub(crate) fn point(&self, node: NodeIndex) -> Point
pub(crate) fn point(&self, node: NodeIndex) -> Point
The grid point a node index stands for. Every index the graph hands out resolves; a stray one yields the origin rather than taking the editor down.
pub(crate) fn successors(&self, state: SearchState) -> Vec<(SearchState, Cost)>
Sourcepub(crate) fn path_find(
&mut self,
start: impl Into<Point>,
end: impl Into<Point>,
incoming: Option<Direction>,
) -> Option<(Vec<Point>, Option<Direction>)>
pub(crate) fn path_find( &mut self, start: impl Into<Point>, end: impl Into<Point>, incoming: Option<Direction>, ) -> Option<(Vec<Point>, Option<Direction>)>
Route from start to end, seeding the search with incoming as the
direction already being travelled (so reversing it out of start pays the
turn_cost reversal penalty). Returns the path together with the direction
of its final segment — the direction of travel arriving at end — so a
caller routing several segments in series can forbid the next one doubling
back.
Sourcepub fn path_find_with_fallback(
&mut self,
start: impl Into<Point>,
end: impl Into<Point>,
incoming: Option<Direction>,
) -> Leg
pub fn path_find_with_fallback( &mut self, start: impl Into<Point>, end: impl Into<Point>, incoming: Option<Direction>, ) -> Leg
Route from start to end, or — when the lattice holds no path — an L
that ignores it, marked Resolution::Fallback so the caller can tell.