pub use libreda_db::prelude::{SInt, UInt, WindingNumber, TryCastCoord};
pub use libreda_db::prelude as db;
use db::L2NBase;
pub use libreda_db::iron_shapes::prelude::{Point, SimpleRPolygon};
use std::collections::HashMap;
use super::placement_problem::PlacementProblem;
#[derive(Debug)]
pub enum PlacementError {
ReachedMaxIterations,
Divergence,
Other(String),
}
impl std::fmt::Display for PlacementError {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
PlacementError::ReachedMaxIterations => write!(f, "Reached maximum number of iterations."),
PlacementError::Divergence => write!(f, "Placement diverges."),
PlacementError::Other(s) => write!(f, "{}", s)
}
}
}
impl std::error::Error for PlacementError {
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
None
}
}
pub trait MixedSizePlacer<C: L2NBase> {
fn name(&self) -> &str;
fn find_cell_positions_impl(
&self,
placement_problem: &dyn PlacementProblem<C>
) -> Result<HashMap<C::CellInstId, db::SimpleTransform<C::Coord>>, PlacementError>;
fn find_cell_positions(
&self,
placement_problem: &dyn PlacementProblem<C>
) -> Result<HashMap<C::CellInstId, db::SimpleTransform<C::Coord>>, PlacementError> {
self.find_cell_positions_impl(placement_problem)
}
}