mirror of https://codeberg.org/topola/topola.git
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:
parent
88c353896c
commit
bec701dbc9
27
src/draw.rs
27
src/draw.rs
|
|
@ -5,13 +5,13 @@ use thiserror::Error;
|
||||||
use crate::{
|
use crate::{
|
||||||
geometry::GetWidth,
|
geometry::GetWidth,
|
||||||
layout::{
|
layout::{
|
||||||
bend::{BendGeodata, BendIndex, LooseBendWeight},
|
bend::{BendIndex, LooseBendWeight},
|
||||||
dot::{DotGeodata, DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
||||||
graph::{GetBandIndex, MakePrimitive},
|
graph::{GetBandIndex, MakePrimitive},
|
||||||
guide::{Guide, Head, HeadTrait, SegbendHead},
|
guide::{Guide, Head, HeadTrait, SegbendHead},
|
||||||
primitive::GetOtherJoint,
|
primitive::GetOtherJoint,
|
||||||
rules::RulesTrait,
|
rules::RulesTrait,
|
||||||
seg::{LoneLooseSegWeight, SegGeodata, SeqLooseSegWeight},
|
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
||||||
Infringement, Layout, LayoutException,
|
Infringement, Layout, LayoutException,
|
||||||
},
|
},
|
||||||
math::{Circle, NoTangents},
|
math::{Circle, NoTangents},
|
||||||
|
|
@ -67,9 +67,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
into.into(),
|
into.into(),
|
||||||
LoneLooseSegWeight {
|
LoneLooseSegWeight {
|
||||||
band: head.band(),
|
band: head.band(),
|
||||||
geodata: SegGeodata {
|
width: self.layout.band(head.band()).width(),
|
||||||
width: self.layout.band(head.band()).width(),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
|
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
|
||||||
|
|
@ -81,9 +79,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
dot,
|
dot,
|
||||||
SeqLooseSegWeight {
|
SeqLooseSegWeight {
|
||||||
band: head.band(),
|
band: head.band(),
|
||||||
geodata: SegGeodata {
|
width: self.layout.band(head.band()).width(),
|
||||||
width: self.layout.band(head.band()).width(),
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
|
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
|
||||||
|
|
@ -224,20 +220,19 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
around,
|
around,
|
||||||
LooseDotWeight {
|
LooseDotWeight {
|
||||||
band: head.band(),
|
band: head.band(),
|
||||||
geodata: DotGeodata {
|
circle: Circle {
|
||||||
circle: Circle {
|
pos: to,
|
||||||
pos: to,
|
r: width / 2.0,
|
||||||
r: width / 2.0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
SeqLooseSegWeight {
|
SeqLooseSegWeight {
|
||||||
band: head.band(),
|
band: head.band(),
|
||||||
geodata: SegGeodata { width },
|
width,
|
||||||
},
|
},
|
||||||
LooseBendWeight {
|
LooseBendWeight {
|
||||||
band: head.band(),
|
band: head.band(),
|
||||||
geodata: BendGeodata { width, offset },
|
width,
|
||||||
|
offset,
|
||||||
},
|
},
|
||||||
cw,
|
cw,
|
||||||
)?;
|
)?;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
layout::{
|
layout::{dot::FixedDotWeight, seg::FixedSegWeight, Layout},
|
||||||
dot::{DotGeodata, FixedDotWeight},
|
|
||||||
seg::{FixedSegWeight, SegGeodata},
|
|
||||||
Layout,
|
|
||||||
},
|
|
||||||
math::Circle,
|
math::Circle,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -50,12 +46,10 @@ impl DsnDesign {
|
||||||
|
|
||||||
// take the list of pins
|
// take the list of pins
|
||||||
// and for each pin id output (pin id, net id)
|
// and for each pin id output (pin id, net id)
|
||||||
net.pins.ids
|
net.pins.ids.iter().map(|id| (id.clone(), *net_id))
|
||||||
.iter()
|
|
||||||
.map(|id| (id.clone(), *net_id))
|
|
||||||
})
|
})
|
||||||
// flatten the nested iters into a single stream of tuples
|
// flatten the nested iters into a single stream of tuples
|
||||||
.flatten()
|
.flatten(),
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
HashMap::<String, usize>::new()
|
HashMap::<String, usize>::new()
|
||||||
|
|
@ -94,10 +88,7 @@ impl DsnDesign {
|
||||||
};
|
};
|
||||||
|
|
||||||
layout
|
layout
|
||||||
.add_fixed_dot(FixedDotWeight {
|
.add_fixed_dot(FixedDotWeight { continent, circle })
|
||||||
continent: continent,
|
|
||||||
geodata: DotGeodata { circle },
|
|
||||||
})
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -131,10 +122,7 @@ impl DsnDesign {
|
||||||
};
|
};
|
||||||
|
|
||||||
layout
|
layout
|
||||||
.add_fixed_dot(FixedDotWeight {
|
.add_fixed_dot(FixedDotWeight { continent, circle })
|
||||||
continent,
|
|
||||||
geodata: DotGeodata { circle },
|
|
||||||
})
|
|
||||||
.unwrap()
|
.unwrap()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
@ -147,15 +135,13 @@ impl DsnDesign {
|
||||||
let mut prev_index = layout
|
let mut prev_index = layout
|
||||||
.add_fixed_dot(FixedDotWeight {
|
.add_fixed_dot(FixedDotWeight {
|
||||||
continent,
|
continent,
|
||||||
geodata: DotGeodata {
|
circle: Circle {
|
||||||
circle: Circle {
|
pos: (
|
||||||
pos: (
|
wire.path.coords[0].x as f64 / 100.0,
|
||||||
wire.path.coords[0].x as f64 / 100.0,
|
-wire.path.coords[0].y as f64 / 100.0,
|
||||||
-wire.path.coords[0].y as f64 / 100.0,
|
)
|
||||||
)
|
.into(),
|
||||||
.into(),
|
r: wire.path.width as f64 / 100.0,
|
||||||
r: wire.path.width as f64 / 100.0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
@ -165,11 +151,9 @@ impl DsnDesign {
|
||||||
let index = layout
|
let index = layout
|
||||||
.add_fixed_dot(FixedDotWeight {
|
.add_fixed_dot(FixedDotWeight {
|
||||||
continent,
|
continent,
|
||||||
geodata: DotGeodata {
|
circle: Circle {
|
||||||
circle: Circle {
|
pos: (coord.x as f64 / 100.0, -coord.y as f64 / 100.0).into(),
|
||||||
pos: (coord.x as f64 / 100.0, -coord.y as f64 / 100.0).into(),
|
r: wire.path.width as f64 / 100.0,
|
||||||
r: wire.path.width as f64 / 100.0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
@ -181,9 +165,7 @@ impl DsnDesign {
|
||||||
index,
|
index,
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
continent,
|
continent,
|
||||||
geodata: SegGeodata {
|
width: wire.path.width as f64 / 100.0,
|
||||||
width: wire.path.width as f64 / 100.0,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
|
||||||
|
|
@ -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)]
|
#[enum_dispatch(GetOffset, SetOffset, GetWidth)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum BendWeight {
|
pub enum BendWeight {
|
||||||
|
|
@ -84,7 +78,8 @@ impl BendWeightTrait<GeometryWeight> for BendWeight {}
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedBendWeight {
|
pub struct FixedBendWeight {
|
||||||
pub continent: ContinentIndex,
|
pub continent: ContinentIndex,
|
||||||
pub geodata: BendGeodata,
|
pub width: f64,
|
||||||
|
pub offset: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex);
|
impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex);
|
||||||
|
|
@ -92,43 +87,44 @@ impl BendWeightTrait<GeometryWeight> for FixedBendWeight {}
|
||||||
|
|
||||||
impl GetOffset for FixedBendWeight {
|
impl GetOffset for FixedBendWeight {
|
||||||
fn offset(&self) -> f64 {
|
fn offset(&self) -> f64 {
|
||||||
self.geodata.offset
|
self.offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SetOffset for FixedBendWeight {
|
impl SetOffset for FixedBendWeight {
|
||||||
fn set_offset(&mut self, offset: f64) {
|
fn set_offset(&mut self, offset: f64) {
|
||||||
self.geodata.offset = offset
|
self.offset = offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetWidth for FixedBendWeight {
|
impl GetWidth for FixedBendWeight {
|
||||||
fn width(&self) -> f64 {
|
fn width(&self) -> f64 {
|
||||||
self.geodata.width
|
self.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct LooseBendWeight {
|
pub struct LooseBendWeight {
|
||||||
pub band: BandIndex,
|
pub band: BandIndex,
|
||||||
pub geodata: BendGeodata,
|
pub width: f64,
|
||||||
|
pub offset: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetOffset for LooseBendWeight {
|
impl GetOffset for LooseBendWeight {
|
||||||
fn offset(&self) -> f64 {
|
fn offset(&self) -> f64 {
|
||||||
self.geodata.offset
|
self.offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SetOffset for LooseBendWeight {
|
impl SetOffset for LooseBendWeight {
|
||||||
fn set_offset(&mut self, offset: f64) {
|
fn set_offset(&mut self, offset: f64) {
|
||||||
self.geodata.offset = offset
|
self.offset = offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetWidth for LooseBendWeight {
|
impl GetWidth for LooseBendWeight {
|
||||||
fn width(&self) -> f64 {
|
fn width(&self) -> f64 {
|
||||||
self.geodata.width
|
self.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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)]
|
#[enum_dispatch(GetPos, SetPos, GetWidth)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum DotWeight {
|
pub enum DotWeight {
|
||||||
|
|
@ -85,7 +80,7 @@ impl DotWeightTrait<GeometryWeight> for DotWeight {}
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedDotWeight {
|
pub struct FixedDotWeight {
|
||||||
pub continent: ContinentIndex,
|
pub continent: ContinentIndex,
|
||||||
pub geodata: DotGeodata,
|
pub circle: Circle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_fixed_weight!(FixedDotWeight, FixedDot, FixedDotIndex);
|
impl_fixed_weight!(FixedDotWeight, FixedDot, FixedDotIndex);
|
||||||
|
|
@ -93,26 +88,26 @@ impl DotWeightTrait<GeometryWeight> for FixedDotWeight {}
|
||||||
|
|
||||||
impl GetPos for FixedDotWeight {
|
impl GetPos for FixedDotWeight {
|
||||||
fn pos(&self) -> Point {
|
fn pos(&self) -> Point {
|
||||||
self.geodata.circle.pos
|
self.circle.pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SetPos for FixedDotWeight {
|
impl SetPos for FixedDotWeight {
|
||||||
fn set_pos(&mut self, pos: Point) {
|
fn set_pos(&mut self, pos: Point) {
|
||||||
self.geodata.circle.pos = pos
|
self.circle.pos = pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetWidth for FixedDotWeight {
|
impl GetWidth for FixedDotWeight {
|
||||||
fn width(&self) -> f64 {
|
fn width(&self) -> f64 {
|
||||||
self.geodata.circle.r * 2.0
|
self.circle.r * 2.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct LooseDotWeight {
|
pub struct LooseDotWeight {
|
||||||
pub band: BandIndex,
|
pub band: BandIndex,
|
||||||
pub geodata: DotGeodata,
|
pub circle: Circle,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_loose_weight!(LooseDotWeight, LooseDot, LooseDotIndex);
|
impl_loose_weight!(LooseDotWeight, LooseDot, LooseDotIndex);
|
||||||
|
|
@ -120,18 +115,18 @@ impl DotWeightTrait<GeometryWeight> for LooseDotWeight {}
|
||||||
|
|
||||||
impl GetPos for LooseDotWeight {
|
impl GetPos for LooseDotWeight {
|
||||||
fn pos(&self) -> Point {
|
fn pos(&self) -> Point {
|
||||||
self.geodata.circle.pos
|
self.circle.pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl SetPos for LooseDotWeight {
|
impl SetPos for LooseDotWeight {
|
||||||
fn set_pos(&mut self, pos: Point) {
|
fn set_pos(&mut self, pos: Point) {
|
||||||
self.geodata.circle.pos = pos
|
self.circle.pos = pos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetWidth for LooseDotWeight {
|
impl GetWidth for LooseDotWeight {
|
||||||
fn width(&self) -> f64 {
|
fn width(&self) -> f64 {
|
||||||
self.geodata.circle.r * 2.0
|
self.circle.r * 2.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ impl<'a, R: RulesTrait> Guide<'a, R> {
|
||||||
) -> Result<Line, NoTangents> {
|
) -> Result<Line, NoTangents> {
|
||||||
let from_circle = self.head_circle(head, width);
|
let from_circle = self.head_circle(head, width);
|
||||||
let to_circle = Circle {
|
let to_circle = Circle {
|
||||||
pos: self.layout.primitive(into).weight().geodata.circle.pos,
|
pos: self.layout.primitive(into).weight().circle.pos,
|
||||||
r: 0.0,
|
r: 0.0,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -474,7 +474,7 @@ impl<'a, R: RulesTrait> GetLimbs for LooseBend<'a, R> {}
|
||||||
|
|
||||||
impl<'a, R: RulesTrait> GetOffset for LooseBend<'a, R> {
|
impl<'a, R: RulesTrait> GetOffset for LooseBend<'a, R> {
|
||||||
fn offset(&self) -> f64 {
|
fn offset(&self) -> f64 {
|
||||||
self.weight().offset()
|
self.weight().offset
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -48,11 +48,6 @@ impl TryFrom<GeometryIndex> for SegIndex {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
||||||
pub struct SegGeodata {
|
|
||||||
pub width: f64,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[enum_dispatch(GetWidth)]
|
#[enum_dispatch(GetWidth)]
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub enum SegWeight {
|
pub enum SegWeight {
|
||||||
|
|
@ -89,7 +84,7 @@ impl SegWeightTrait<GeometryWeight> for SegWeight {}
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedSegWeight {
|
pub struct FixedSegWeight {
|
||||||
pub continent: ContinentIndex,
|
pub continent: ContinentIndex,
|
||||||
pub geodata: SegGeodata,
|
pub width: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_fixed_weight!(FixedSegWeight, FixedSeg, FixedSegIndex);
|
impl_fixed_weight!(FixedSegWeight, FixedSeg, FixedSegIndex);
|
||||||
|
|
@ -97,14 +92,14 @@ impl SegWeightTrait<GeometryWeight> for FixedSegWeight {}
|
||||||
|
|
||||||
impl GetWidth for FixedSegWeight {
|
impl GetWidth for FixedSegWeight {
|
||||||
fn width(&self) -> f64 {
|
fn width(&self) -> f64 {
|
||||||
self.geodata.width
|
self.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct LoneLooseSegWeight {
|
pub struct LoneLooseSegWeight {
|
||||||
pub band: BandIndex,
|
pub band: BandIndex,
|
||||||
pub geodata: SegGeodata,
|
pub width: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_loose_weight!(LoneLooseSegWeight, LoneLooseSeg, LoneLooseSegIndex);
|
impl_loose_weight!(LoneLooseSegWeight, LoneLooseSeg, LoneLooseSegIndex);
|
||||||
|
|
@ -112,14 +107,14 @@ impl SegWeightTrait<GeometryWeight> for LoneLooseSegWeight {}
|
||||||
|
|
||||||
impl GetWidth for LoneLooseSegWeight {
|
impl GetWidth for LoneLooseSegWeight {
|
||||||
fn width(&self) -> f64 {
|
fn width(&self) -> f64 {
|
||||||
self.geodata.width
|
self.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct SeqLooseSegWeight {
|
pub struct SeqLooseSegWeight {
|
||||||
pub band: BandIndex,
|
pub band: BandIndex,
|
||||||
pub geodata: SegGeodata,
|
pub width: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl_loose_weight!(SeqLooseSegWeight, SeqLooseSeg, SeqLooseSegIndex);
|
impl_loose_weight!(SeqLooseSegWeight, SeqLooseSeg, SeqLooseSegIndex);
|
||||||
|
|
@ -127,6 +122,6 @@ impl SegWeightTrait<GeometryWeight> for SeqLooseSegWeight {}
|
||||||
|
|
||||||
impl GetWidth for SeqLooseSegWeight {
|
impl GetWidth for SeqLooseSegWeight {
|
||||||
fn width(&self) -> f64 {
|
fn width(&self) -> f64 {
|
||||||
self.geodata.width
|
self.width
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue