Revert "layout: encapsulate weight geometrical datas in new "geodata" structs"

This reverts commit a3ba8c9ba9.

This wasn't the right approach. Instead, we need a superordinate struct
that will manage the connectivity without layout knowing anything about
it.
This commit is contained in:
Mikolaj Wielgus 2024-02-27 06:18:30 +00:00
parent 88c353896c
commit bec701dbc9
7 changed files with 53 additions and 90 deletions

View File

@ -5,13 +5,13 @@ use thiserror::Error;
use crate::{
geometry::GetWidth,
layout::{
bend::{BendGeodata, BendIndex, LooseBendWeight},
dot::{DotGeodata, DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
bend::{BendIndex, LooseBendWeight},
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
graph::{GetBandIndex, MakePrimitive},
guide::{Guide, Head, HeadTrait, SegbendHead},
primitive::GetOtherJoint,
rules::RulesTrait,
seg::{LoneLooseSegWeight, SegGeodata, SeqLooseSegWeight},
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
Infringement, Layout, LayoutException,
},
math::{Circle, NoTangents},
@ -67,10 +67,8 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
into.into(),
LoneLooseSegWeight {
band: head.band(),
geodata: SegGeodata {
width: self.layout.band(head.band()).width(),
},
},
)
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
}
@ -81,10 +79,8 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
dot,
SeqLooseSegWeight {
band: head.band(),
geodata: SegGeodata {
width: self.layout.band(head.band()).width(),
},
},
)
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
}
@ -224,20 +220,19 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
around,
LooseDotWeight {
band: head.band(),
geodata: DotGeodata {
circle: Circle {
pos: to,
r: width / 2.0,
},
},
},
SeqLooseSegWeight {
band: head.band(),
geodata: SegGeodata { width },
width,
},
LooseBendWeight {
band: head.band(),
geodata: BendGeodata { width, offset },
width,
offset,
},
cw,
)?;

View File

@ -1,11 +1,7 @@
use std::collections::HashMap;
use crate::{
layout::{
dot::{DotGeodata, FixedDotWeight},
seg::{FixedSegWeight, SegGeodata},
Layout,
},
layout::{dot::FixedDotWeight, seg::FixedSegWeight, Layout},
math::Circle,
};
@ -50,12 +46,10 @@ impl DsnDesign {
// take the list of pins
// and for each pin id output (pin id, net id)
net.pins.ids
.iter()
.map(|id| (id.clone(), *net_id))
net.pins.ids.iter().map(|id| (id.clone(), *net_id))
})
// flatten the nested iters into a single stream of tuples
.flatten()
.flatten(),
)
} else {
HashMap::<String, usize>::new()
@ -94,10 +88,7 @@ impl DsnDesign {
};
layout
.add_fixed_dot(FixedDotWeight {
continent: continent,
geodata: DotGeodata { circle },
})
.add_fixed_dot(FixedDotWeight { continent, circle })
.unwrap();
}
}
@ -131,10 +122,7 @@ impl DsnDesign {
};
layout
.add_fixed_dot(FixedDotWeight {
continent,
geodata: DotGeodata { circle },
})
.add_fixed_dot(FixedDotWeight { continent, circle })
.unwrap()
})
.collect();
@ -147,7 +135,6 @@ impl DsnDesign {
let mut prev_index = layout
.add_fixed_dot(FixedDotWeight {
continent,
geodata: DotGeodata {
circle: Circle {
pos: (
wire.path.coords[0].x as f64 / 100.0,
@ -156,7 +143,6 @@ impl DsnDesign {
.into(),
r: wire.path.width as f64 / 100.0,
},
},
})
.unwrap();
@ -165,12 +151,10 @@ impl DsnDesign {
let index = layout
.add_fixed_dot(FixedDotWeight {
continent,
geodata: DotGeodata {
circle: Circle {
pos: (coord.x as f64 / 100.0, -coord.y as f64 / 100.0).into(),
r: wire.path.width as f64 / 100.0,
},
},
})
.unwrap();
@ -181,10 +165,8 @@ impl DsnDesign {
index,
FixedSegWeight {
continent,
geodata: SegGeodata {
width: wire.path.width as f64 / 100.0,
},
},
)
.unwrap();

View File

@ -45,12 +45,6 @@ impl TryFrom<GeometryIndex> for BendIndex {
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct BendGeodata {
pub width: f64,
pub offset: f64,
}
#[enum_dispatch(GetOffset, SetOffset, GetWidth)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum BendWeight {
@ -84,7 +78,8 @@ impl BendWeightTrait<GeometryWeight> for BendWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedBendWeight {
pub continent: ContinentIndex,
pub geodata: BendGeodata,
pub width: f64,
pub offset: f64,
}
impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex);
@ -92,43 +87,44 @@ impl BendWeightTrait<GeometryWeight> for FixedBendWeight {}
impl GetOffset for FixedBendWeight {
fn offset(&self) -> f64 {
self.geodata.offset
self.offset
}
}
impl SetOffset for FixedBendWeight {
fn set_offset(&mut self, offset: f64) {
self.geodata.offset = offset
self.offset = offset
}
}
impl GetWidth for FixedBendWeight {
fn width(&self) -> f64 {
self.geodata.width
self.width
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LooseBendWeight {
pub band: BandIndex,
pub geodata: BendGeodata,
pub width: f64,
pub offset: f64,
}
impl GetOffset for LooseBendWeight {
fn offset(&self) -> f64 {
self.geodata.offset
self.offset
}
}
impl SetOffset for LooseBendWeight {
fn set_offset(&mut self, offset: f64) {
self.geodata.offset = offset
self.offset = offset
}
}
impl GetWidth for LooseBendWeight {
fn width(&self) -> f64 {
self.geodata.width
self.width
}
}

View File

@ -47,11 +47,6 @@ impl TryFrom<GeometryIndex> for DotIndex {
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct DotGeodata {
pub circle: Circle,
}
#[enum_dispatch(GetPos, SetPos, GetWidth)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum DotWeight {
@ -85,7 +80,7 @@ impl DotWeightTrait<GeometryWeight> for DotWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedDotWeight {
pub continent: ContinentIndex,
pub geodata: DotGeodata,
pub circle: Circle,
}
impl_fixed_weight!(FixedDotWeight, FixedDot, FixedDotIndex);
@ -93,26 +88,26 @@ impl DotWeightTrait<GeometryWeight> for FixedDotWeight {}
impl GetPos for FixedDotWeight {
fn pos(&self) -> Point {
self.geodata.circle.pos
self.circle.pos
}
}
impl SetPos for FixedDotWeight {
fn set_pos(&mut self, pos: Point) {
self.geodata.circle.pos = pos
self.circle.pos = pos
}
}
impl GetWidth for FixedDotWeight {
fn width(&self) -> f64 {
self.geodata.circle.r * 2.0
self.circle.r * 2.0
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LooseDotWeight {
pub band: BandIndex,
pub geodata: DotGeodata,
pub circle: Circle,
}
impl_loose_weight!(LooseDotWeight, LooseDot, LooseDotIndex);
@ -120,18 +115,18 @@ impl DotWeightTrait<GeometryWeight> for LooseDotWeight {}
impl GetPos for LooseDotWeight {
fn pos(&self) -> Point {
self.geodata.circle.pos
self.circle.pos
}
}
impl SetPos for LooseDotWeight {
fn set_pos(&mut self, pos: Point) {
self.geodata.circle.pos = pos
self.circle.pos = pos
}
}
impl GetWidth for LooseDotWeight {
fn width(&self) -> f64 {
self.geodata.circle.r * 2.0
self.circle.r * 2.0
}
}

View File

@ -85,7 +85,7 @@ impl<'a, R: RulesTrait> Guide<'a, R> {
) -> Result<Line, NoTangents> {
let from_circle = self.head_circle(head, width);
let to_circle = Circle {
pos: self.layout.primitive(into).weight().geodata.circle.pos,
pos: self.layout.primitive(into).weight().circle.pos,
r: 0.0,
};

View File

@ -474,7 +474,7 @@ impl<'a, R: RulesTrait> GetLimbs for LooseBend<'a, R> {}
impl<'a, R: RulesTrait> GetOffset for LooseBend<'a, R> {
fn offset(&self) -> f64 {
self.weight().offset()
self.weight().offset
}
}

View File

@ -48,11 +48,6 @@ impl TryFrom<GeometryIndex> for SegIndex {
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SegGeodata {
pub width: f64,
}
#[enum_dispatch(GetWidth)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum SegWeight {
@ -89,7 +84,7 @@ impl SegWeightTrait<GeometryWeight> for SegWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedSegWeight {
pub continent: ContinentIndex,
pub geodata: SegGeodata,
pub width: f64,
}
impl_fixed_weight!(FixedSegWeight, FixedSeg, FixedSegIndex);
@ -97,14 +92,14 @@ impl SegWeightTrait<GeometryWeight> for FixedSegWeight {}
impl GetWidth for FixedSegWeight {
fn width(&self) -> f64 {
self.geodata.width
self.width
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct LoneLooseSegWeight {
pub band: BandIndex,
pub geodata: SegGeodata,
pub width: f64,
}
impl_loose_weight!(LoneLooseSegWeight, LoneLooseSeg, LoneLooseSegIndex);
@ -112,14 +107,14 @@ impl SegWeightTrait<GeometryWeight> for LoneLooseSegWeight {}
impl GetWidth for LoneLooseSegWeight {
fn width(&self) -> f64 {
self.geodata.width
self.width
}
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct SeqLooseSegWeight {
pub band: BandIndex,
pub geodata: SegGeodata,
pub width: f64,
}
impl_loose_weight!(SeqLooseSegWeight, SeqLooseSeg, SeqLooseSegIndex);
@ -127,6 +122,6 @@ impl SegWeightTrait<GeometryWeight> for SeqLooseSegWeight {}
impl GetWidth for SeqLooseSegWeight {
fn width(&self) -> f64 {
self.geodata.width
self.width
}
}