mirror of https://codeberg.org/topola/topola.git
fix(autorouter/anterouter): Make anterouting undo-redoable
This commit is contained in:
parent
3d55d1a81e
commit
d920f62a1e
|
|
@ -58,6 +58,7 @@ impl Anterouter {
|
||||||
pub fn anteroute(
|
pub fn anteroute(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
|
recorder: &mut BoardEdit,
|
||||||
options: &AnterouterOptions,
|
options: &AnterouterOptions,
|
||||||
) {
|
) {
|
||||||
// PERF: Unnecessary clone.
|
// PERF: Unnecessary clone.
|
||||||
|
|
@ -86,6 +87,7 @@ impl Anterouter {
|
||||||
),
|
),
|
||||||
TerminatingScheme::Fanout => self.anteroute_fanout(
|
TerminatingScheme::Fanout => self.anteroute_fanout(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
endpoint_indices.0,
|
endpoint_indices.0,
|
||||||
*ratline,
|
*ratline,
|
||||||
endpoint_dots.0,
|
endpoint_dots.0,
|
||||||
|
|
@ -111,6 +113,7 @@ impl Anterouter {
|
||||||
),
|
),
|
||||||
TerminatingScheme::Fanout => self.anteroute_fanout(
|
TerminatingScheme::Fanout => self.anteroute_fanout(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
endpoint_indices.1,
|
endpoint_indices.1,
|
||||||
*ratline,
|
*ratline,
|
||||||
endpoint_dots.1,
|
endpoint_dots.1,
|
||||||
|
|
@ -125,6 +128,7 @@ impl Anterouter {
|
||||||
fn anteroute_fanout(
|
fn anteroute_fanout(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
|
recorder: &mut BoardEdit,
|
||||||
ratvertex: NodeIndex<usize>,
|
ratvertex: NodeIndex<usize>,
|
||||||
ratline: RatlineUid,
|
ratline: RatlineUid,
|
||||||
source_dot: FixedDotIndex,
|
source_dot: FixedDotIndex,
|
||||||
|
|
@ -160,6 +164,7 @@ impl Anterouter {
|
||||||
if self
|
if self
|
||||||
.anteroute_fanout_on_bbox(
|
.anteroute_fanout_on_bbox(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
ratvertex,
|
ratvertex,
|
||||||
source_dot,
|
source_dot,
|
||||||
small_bbox,
|
small_bbox,
|
||||||
|
|
@ -193,6 +198,7 @@ impl Anterouter {
|
||||||
if self
|
if self
|
||||||
.anteroute_fanout_on_bbox(
|
.anteroute_fanout_on_bbox(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
ratvertex,
|
ratvertex,
|
||||||
source_dot,
|
source_dot,
|
||||||
large_bbox,
|
large_bbox,
|
||||||
|
|
@ -208,6 +214,7 @@ impl Anterouter {
|
||||||
if self
|
if self
|
||||||
.anteroute_fanout_on_bbox(
|
.anteroute_fanout_on_bbox(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
ratvertex,
|
ratvertex,
|
||||||
source_dot,
|
source_dot,
|
||||||
small_bbox,
|
small_bbox,
|
||||||
|
|
@ -223,6 +230,7 @@ impl Anterouter {
|
||||||
if self
|
if self
|
||||||
.anteroute_fanout_on_bbox(
|
.anteroute_fanout_on_bbox(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
ratvertex,
|
ratvertex,
|
||||||
source_dot,
|
source_dot,
|
||||||
large_bbox,
|
large_bbox,
|
||||||
|
|
@ -241,6 +249,7 @@ impl Anterouter {
|
||||||
fn anteroute_fanout_on_bbox(
|
fn anteroute_fanout_on_bbox(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
|
recorder: &mut BoardEdit,
|
||||||
ratvertex: NodeIndex<usize>,
|
ratvertex: NodeIndex<usize>,
|
||||||
source_dot: FixedDotIndex,
|
source_dot: FixedDotIndex,
|
||||||
bbox: AABB<[f64; 2]>,
|
bbox: AABB<[f64; 2]>,
|
||||||
|
|
@ -251,6 +260,7 @@ impl Anterouter {
|
||||||
if self
|
if self
|
||||||
.anteroute_fanout_on_bbox_in_direction(
|
.anteroute_fanout_on_bbox_in_direction(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
ratvertex,
|
ratvertex,
|
||||||
source_dot,
|
source_dot,
|
||||||
bbox,
|
bbox,
|
||||||
|
|
@ -273,6 +283,7 @@ impl Anterouter {
|
||||||
if self
|
if self
|
||||||
.anteroute_fanout_on_bbox_in_direction(
|
.anteroute_fanout_on_bbox_in_direction(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
ratvertex,
|
ratvertex,
|
||||||
source_dot,
|
source_dot,
|
||||||
bbox,
|
bbox,
|
||||||
|
|
@ -291,6 +302,7 @@ impl Anterouter {
|
||||||
if self
|
if self
|
||||||
.anteroute_fanout_on_bbox_in_direction(
|
.anteroute_fanout_on_bbox_in_direction(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
ratvertex,
|
ratvertex,
|
||||||
source_dot,
|
source_dot,
|
||||||
bbox,
|
bbox,
|
||||||
|
|
@ -314,6 +326,7 @@ impl Anterouter {
|
||||||
fn anteroute_fanout_on_bbox_in_direction(
|
fn anteroute_fanout_on_bbox_in_direction(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
|
recorder: &mut BoardEdit,
|
||||||
ratvertex: NodeIndex<usize>,
|
ratvertex: NodeIndex<usize>,
|
||||||
source_dot: FixedDotIndex,
|
source_dot: FixedDotIndex,
|
||||||
bbox: AABB<[f64; 2]>,
|
bbox: AABB<[f64; 2]>,
|
||||||
|
|
@ -323,6 +336,7 @@ impl Anterouter {
|
||||||
) -> Result<(), ()> {
|
) -> Result<(), ()> {
|
||||||
let (_, dots) = self.place_fanout_via_on_bbox_in_direction(
|
let (_, dots) = self.place_fanout_via_on_bbox_in_direction(
|
||||||
autorouter,
|
autorouter,
|
||||||
|
recorder,
|
||||||
ratvertex,
|
ratvertex,
|
||||||
source_dot,
|
source_dot,
|
||||||
bbox,
|
bbox,
|
||||||
|
|
@ -350,7 +364,7 @@ impl Anterouter {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
autorouter.board.layout_mut().add_fixed_seg(
|
autorouter.board.layout_mut().add_fixed_seg(
|
||||||
&mut LayoutEdit::new(),
|
&mut recorder.layout_edit,
|
||||||
source_dot,
|
source_dot,
|
||||||
fanout_dot,
|
fanout_dot,
|
||||||
FixedSegWeight(GeneralSegWeight {
|
FixedSegWeight(GeneralSegWeight {
|
||||||
|
|
@ -366,6 +380,7 @@ impl Anterouter {
|
||||||
fn place_fanout_via_on_bbox_in_direction(
|
fn place_fanout_via_on_bbox_in_direction(
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
|
recorder: &mut BoardEdit,
|
||||||
ratvertex: NodeIndex<usize>,
|
ratvertex: NodeIndex<usize>,
|
||||||
source_dot: FixedDotIndex,
|
source_dot: FixedDotIndex,
|
||||||
bbox: AABB<[f64; 2]>,
|
bbox: AABB<[f64; 2]>,
|
||||||
|
|
@ -409,10 +424,8 @@ impl Anterouter {
|
||||||
* (bbox_center + bbox_anchor_with_clearance - center)
|
* (bbox_center + bbox_anchor_with_clearance - center)
|
||||||
.dot(cardinal_direction_vector);
|
.dot(cardinal_direction_vector);
|
||||||
|
|
||||||
let mut board_edit = BoardEdit::new();
|
|
||||||
|
|
||||||
if let Ok((via, dots)) = autorouter.board.add_via(
|
if let Ok((via, dots)) = autorouter.board.add_via(
|
||||||
&mut board_edit,
|
recorder,
|
||||||
ViaWeight {
|
ViaWeight {
|
||||||
from_layer: std::cmp::min(source_layer, target_layer),
|
from_layer: std::cmp::min(source_layer, target_layer),
|
||||||
to_layer: std::cmp::max(source_layer, target_layer),
|
to_layer: std::cmp::max(source_layer, target_layer),
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
board::edit::BoardEdit,
|
board::edit::BoardEdit,
|
||||||
drawing::graph::PrimitiveIndex,
|
drawing::graph::PrimitiveIndex,
|
||||||
geometry::primitive::PrimitiveShape,
|
geometry::{edit::Edit, primitive::PrimitiveShape},
|
||||||
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
router::{navcord::Navcord, navmesh::Navmesh, thetastar::ThetastarStepper},
|
||||||
stepper::{Abort, EstimateProgress, Step},
|
stepper::{Abort, EstimateProgress, Step},
|
||||||
};
|
};
|
||||||
|
|
@ -31,6 +31,7 @@ pub struct MultilayerAutorouteOptions {
|
||||||
|
|
||||||
pub struct MultilayerAutorouteExecutionStepper {
|
pub struct MultilayerAutorouteExecutionStepper {
|
||||||
planar: PlanarAutorouteExecutionPermutator,
|
planar: PlanarAutorouteExecutionPermutator,
|
||||||
|
anteroute_edit: BoardEdit,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MultilayerAutorouteExecutionStepper {
|
impl MultilayerAutorouteExecutionStepper {
|
||||||
|
|
@ -41,10 +42,12 @@ impl MultilayerAutorouteExecutionStepper {
|
||||||
options: MultilayerAutorouteOptions,
|
options: MultilayerAutorouteOptions,
|
||||||
) -> Result<Self, AutorouterError> {
|
) -> Result<Self, AutorouterError> {
|
||||||
let mut assigner = Anterouter::new(plan);
|
let mut assigner = Anterouter::new(plan);
|
||||||
assigner.anteroute(autorouter, &options.anterouter);
|
let mut anteroute_edit = BoardEdit::new();
|
||||||
|
assigner.anteroute(autorouter, &mut anteroute_edit, &options.anterouter);
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
planar: PlanarAutorouteExecutionPermutator::new(autorouter, ratlines, options.planar)?,
|
planar: PlanarAutorouteExecutionPermutator::new(autorouter, ratlines, options.planar)?,
|
||||||
|
anteroute_edit,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +62,14 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, PlanarAutorouteCo
|
||||||
autorouter: &mut Autorouter<M>,
|
autorouter: &mut Autorouter<M>,
|
||||||
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteContinueStatus>, AutorouterError>
|
) -> Result<ControlFlow<Option<BoardEdit>, PlanarAutorouteContinueStatus>, AutorouterError>
|
||||||
{
|
{
|
||||||
self.planar.step(autorouter)
|
match self.planar.step(autorouter) {
|
||||||
|
Ok(ControlFlow::Break(Some(edit))) => {
|
||||||
|
self.anteroute_edit.merge(edit);
|
||||||
|
// FIXME: Unnecessary large clone.
|
||||||
|
Ok(ControlFlow::Break(Some(self.anteroute_edit.clone())))
|
||||||
|
}
|
||||||
|
x => x,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue