Skip to main content

RouterNG

Struct RouterNG 

Source
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: Bounds

What this lattice covers. Channels are clipped to it.

§blocks: Vec<Block>

The blocking rectangles - not mutable

§block_index: BlockAxisIndex

Per-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: bool

Dirty flag that indicates h_segments or v_segments have been modified and the graph needs to be rebuilt.

§requested: Requests

The 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

Source

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.

Source

pub fn is_accessible(&self, test: impl Into<Point>) -> bool

Source

pub(crate) fn seed_horiz_channel( &mut self, center: impl Into<Point>, cost: impl Into<Cost>, )

Source

pub(crate) fn seed_vert_channel( &mut self, center: impl Into<Point>, cost: impl Into<Cost>, )

Source

pub fn seed_channels(&mut self, center: impl Into<Point>, cost: impl Into<Cost>)

Source

pub fn add_horiz_segment( &mut self, vert: impl Into<CoordY>, left: impl Into<CoordX>, right: impl Into<CoordX>, cost: impl Into<Cost>, )

Source

pub fn add_vert_segment( &mut self, horiz: impl Into<CoordX>, top: impl Into<CoordY>, bottom: impl Into<CoordY>, cost: impl Into<Cost>, )

Source

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.

Source

pub fn update(&mut self)

Source

pub(crate) fn iter_hsegs(&self) -> impl Iterator<Item = (CoordY, HSegment)> + '_

Source

pub(crate) fn iter_vsegs(&self) -> impl Iterator<Item = (CoordX, VSegment)> + '_

Source

pub(crate) fn rebuild_graph(&mut self)

Source

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.

Source

pub(crate) fn successors(&self, state: SearchState) -> Vec<(SearchState, Cost)>

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for RouterNG

Source§

fn clone(&self) -> RouterNG

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RouterNG

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more