mirror of https://codeberg.org/topola/topola.git
fix(autorouter/autoroute): Skip permutations that result in nothing undone
This commit is contained in:
parent
3cc2315ebe
commit
ce0424b3e6
|
|
@ -92,6 +92,10 @@ impl AutorouteExecutionStepper {
|
||||||
autorouter: &mut Autorouter<impl AccessMesadata>,
|
autorouter: &mut Autorouter<impl AccessMesadata>,
|
||||||
index: usize,
|
index: usize,
|
||||||
) -> Result<(), AutorouterError> {
|
) -> Result<(), AutorouterError> {
|
||||||
|
if index > self.board_data_edits.len() {
|
||||||
|
return Err(AutorouterError::NothingToUndoForPermutation);
|
||||||
|
}
|
||||||
|
|
||||||
self.dissolve_route_stepper_and_push_layout_edit();
|
self.dissolve_route_stepper_and_push_layout_edit();
|
||||||
|
|
||||||
let board_edit = BoardEdit::new_from_edits(
|
let board_edit = BoardEdit::new_from_edits(
|
||||||
|
|
@ -313,11 +317,18 @@ impl<M: AccessMesadata> Step<Autorouter<M>, Option<BoardEdit>, AutorouteContinue
|
||||||
return Err(err);
|
return Err(err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loop {
|
||||||
let Some(permutation) = self.permutations_iter.next() else {
|
let Some(permutation) = self.permutations_iter.next() else {
|
||||||
return Ok(ControlFlow::Break(None));
|
return Ok(ControlFlow::Break(None));
|
||||||
};
|
};
|
||||||
|
|
||||||
self.stepper.permute(autorouter, permutation);
|
match self.stepper.permute(autorouter, permutation) {
|
||||||
|
Ok(()) => break,
|
||||||
|
Err(AutorouterError::NothingToUndoForPermutation) => continue,
|
||||||
|
Err(err) => return Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.stepper.step(autorouter)
|
self.stepper.step(autorouter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,8 @@ pub enum AutorouterError {
|
||||||
CouldNotRemoveBand(BandTermsegIndex),
|
CouldNotRemoveBand(BandTermsegIndex),
|
||||||
#[error("need exactly two ratlines")]
|
#[error("need exactly two ratlines")]
|
||||||
NeedExactlyTwoRatlines,
|
NeedExactlyTwoRatlines,
|
||||||
|
#[error("nothing to undo for permutation")]
|
||||||
|
NothingToUndoForPermutation,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Getters)]
|
#[derive(Getters)]
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue