pub struct Obstacles {
rects: Vec<Block>,
by_row: BTreeMap<i32, Vec<usize>>,
by_col: BTreeMap<i32, Vec<usize>>,
}Expand description
The obstacle rectangles of a block, for the cheap “does a straight wire cross
a block?” test that decides whether a leg can stay straight. Mirrors exactly
the rects build_closed_router_for_block feeds to the router as blocks, so a
straight leg judged clear here is the same one the router would leave alone —
but without paying to build the routing graph (the point of the fast load path).
Rects are indexed by the rows and columns they span, so blocked/accessible
only test the rects that could possibly hit the query line — not all of them.
A linear scan here is quadratic across a whole document’s routes (each leg
scans every block), which showed up as ~20s of load overhead at scale.
Fields§
§rects: Vec<Block>§by_row: BTreeMap<i32, Vec<usize>>§by_col: BTreeMap<i32, Vec<usize>>Implementations§
Source§impl Obstacles
impl Obstacles
pub fn new(rects: Vec<ObstacleRect>) -> Self
Sourcepub fn blocked(&self, a: GridPoint, b: GridPoint) -> bool
pub fn blocked(&self, a: GridPoint, b: GridPoint) -> bool
Whether the axis-aligned wire a → b crosses any obstacle. Same result as
ClosedRouter::is_wire_blocked, but only the rects spanning the wire’s
row (horizontal wire) or column (vertical wire) are tested.
Sourcepub fn crossings(
&self,
a: GridPoint,
b: GridPoint,
) -> impl Iterator<Item = (GridPoint, GridPoint)> + '_
pub fn crossings( &self, a: GridPoint, b: GridPoint, ) -> impl Iterator<Item = (GridPoint, GridPoint)> + '_
Each stretch of the axis-aligned wire a → b that runs through an
obstacle — what Self::blocked refuses, located.
Sourcepub fn hugs(&self, a: GridPoint, b: GridPoint) -> bool
pub fn hugs(&self, a: GridPoint, b: GridPoint) -> bool
Whether the axis-aligned wire a → b hugs any obstacle (runs alongside an
edge within the routing gutter).
A hugging wire runs beside an edge rather than over it, so the index is
queried a gutter wide either side of the wire: a rect with an edge within
ROUTE_GUTTER of row y spans one of the rows y-gutter ..= y+gutter,
and so is in one of their buckets. A rect spanning several of them is
tested more than once, which costs less than the dedup would.
Sourcepub fn accessible(&self, p: GridPoint) -> bool
pub fn accessible(&self, p: GridPoint) -> bool
Whether p lies outside every obstacle (a waypoint inside one is dropped).
Source§impl Obstacles
impl Obstacles
Sourcepub fn reroute_blocked(&self) -> LegRules<'_>
pub fn reroute_blocked(&self) -> LegRules<'_>
The rider’s rules: a leg through a block is routed again.
Sourcepub fn keep_blocked(&self) -> LegRules<'_>
pub fn keep_blocked(&self) -> LegRules<'_>
A reconstruction’s rules: a leg through a block is kept as the document has it.
Auto Trait Implementations§
impl Freeze for Obstacles
impl RefUnwindSafe for Obstacles
impl Send for Obstacles
impl Sync for Obstacles
impl Unpin for Obstacles
impl UnsafeUnpin for Obstacles
impl UnwindSafe for Obstacles
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<D> OwoColorize for D
impl<D> OwoColorize for D
§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg] or
a color-specific method, such as [OwoColorize::green], Read more§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg] or
a color-specific method, such as [OwoColorize::on_yellow], Read more