mirror of https://codeberg.org/topola/topola.git
refactor: get rid of unnecessary bounds on struct generics
This commit is contained in:
parent
3cb3a9a230
commit
ba41ff6837
|
|
@ -117,7 +117,7 @@ pub struct ListTokenizer<R> {
|
||||||
column: usize,
|
column: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: std::io::BufRead> ListTokenizer<R> {
|
impl<R> ListTokenizer<R> {
|
||||||
pub fn new(reader: R) -> Self {
|
pub fn new(reader: R) -> Self {
|
||||||
Self {
|
Self {
|
||||||
reader,
|
reader,
|
||||||
|
|
@ -140,7 +140,9 @@ impl<R: std::io::BufRead> ListTokenizer<R> {
|
||||||
context: (self.line, self.column),
|
context: (self.line, self.column),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<R: std::io::BufRead> ListTokenizer<R> {
|
||||||
fn next_char(&mut self) -> Result<char, ParseErrorContext> {
|
fn next_char(&mut self) -> Result<char, ParseErrorContext> {
|
||||||
let return_chr = self.peek_char()?;
|
let return_chr = self.peek_char()?;
|
||||||
self.reset_char();
|
self.reset_char();
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,14 @@ impl<W: io::Write> WriteSes<W> for f64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ListWriter<W: io::Write> {
|
pub struct ListWriter<W> {
|
||||||
writable: W,
|
writable: W,
|
||||||
indent_level: usize,
|
indent_level: usize,
|
||||||
multiline_level: usize,
|
multiline_level: usize,
|
||||||
pub line_len: usize,
|
pub line_len: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<W: io::Write> ListWriter<W> {
|
impl<W> ListWriter<W> {
|
||||||
pub fn new(writable: W) -> Self {
|
pub fn new(writable: W) -> Self {
|
||||||
Self {
|
Self {
|
||||||
writable,
|
writable,
|
||||||
|
|
@ -82,7 +82,9 @@ impl<W: io::Write> ListWriter<W> {
|
||||||
line_len: 0,
|
line_len: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<W: io::Write> ListWriter<W> {
|
||||||
pub fn write_token(&mut self, token: ListToken) -> Result<(), io::Error> {
|
pub fn write_token(&mut self, token: ListToken) -> Result<(), io::Error> {
|
||||||
let len = token.len();
|
let len = token.len();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ pub enum AutorouterError {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Getters)]
|
#[derive(Getters)]
|
||||||
pub struct Autorouter<M: AccessMesadata> {
|
pub struct Autorouter<M> {
|
||||||
pub(super) board: Board<M>,
|
pub(super) board: Board<M>,
|
||||||
pub(super) ratsnest: Ratsnest,
|
pub(super) ratsnest: Ratsnest,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,7 @@ pub enum InvokerError {
|
||||||
|
|
||||||
#[derive(Getters, Dissolve)]
|
#[derive(Getters, Dissolve)]
|
||||||
/// Structure that manages the execution and history of commands within the autorouting system
|
/// Structure that manages the execution and history of commands within the autorouting system
|
||||||
pub struct Invoker<M: AccessMesadata> {
|
pub struct Invoker<M> {
|
||||||
/// Instance for executing desired autorouting commands
|
/// Instance for executing desired autorouting commands
|
||||||
pub(super) autorouter: Autorouter<M>,
|
pub(super) autorouter: Autorouter<M>,
|
||||||
/// History of executed commands
|
/// History of executed commands
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ impl BandName {
|
||||||
/// The struct manages the relationships between board's layout,
|
/// The struct manages the relationships between board's layout,
|
||||||
/// and its compounds, as well as provides methods to manipulate them.
|
/// and its compounds, as well as provides methods to manipulate them.
|
||||||
#[derive(Debug, Getters)]
|
#[derive(Debug, Getters)]
|
||||||
pub struct Board<M: AccessMesadata> {
|
pub struct Board<M> {
|
||||||
layout: Layout<M>,
|
layout: Layout<M>,
|
||||||
// TODO: Simplify access logic to these members so that `#[getter(skip)]`s can be removed.
|
// TODO: Simplify access logic to these members so that `#[getter(skip)]`s can be removed.
|
||||||
#[getter(skip)]
|
#[getter(skip)]
|
||||||
|
|
@ -61,7 +61,7 @@ pub struct Board<M: AccessMesadata> {
|
||||||
band_bandname: BiHashMap<BandUid, BandName>,
|
band_bandname: BiHashMap<BandUid, BandName>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: AccessMesadata> Board<M> {
|
impl<M> Board<M> {
|
||||||
/// Initializes the board with given [`Layout`]
|
/// Initializes the board with given [`Layout`]
|
||||||
pub fn new(layout: Layout<M>) -> Self {
|
pub fn new(layout: Layout<M>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -71,6 +71,13 @@ impl<M: AccessMesadata> Board<M> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns a mutable reference to the layout, allowing modifications.
|
||||||
|
pub fn layout_mut(&mut self) -> &mut Layout<M> {
|
||||||
|
&mut self.layout
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<M: AccessMesadata> Board<M> {
|
||||||
/// Adds a new fixed dot with an optional pin name.
|
/// Adds a new fixed dot with an optional pin name.
|
||||||
///
|
///
|
||||||
/// Inserts the dot into the layout and, if a pin name is provided, maps it to the created dot's node.
|
/// Inserts the dot into the layout and, if a pin name is provided, maps it to the created dot's node.
|
||||||
|
|
@ -249,11 +256,6 @@ impl<M: AccessMesadata> Board<M> {
|
||||||
pub fn mesadata(&self) -> &M {
|
pub fn mesadata(&self) -> &M {
|
||||||
self.layout.drawing().rules()
|
self.layout.drawing().rules()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns a mutable reference to the layout, allowing modifications.
|
|
||||||
pub fn layout_mut(&mut self) -> &mut Layout<M> {
|
|
||||||
&mut self.layout
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<M: AccessMesadata>
|
impl<M: AccessMesadata>
|
||||||
|
|
|
||||||
|
|
@ -56,20 +56,18 @@ impl From<BandTermsegIndex> for LooseIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, CW: Copy, R: AccessRules> MakeRef<'a, BandRef<'a, CW, R>, Drawing<CW, R>>
|
impl<'a, CW, R> MakeRef<'a, BandRef<'a, CW, R>, Drawing<CW, R>> for BandTermsegIndex {
|
||||||
for BandTermsegIndex
|
|
||||||
{
|
|
||||||
fn ref_(&self, drawing: &'a Drawing<CW, R>) -> BandRef<'a, CW, R> {
|
fn ref_(&self, drawing: &'a Drawing<CW, R>) -> BandRef<'a, CW, R> {
|
||||||
BandRef::new(*self, drawing)
|
BandRef::new(*self, drawing)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct BandRef<'a, CW: Copy, R: AccessRules> {
|
pub struct BandRef<'a, CW, R> {
|
||||||
first_seg: BandTermsegIndex,
|
first_seg: BandTermsegIndex,
|
||||||
drawing: &'a Drawing<CW, R>,
|
drawing: &'a Drawing<CW, R>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, CW: Copy, R: AccessRules> BandRef<'a, CW, R> {
|
impl<'a, CW, R> BandRef<'a, CW, R> {
|
||||||
pub fn new(first_seg: BandTermsegIndex, drawing: &'a Drawing<CW, R>) -> BandRef<'a, CW, R> {
|
pub fn new(first_seg: BandTermsegIndex, drawing: &'a Drawing<CW, R>) -> BandRef<'a, CW, R> {
|
||||||
Self { first_seg, drawing }
|
Self { first_seg, drawing }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,15 +12,17 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Collect<'a, CW: Copy, R: AccessRules> {
|
pub struct Collect<'a, CW, R> {
|
||||||
drawing: &'a Drawing<CW, R>,
|
drawing: &'a Drawing<CW, R>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, CW: Copy, R: AccessRules> Collect<'a, CW, R> {
|
impl<'a, CW, R> Collect<'a, CW, R> {
|
||||||
pub fn new(drawing: &'a Drawing<CW, R>) -> Self {
|
pub fn new(drawing: &'a Drawing<CW, R>) -> Self {
|
||||||
Self { drawing }
|
Self { drawing }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, CW: Copy, R: AccessRules> Collect<'a, CW, R> {
|
||||||
pub fn loose_band_uid(&self, start_loose: LooseIndex) -> BandUid {
|
pub fn loose_band_uid(&self, start_loose: LooseIndex) -> BandUid {
|
||||||
BandUid::new(
|
BandUid::new(
|
||||||
self.loose_band_first_seg(start_loose),
|
self.loose_band_first_seg(start_loose),
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ pub struct Collision(pub PrimitiveShape, pub PrimitiveIndex);
|
||||||
#[error("{1:?} is already connected to net {0}")]
|
#[error("{1:?} is already connected to net {0}")]
|
||||||
pub struct AlreadyConnected(pub usize, pub PrimitiveIndex);
|
pub struct AlreadyConnected(pub usize, pub PrimitiveIndex);
|
||||||
|
|
||||||
pub type DrawingEdit<CW: Copy> = GeometryEdit<
|
pub type DrawingEdit<CW> = GeometryEdit<
|
||||||
PrimitiveWeight,
|
PrimitiveWeight,
|
||||||
DotWeight,
|
DotWeight,
|
||||||
SegWeight,
|
SegWeight,
|
||||||
|
|
@ -79,7 +79,7 @@ pub type DrawingEdit<CW: Copy> = GeometryEdit<
|
||||||
>;
|
>;
|
||||||
|
|
||||||
#[derive(Debug, Getters)]
|
#[derive(Debug, Getters)]
|
||||||
pub struct Drawing<CW: Copy, R: AccessRules> {
|
pub struct Drawing<CW, R> {
|
||||||
recording_geometry_with_rtree: RecordingGeometryWithRtree<
|
recording_geometry_with_rtree: RecordingGeometryWithRtree<
|
||||||
PrimitiveWeight,
|
PrimitiveWeight,
|
||||||
DotWeight,
|
DotWeight,
|
||||||
|
|
|
||||||
|
|
@ -18,15 +18,17 @@ use super::{
|
||||||
Drawing,
|
Drawing,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Guide<'a, CW: Copy, R: AccessRules> {
|
pub struct Guide<'a, CW, R> {
|
||||||
drawing: &'a Drawing<CW, R>,
|
drawing: &'a Drawing<CW, R>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, CW: Copy, R: AccessRules> Guide<'a, CW, R> {
|
impl<'a, CW, R> Guide<'a, CW, R> {
|
||||||
pub fn new(drawing: &'a Drawing<CW, R>) -> Self {
|
pub fn new(drawing: &'a Drawing<CW, R>) -> Self {
|
||||||
Self { drawing }
|
Self { drawing }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, CW: Copy, R: AccessRules> Guide<'a, CW, R> {
|
||||||
pub fn head_into_dot_segment(
|
pub fn head_into_dot_segment(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ pub enum Head {
|
||||||
Cane(CaneHead),
|
Cane(CaneHead),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, CW: Copy, R: AccessRules> MakeRef<'a, HeadRef<'a, CW, R>, Drawing<CW, R>> for Head {
|
impl<'a, CW, R> MakeRef<'a, HeadRef<'a, CW, R>, Drawing<CW, R>> for Head {
|
||||||
fn ref_(&self, drawing: &'a Drawing<CW, R>) -> HeadRef<'a, CW, R> {
|
fn ref_(&self, drawing: &'a Drawing<CW, R>) -> HeadRef<'a, CW, R> {
|
||||||
HeadRef::new(*self, drawing)
|
HeadRef::new(*self, drawing)
|
||||||
}
|
}
|
||||||
|
|
@ -67,18 +67,18 @@ impl GetFace for CaneHead {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct HeadRef<'a, CW: Copy, R: AccessRules> {
|
pub struct HeadRef<'a, CW, R> {
|
||||||
head: Head,
|
head: Head,
|
||||||
drawing: &'a Drawing<CW, R>,
|
drawing: &'a Drawing<CW, R>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, CW: Copy, R: AccessRules> HeadRef<'a, CW, R> {
|
impl<'a, CW, R> HeadRef<'a, CW, R> {
|
||||||
pub fn new(head: Head, drawing: &'a Drawing<CW, R>) -> Self {
|
pub fn new(head: Head, drawing: &'a Drawing<CW, R>) -> Self {
|
||||||
Self { drawing, head }
|
Self { drawing, head }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, CW: Copy, R: AccessRules> GetFace for HeadRef<'a, CW, R> {
|
impl<'a, CW, R> GetFace for HeadRef<'a, CW, R> {
|
||||||
fn face(&self) -> DotIndex {
|
fn face(&self) -> DotIndex {
|
||||||
self.head.face()
|
self.head.face()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,17 +23,7 @@ pub trait ApplyGeometryEdit<
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct GeometryEdit<
|
pub struct GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
|
||||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
|
||||||
DW: AccessDotWeight<PW> + GetLayer,
|
|
||||||
SW: AccessSegWeight<PW> + GetLayer,
|
|
||||||
BW: AccessBendWeight<PW> + GetLayer,
|
|
||||||
CW: Copy,
|
|
||||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
|
|
||||||
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
|
||||||
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
|
||||||
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
|
||||||
> {
|
|
||||||
pub(super) dots: HashMap<DI, (Option<DW>, Option<DW>)>,
|
pub(super) dots: HashMap<DI, (Option<DW>, Option<DW>)>,
|
||||||
pub(super) segs: HashMap<SI, (Option<((DI, DI), SW)>, Option<((DI, DI), SW)>)>,
|
pub(super) segs: HashMap<SI, (Option<((DI, DI), SW)>, Option<((DI, DI), SW)>)>,
|
||||||
pub(super) bends: HashMap<BI, (Option<((DI, DI, DI), BW)>, Option<((DI, DI, DI), BW)>)>,
|
pub(super) bends: HashMap<BI, (Option<((DI, DI, DI), BW)>, Option<((DI, DI, DI), BW)>)>,
|
||||||
|
|
|
||||||
|
|
@ -70,17 +70,7 @@ pub trait AccessSegWeight<PW>: GetWidth + Into<PW> + Copy {}
|
||||||
pub trait AccessBendWeight<PW>: GetOffset + SetOffset + GetWidth + Into<PW> + Copy {}
|
pub trait AccessBendWeight<PW>: GetOffset + SetOffset + GetWidth + Into<PW> + Copy {}
|
||||||
|
|
||||||
#[derive(Debug, Getters)]
|
#[derive(Debug, Getters)]
|
||||||
pub struct Geometry<
|
pub struct Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
|
||||||
PW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
|
||||||
DW: AccessDotWeight<PW>,
|
|
||||||
SW: AccessSegWeight<PW>,
|
|
||||||
BW: AccessBendWeight<PW>,
|
|
||||||
CW: Copy,
|
|
||||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
|
|
||||||
DI: GetPetgraphIndex + Into<PI> + Copy,
|
|
||||||
SI: GetPetgraphIndex + Into<PI> + Copy,
|
|
||||||
BI: GetPetgraphIndex + Into<PI> + Copy,
|
|
||||||
> {
|
|
||||||
graph: StableDiGraph<GenericNode<PW, CW>, GeometryLabel, usize>,
|
graph: StableDiGraph<GenericNode<PW, CW>, GeometryLabel, usize>,
|
||||||
primitive_weight_marker: PhantomData<PW>,
|
primitive_weight_marker: PhantomData<PW>,
|
||||||
dot_weight_marker: PhantomData<DW>,
|
dot_weight_marker: PhantomData<DW>,
|
||||||
|
|
|
||||||
|
|
@ -19,17 +19,7 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RecordingGeometryWithRtree<
|
pub struct RecordingGeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
|
||||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
|
||||||
DW: AccessDotWeight<PW> + GetLayer,
|
|
||||||
SW: AccessSegWeight<PW> + GetLayer,
|
|
||||||
BW: AccessBendWeight<PW> + GetLayer,
|
|
||||||
CW: Copy,
|
|
||||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
|
|
||||||
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
|
||||||
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
|
||||||
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
|
||||||
> {
|
|
||||||
geometry_with_rtree: GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
|
geometry_with_rtree: GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,7 @@ impl RTreeObject for Bbox {
|
||||||
pub type BboxedIndex<I> = GeomWithData<Bbox, I>;
|
pub type BboxedIndex<I> = GeomWithData<Bbox, I>;
|
||||||
|
|
||||||
#[derive(Debug, Getters)]
|
#[derive(Debug, Getters)]
|
||||||
pub struct GeometryWithRtree<
|
pub struct GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
|
||||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
|
||||||
DW: AccessDotWeight<PW> + GetLayer,
|
|
||||||
SW: AccessSegWeight<PW> + GetLayer,
|
|
||||||
BW: AccessBendWeight<PW> + GetLayer,
|
|
||||||
CW: Copy,
|
|
||||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
|
|
||||||
DI: GetPetgraphIndex + Into<PI> + Copy,
|
|
||||||
SI: GetPetgraphIndex + Into<PI> + Copy,
|
|
||||||
BI: GetPetgraphIndex + Into<PI> + Copy,
|
|
||||||
> {
|
|
||||||
geometry: Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
|
geometry: Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
|
||||||
rtree: RTree<BboxedIndex<GenericNode<PI, GenericIndex<CW>>>>,
|
rtree: RTree<BboxedIndex<GenericNode<PI, GenericIndex<CW>>>>,
|
||||||
layer_count: usize,
|
layer_count: usize,
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ pub struct InteractiveInput {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This is the execution context passed to the stepper on each step
|
/// This is the execution context passed to the stepper on each step
|
||||||
pub struct ActivityContext<'a, M: AccessMesadata> {
|
pub struct ActivityContext<'a, M> {
|
||||||
pub interactive_input: &'a InteractiveInput,
|
pub interactive_input: &'a InteractiveInput,
|
||||||
pub invoker: &'a mut Invoker<M>,
|
pub invoker: &'a mut Invoker<M>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Structure that manages the invoker and activities
|
/// Structure that manages the invoker and activities
|
||||||
pub struct Interactor<M: AccessMesadata> {
|
pub struct Interactor<M> {
|
||||||
invoker: Invoker<M>,
|
invoker: Invoker<M>,
|
||||||
activity: Option<ActivityStepperWithStatus>,
|
activity: Option<ActivityStepperWithStatus>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,15 +43,17 @@ pub type LayoutEdit = DrawingEdit<CompoundWeight>;
|
||||||
|
|
||||||
#[derive(Debug, Getters)]
|
#[derive(Debug, Getters)]
|
||||||
/// Structure for managing the Layout design
|
/// Structure for managing the Layout design
|
||||||
pub struct Layout<R: AccessRules> {
|
pub struct Layout<R> {
|
||||||
drawing: Drawing<CompoundWeight, R>,
|
drawing: Drawing<CompoundWeight, R>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R: AccessRules> Layout<R> {
|
impl<R> Layout<R> {
|
||||||
pub fn new(drawing: Drawing<CompoundWeight, R>) -> Self {
|
pub fn new(drawing: Drawing<CompoundWeight, R>) -> Self {
|
||||||
Self { drawing }
|
Self { drawing }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<R: AccessRules> Layout<R> {
|
||||||
/// Insert [`Cane`] object into the [`Layout`]
|
/// Insert [`Cane`] object into the [`Layout`]
|
||||||
pub fn insert_cane(
|
pub fn insert_cane(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ pub trait GetMaybeApex {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Poly<'a, R: AccessRules> {
|
pub struct Poly<'a, R> {
|
||||||
pub index: GenericIndex<PolyWeight>,
|
pub index: GenericIndex<PolyWeight>,
|
||||||
layout: &'a Layout<R>,
|
layout: &'a Layout<R>,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,12 +11,12 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Via<'a, R: AccessRules> {
|
pub struct Via<'a, R> {
|
||||||
pub index: GenericIndex<ViaWeight>,
|
pub index: GenericIndex<ViaWeight>,
|
||||||
layout: &'a Layout<R>,
|
layout: &'a Layout<R>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, R: AccessRules> Via<'a, R> {
|
impl<'a, R> Via<'a, R> {
|
||||||
pub fn new(index: GenericIndex<ViaWeight>, layout: &'a Layout<R>) -> Self {
|
pub fn new(index: GenericIndex<ViaWeight>, layout: &'a Layout<R>) -> Self {
|
||||||
Self { index, layout }
|
Self { index, layout }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ pub enum DrawException {
|
||||||
/// This struct is a simple wrapper whose sole purpose is to have a separate
|
/// This struct is a simple wrapper whose sole purpose is to have a separate
|
||||||
/// file for the router module's routines for drawing and erasing the primitives
|
/// file for the router module's routines for drawing and erasing the primitives
|
||||||
/// to pull out or contract the currently routed band.
|
/// to pull out or contract the currently routed band.
|
||||||
pub struct Draw<'a, R: AccessRules> {
|
pub struct Draw<'a, R> {
|
||||||
layout: &'a mut Layout<R>,
|
layout: &'a mut Layout<R>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -120,7 +120,7 @@ impl NavcordStepper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct NavcordStepContext<'a: 'b, 'b, R: AccessRules> {
|
pub struct NavcordStepContext<'a: 'b, 'b, R> {
|
||||||
pub navcorder: &'b mut Navcorder<'a, R>,
|
pub navcorder: &'b mut Navcorder<'a, R>,
|
||||||
pub navmesh: &'b Navmesh,
|
pub navmesh: &'b Navmesh,
|
||||||
pub to: NavvertexIndex,
|
pub to: NavvertexIndex,
|
||||||
|
|
|
||||||
|
|
@ -21,15 +21,17 @@ pub enum NavcorderException {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Navcorder<'a, R: AccessRules> {
|
pub struct Navcorder<'a, R> {
|
||||||
pub layout: &'a mut Layout<R>,
|
pub layout: &'a mut Layout<R>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, R: AccessRules> Navcorder<'a, R> {
|
impl<'a, R> Navcorder<'a, R> {
|
||||||
pub fn new(layout: &mut Layout<R>) -> Navcorder<R> {
|
pub fn new(layout: &mut Layout<R>) -> Navcorder<R> {
|
||||||
Navcorder { layout }
|
Navcorder { layout }
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, R: AccessRules> Navcorder<'a, R> {
|
||||||
pub fn start(
|
pub fn start(
|
||||||
&mut self,
|
&mut self,
|
||||||
recorder: LayoutEdit,
|
recorder: LayoutEdit,
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ pub struct RouterOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct RouterAstarStrategy<'a, R: AccessRules> {
|
pub struct RouterAstarStrategy<'a, R> {
|
||||||
pub navcorder: Navcorder<'a, R>,
|
pub navcorder: Navcorder<'a, R>,
|
||||||
pub navcord: &'a mut NavcordStepper,
|
pub navcord: &'a mut NavcordStepper,
|
||||||
pub target: FixedDotIndex,
|
pub target: FixedDotIndex,
|
||||||
|
|
@ -46,7 +46,7 @@ pub struct RouterAstarStrategy<'a, R: AccessRules> {
|
||||||
pub probe_obstacles: Vec<PrimitiveIndex>,
|
pub probe_obstacles: Vec<PrimitiveIndex>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
|
impl<'a, R> RouterAstarStrategy<'a, R> {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
navcorder: Navcorder<'a, R>,
|
navcorder: Navcorder<'a, R>,
|
||||||
navcord: &'a mut NavcordStepper,
|
navcord: &'a mut NavcordStepper,
|
||||||
|
|
@ -60,7 +60,9 @@ impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
|
||||||
probe_obstacles: vec![],
|
probe_obstacles: vec![],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
|
||||||
fn bihead_length(&self) -> f64 {
|
fn bihead_length(&self) -> f64 {
|
||||||
self.navcord
|
self.navcord
|
||||||
.head
|
.head
|
||||||
|
|
|
||||||
|
|
@ -12,21 +12,14 @@ pub trait GetTrianvertexNodeIndex<I> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Triangulation<
|
pub struct Triangulation<I, VW: GetTrianvertexNodeIndex<I> + HasPosition, EW: Default> {
|
||||||
I: Copy + PartialEq + GetPetgraphIndex,
|
|
||||||
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
|
||||||
EW: Copy + Default,
|
|
||||||
> {
|
|
||||||
triangulation: DelaunayTriangulation<VW, EW>,
|
triangulation: DelaunayTriangulation<VW, EW>,
|
||||||
trianvertex_to_handle: Box<[Option<FixedVertexHandle>]>,
|
trianvertex_to_handle: Box<[Option<FixedVertexHandle>]>,
|
||||||
index_marker: PhantomData<I>,
|
index_marker: PhantomData<I>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<I: GetPetgraphIndex, VW: GetTrianvertexNodeIndex<I> + HasPosition, EW: Default>
|
||||||
I: Copy + PartialEq + GetPetgraphIndex,
|
Triangulation<I, VW, EW>
|
||||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
|
||||||
EW: Copy + Default,
|
|
||||||
> Triangulation<I, VW, EW>
|
|
||||||
{
|
{
|
||||||
pub fn new(node_bound: usize) -> Self {
|
pub fn new(node_bound: usize) -> Self {
|
||||||
Self {
|
Self {
|
||||||
|
|
@ -57,12 +50,6 @@ impl<
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn position(&self, vertex: I) -> Point {
|
|
||||||
let position =
|
|
||||||
spade::Triangulation::vertex(&self.triangulation, self.handle(vertex)).position();
|
|
||||||
point! {x: position.x, y: position.y}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn vertex(&self, handle: FixedVertexHandle) -> I {
|
fn vertex(&self, handle: FixedVertexHandle) -> I {
|
||||||
spade::Triangulation::vertex(&self.triangulation, handle)
|
spade::Triangulation::vertex(&self.triangulation, handle)
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|
@ -72,12 +59,21 @@ impl<
|
||||||
fn handle(&self, vertex: I) -> FixedVertexHandle {
|
fn handle(&self, vertex: I) -> FixedVertexHandle {
|
||||||
self.trianvertex_to_handle[vertex.petgraph_index().index()].unwrap()
|
self.trianvertex_to_handle[vertex.petgraph_index().index()].unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn position(&self, vertex: I) -> Point<<VW as HasPosition>::Scalar>
|
||||||
|
where
|
||||||
|
<VW as HasPosition>::Scalar: geo::CoordNum,
|
||||||
|
{
|
||||||
|
let position =
|
||||||
|
spade::Triangulation::vertex(&self.triangulation, self.handle(vertex)).position();
|
||||||
|
point! {x: position.x, y: position.y}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<
|
impl<
|
||||||
I: Copy + PartialEq + GetPetgraphIndex,
|
I: Copy + PartialEq + GetPetgraphIndex,
|
||||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||||
EW: Copy + Default,
|
EW: Default,
|
||||||
> visit::GraphBase for Triangulation<I, VW, EW>
|
> visit::GraphBase for Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
type NodeId = I;
|
type NodeId = I;
|
||||||
|
|
@ -85,18 +81,18 @@ impl<
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct TriangulationEdgeWeightWrapper<EW: Copy + Default> {
|
pub struct TriangulationEdgeWeightWrapper<EW> {
|
||||||
length: f64,
|
length: f64,
|
||||||
pub weight: EW,
|
pub weight: EW,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<EW: Copy + Default> PartialEq for TriangulationEdgeWeightWrapper<EW> {
|
impl<EW> PartialEq for TriangulationEdgeWeightWrapper<EW> {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.length.eq(&other.length)
|
self.length.eq(&other.length)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<EW: Copy + Default> PartialOrd for TriangulationEdgeWeightWrapper<EW> {
|
impl<EW> PartialOrd for TriangulationEdgeWeightWrapper<EW> {
|
||||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
self.length.partial_cmp(&other.length)
|
self.length.partial_cmp(&other.length)
|
||||||
}
|
}
|
||||||
|
|
@ -104,7 +100,7 @@ impl<EW: Copy + Default> PartialOrd for TriangulationEdgeWeightWrapper<EW> {
|
||||||
|
|
||||||
impl<
|
impl<
|
||||||
I: Copy + PartialEq + GetPetgraphIndex,
|
I: Copy + PartialEq + GetPetgraphIndex,
|
||||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::Data for Triangulation<I, VW, EW>
|
> visit::Data for Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -113,13 +109,13 @@ impl<
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct TriangulationEdgeReference<I, EW: Copy + Default> {
|
pub struct TriangulationEdgeReference<I, EW> {
|
||||||
from: I,
|
from: I,
|
||||||
to: I,
|
to: I,
|
||||||
weight: TriangulationEdgeWeightWrapper<EW>,
|
weight: TriangulationEdgeWeightWrapper<EW>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<I: Copy, EW: Copy + Default> visit::EdgeRef for TriangulationEdgeReference<I, EW> {
|
impl<I: Copy, EW: Copy> visit::EdgeRef for TriangulationEdgeReference<I, EW> {
|
||||||
type NodeId = I;
|
type NodeId = I;
|
||||||
type EdgeId = (I, I);
|
type EdgeId = (I, I);
|
||||||
type Weight = TriangulationEdgeWeightWrapper<EW>;
|
type Weight = TriangulationEdgeWeightWrapper<EW>;
|
||||||
|
|
@ -144,8 +140,8 @@ impl<I: Copy, EW: Copy + Default> visit::EdgeRef for TriangulationEdgeReference<
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetPetgraphIndex,
|
I: Copy + PartialEq + GetPetgraphIndex,
|
||||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||||
EW: Copy + Default,
|
EW: Default,
|
||||||
> visit::IntoNeighbors for &'a Triangulation<I, VW, EW>
|
> visit::IntoNeighbors for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
type Neighbors = Box<dyn Iterator<Item = I> + 'a>;
|
type Neighbors = Box<dyn Iterator<Item = I> + 'a>;
|
||||||
|
|
@ -221,8 +217,8 @@ impl<
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetPetgraphIndex,
|
I: Copy + PartialEq + GetPetgraphIndex,
|
||||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||||
EW: Copy + Default,
|
EW: Default,
|
||||||
> visit::IntoNodeIdentifiers for &'a Triangulation<I, VW, EW>
|
> visit::IntoNodeIdentifiers for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
type NodeIdentifiers = Box<dyn Iterator<Item = I> + 'a>;
|
type NodeIdentifiers = Box<dyn Iterator<Item = I> + 'a>;
|
||||||
|
|
@ -238,13 +234,24 @@ impl<
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, PartialEq)]
|
||||||
pub struct TriangulationVertexReference<'a, I: Copy, VW> {
|
pub struct TriangulationVertexReference<'a, I, VW> {
|
||||||
index: I,
|
index: I,
|
||||||
weight: &'a VW,
|
weight: &'a VW,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, I: Copy, VW: Copy> visit::NodeRef for TriangulationVertexReference<'a, I, VW> {
|
impl<I: Clone, VW> Clone for TriangulationVertexReference<'_, I, VW> {
|
||||||
|
fn clone(&self) -> Self {
|
||||||
|
Self {
|
||||||
|
index: self.index.clone(),
|
||||||
|
weight: self.weight,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<I: Copy, VW> Copy for TriangulationVertexReference<'_, I, VW> {}
|
||||||
|
|
||||||
|
impl<I: Copy, VW> visit::NodeRef for TriangulationVertexReference<'_, I, VW> {
|
||||||
type NodeId = I;
|
type NodeId = I;
|
||||||
type Weight = VW;
|
type Weight = VW;
|
||||||
|
|
||||||
|
|
@ -260,7 +267,7 @@ impl<'a, I: Copy, VW: Copy> visit::NodeRef for TriangulationVertexReference<'a,
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetPetgraphIndex,
|
I: Copy + PartialEq + GetPetgraphIndex,
|
||||||
VW: Copy + GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||||
EW: Copy + Default,
|
EW: Copy + Default,
|
||||||
> visit::IntoNodeReferences for &'a Triangulation<I, VW, EW>
|
> visit::IntoNodeReferences for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
|
|
@ -283,8 +290,8 @@ impl<
|
||||||
impl<
|
impl<
|
||||||
'a,
|
'a,
|
||||||
I: Copy + PartialEq + GetPetgraphIndex + std::fmt::Debug,
|
I: Copy + PartialEq + GetPetgraphIndex + std::fmt::Debug,
|
||||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||||
EW: Copy + Default,
|
EW: Default,
|
||||||
> visit::NodeIndexable for &'a Triangulation<I, VW, EW>
|
> visit::NodeIndexable for &'a Triangulation<I, VW, EW>
|
||||||
{
|
{
|
||||||
fn node_bound(&self) -> usize {
|
fn node_bound(&self) -> usize {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue