mirror of https://codeberg.org/topola/topola.git
autorouter: don't crash after comparing detours
This commit is contained in:
parent
47d8e82344
commit
c12eea5b4d
|
|
@ -37,6 +37,7 @@ pub struct CompareDetours {
|
||||||
ratline2: EdgeIndex<usize>,
|
ratline2: EdgeIndex<usize>,
|
||||||
total_length1: Option<f64>,
|
total_length1: Option<f64>,
|
||||||
total_length2: Option<f64>,
|
total_length2: Option<f64>,
|
||||||
|
done: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CompareDetours {
|
impl CompareDetours {
|
||||||
|
|
@ -52,6 +53,7 @@ impl CompareDetours {
|
||||||
ratline2,
|
ratline2,
|
||||||
total_length1: None,
|
total_length1: None,
|
||||||
total_length2: None,
|
total_length2: None,
|
||||||
|
done: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -65,6 +67,12 @@ impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterErro
|
||||||
&mut self,
|
&mut self,
|
||||||
autorouter: &mut Autorouter<M>,
|
autorouter: &mut Autorouter<M>,
|
||||||
) -> Result<CompareDetoursStatus, AutorouterError> {
|
) -> Result<CompareDetoursStatus, AutorouterError> {
|
||||||
|
if self.done {
|
||||||
|
return Ok(CompareDetoursStatus::Finished(
|
||||||
|
self.total_length1.unwrap() - self.total_length2.unwrap(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
match self.autoroute.step(autorouter)? {
|
match self.autoroute.step(autorouter)? {
|
||||||
AutorouteStatus::Running => Ok(CompareDetoursStatus::Running),
|
AutorouteStatus::Running => Ok(CompareDetoursStatus::Running),
|
||||||
AutorouteStatus::Routed(band_termseg) => {
|
AutorouteStatus::Routed(band_termseg) => {
|
||||||
|
|
@ -89,6 +97,7 @@ impl<M: AccessMesadata> Step<Autorouter<M>, CompareDetoursStatus, AutorouterErro
|
||||||
|
|
||||||
Ok(CompareDetoursStatus::Running)
|
Ok(CompareDetoursStatus::Running)
|
||||||
} else {
|
} else {
|
||||||
|
self.done = true;
|
||||||
autorouter.undo_autoroute_ratlines(vec![self.ratline2, self.ratline1]);
|
autorouter.undo_autoroute_ratlines(vec![self.ratline2, self.ratline1]);
|
||||||
|
|
||||||
Ok(CompareDetoursStatus::Finished(
|
Ok(CompareDetoursStatus::Finished(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue