mirror of https://codeberg.org/topola/topola.git
refactor(DrawingException): factor out extraction of ghost+obstacle
This commit is contained in:
parent
566949d4c1
commit
22460c75f7
|
|
@ -66,6 +66,17 @@ impl fmt::Debug for DrawingException {
|
|||
}
|
||||
}
|
||||
|
||||
impl DrawingException {
|
||||
pub fn maybe_ghost_and_obstacle(&self) -> Option<(&PrimitiveShape, PrimitiveIndex)> {
|
||||
match self {
|
||||
Self::NoTangents(_) => None,
|
||||
Self::Infringement(Infringement(ghost, obstacle)) => Some((ghost, *obstacle)),
|
||||
Self::Collision(Collision(ghost, obstacle)) => Some((ghost, *obstacle)),
|
||||
Self::AlreadyConnected(_) => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO add real error messages + these should eventually use Display
|
||||
#[derive(Error, Debug, Clone, Copy)]
|
||||
#[error("{0:?} infringes on {1:?}")]
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use crate::{
|
|||
head::GetFace,
|
||||
primitive::MakePrimitiveShape,
|
||||
rules::AccessRules,
|
||||
Collision, DrawingException, Guide, Infringement,
|
||||
Guide,
|
||||
},
|
||||
geometry::{
|
||||
primitive::PrimitiveShape,
|
||||
|
|
@ -116,18 +116,8 @@ impl<R: AccessRules> AstarStrategy<Navmesh, f64, BandTermsegIndex> for RouterAst
|
|||
DrawException::CannotWrapAround(.., layout_err) => layout_err,
|
||||
};
|
||||
|
||||
let (ghost, obstacle) = match layout_err {
|
||||
DrawingException::NoTangents(..) => return None,
|
||||
DrawingException::Infringement(Infringement(ghost, obstacle)) => {
|
||||
(ghost, obstacle)
|
||||
}
|
||||
DrawingException::Collision(Collision(ghost, obstacle)) => {
|
||||
(ghost, obstacle)
|
||||
}
|
||||
DrawingException::AlreadyConnected(..) => return None,
|
||||
};
|
||||
|
||||
self.probe_ghosts = vec![ghost];
|
||||
let (ghost, obstacle) = layout_err.maybe_ghost_and_obstacle()?;
|
||||
self.probe_ghosts = vec![*ghost];
|
||||
self.probe_obstacles = vec![obstacle];
|
||||
}
|
||||
None
|
||||
|
|
|
|||
Loading…
Reference in New Issue