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
|
// TODO add real error messages + these should eventually use Display
|
||||||
#[derive(Error, Debug, Clone, Copy)]
|
#[derive(Error, Debug, Clone, Copy)]
|
||||||
#[error("{0:?} infringes on {1:?}")]
|
#[error("{0:?} infringes on {1:?}")]
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ use crate::{
|
||||||
head::GetFace,
|
head::GetFace,
|
||||||
primitive::MakePrimitiveShape,
|
primitive::MakePrimitiveShape,
|
||||||
rules::AccessRules,
|
rules::AccessRules,
|
||||||
Collision, DrawingException, Guide, Infringement,
|
Guide,
|
||||||
},
|
},
|
||||||
geometry::{
|
geometry::{
|
||||||
primitive::PrimitiveShape,
|
primitive::PrimitiveShape,
|
||||||
|
|
@ -116,18 +116,8 @@ impl<R: AccessRules> AstarStrategy<Navmesh, f64, BandTermsegIndex> for RouterAst
|
||||||
DrawException::CannotWrapAround(.., layout_err) => layout_err,
|
DrawException::CannotWrapAround(.., layout_err) => layout_err,
|
||||||
};
|
};
|
||||||
|
|
||||||
let (ghost, obstacle) = match layout_err {
|
let (ghost, obstacle) = layout_err.maybe_ghost_and_obstacle()?;
|
||||||
DrawingException::NoTangents(..) => return None,
|
self.probe_ghosts = vec![*ghost];
|
||||||
DrawingException::Infringement(Infringement(ghost, obstacle)) => {
|
|
||||||
(ghost, obstacle)
|
|
||||||
}
|
|
||||||
DrawingException::Collision(Collision(ghost, obstacle)) => {
|
|
||||||
(ghost, obstacle)
|
|
||||||
}
|
|
||||||
DrawingException::AlreadyConnected(..) => return None,
|
|
||||||
};
|
|
||||||
|
|
||||||
self.probe_ghosts = vec![ghost];
|
|
||||||
self.probe_obstacles = vec![obstacle];
|
self.probe_obstacles = vec![obstacle];
|
||||||
}
|
}
|
||||||
None
|
None
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue