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::{
|
||||
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,9 +67,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
into.into(),
|
||||
LoneLooseSegWeight {
|
||||
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()))?;
|
||||
|
|
@ -81,9 +79,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
|||
dot,
|
||||
SeqLooseSegWeight {
|
||||
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()))?;
|
||||
|
|
@ -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,
|
||||
},
|
||||
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,
|
||||
)?;
|
||||
|
|
|
|||
|
|
@ -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,15 +135,13 @@ 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,
|
||||
-wire.path.coords[0].y as f64 / 100.0,
|
||||
)
|
||||
.into(),
|
||||
r: wire.path.width as f64 / 100.0,
|
||||
},
|
||||
circle: Circle {
|
||||
pos: (
|
||||
wire.path.coords[0].x as f64 / 100.0,
|
||||
-wire.path.coords[0].y as f64 / 100.0,
|
||||
)
|
||||
.into(),
|
||||
r: wire.path.width as f64 / 100.0,
|
||||
},
|
||||
})
|
||||
.unwrap();
|
||||
|
|
@ -165,11 +151,9 @@ 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,
|
||||
},
|
||||
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,9 +165,7 @@ impl DsnDesign {
|
|||
index,
|
||||
FixedSegWeight {
|
||||
continent,
|
||||
geodata: SegGeodata {
|
||||
width: wire.path.width as f64 / 100.0,
|
||||
},
|
||||
width: wire.path.width as f64 / 100.0,
|
||||
},
|
||||
)
|
||||
.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)]
|
||||
#[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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue