From bec701dbc9aae796ec0f76462c5c6ca97e99b1f6 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Tue, 27 Feb 2024 06:18:30 +0000 Subject: [PATCH] Revert "layout: encapsulate weight geometrical datas in new "geodata" structs" This reverts commit a3ba8c9ba9144a796d7b8fd7c7dfc9ff6b04d2ce. This wasn't the right approach. Instead, we need a superordinate struct that will manage the connectivity without layout knowing anything about it. --- src/draw.rs | 27 +++++++++------------- src/dsn/design.rs | 50 +++++++++++++---------------------------- src/layout/bend.rs | 24 +++++++++----------- src/layout/dot.rs | 21 +++++++---------- src/layout/guide.rs | 2 +- src/layout/primitive.rs | 2 +- src/layout/seg.rs | 17 +++++--------- 7 files changed, 53 insertions(+), 90 deletions(-) diff --git a/src/draw.rs b/src/draw.rs index 0707fc7..dc8a0a4 100644 --- a/src/draw.rs +++ b/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, )?; diff --git a/src/dsn/design.rs b/src/dsn/design.rs index 8fd2c57..df90382 100644 --- a/src/dsn/design.rs +++ b/src/dsn/design.rs @@ -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::::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(); diff --git a/src/layout/bend.rs b/src/layout/bend.rs index ad8d6fe..bef35bf 100644 --- a/src/layout/bend.rs +++ b/src/layout/bend.rs @@ -45,12 +45,6 @@ impl TryFrom 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 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 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 } } diff --git a/src/layout/dot.rs b/src/layout/dot.rs index d5149d0..0136c2d 100644 --- a/src/layout/dot.rs +++ b/src/layout/dot.rs @@ -47,11 +47,6 @@ impl TryFrom 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 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 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 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 } } diff --git a/src/layout/guide.rs b/src/layout/guide.rs index 86d6c32..f545c26 100644 --- a/src/layout/guide.rs +++ b/src/layout/guide.rs @@ -85,7 +85,7 @@ impl<'a, R: RulesTrait> Guide<'a, R> { ) -> Result { 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, }; diff --git a/src/layout/primitive.rs b/src/layout/primitive.rs index 022d324..4c7a97b 100644 --- a/src/layout/primitive.rs +++ b/src/layout/primitive.rs @@ -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 } } diff --git a/src/layout/seg.rs b/src/layout/seg.rs index 072aceb..0478fa1 100644 --- a/src/layout/seg.rs +++ b/src/layout/seg.rs @@ -48,11 +48,6 @@ impl TryFrom 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 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 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 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 for SeqLooseSegWeight {} impl GetWidth for SeqLooseSegWeight { fn width(&self) -> f64 { - self.geodata.width + self.width } }