diff --git a/src/layout/layout.rs b/src/layout/layout.rs index 8e74635..a884544 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -343,11 +343,11 @@ impl Layout { } pub fn poly(&self, index: GenericIndex) -> Poly { - Poly::new(index, self) + Poly::new(index, self.drawing()) } pub fn via(&self, index: GenericIndex) -> Via { - Via::new(index, self) + Via::new(index, self.drawing()) } } diff --git a/src/layout/poly.rs b/src/layout/poly.rs index 23b3808..b2c5457 100644 --- a/src/layout/poly.rs +++ b/src/layout/poly.rs @@ -15,10 +15,11 @@ use crate::{ primitive::GetLimbs, rules::AccessRules, seg::SegIndex, + Drawing, }, geometry::GetPos, graph::{GenericIndex, GetPetgraphIndex}, - layout::{CompoundWeight, Layout}, + layout::CompoundWeight, }; #[enum_dispatch] @@ -34,31 +35,28 @@ pub trait GetMaybeApex { #[derive(Debug)] pub struct Poly<'a, R> { pub index: GenericIndex, - layout: &'a Layout, + drawing: &'a Drawing, } impl<'a, R: AccessRules> Poly<'a, R> { - pub fn new(index: GenericIndex, layout: &'a Layout) -> Self { - Self { index, layout } + pub fn new(index: GenericIndex, drawing: &'a Drawing) -> Self { + Self { index, drawing } } fn is_apex(&self, dot: FixedDotIndex) -> bool { !self - .layout - .drawing() + .drawing .primitive(dot) .segs() .iter() .any(|seg| matches!(seg, SegIndex::Fixed(..))) - && self.layout.drawing().primitive(dot).bends().is_empty() + && self.drawing.primitive(dot).bends().is_empty() } } impl<'a, R: AccessRules> GetLayer for Poly<'a, R> { fn layer(&self) -> usize { - if let CompoundWeight::Poly(weight) = - self.layout.drawing().compound_weight(self.index.into()) - { + if let CompoundWeight::Poly(weight) = self.drawing.compound_weight(self.index.into()) { weight.layer() } else { unreachable!(); @@ -68,10 +66,7 @@ impl<'a, R: AccessRules> GetLayer for Poly<'a, R> { impl<'a, R: AccessRules> GetMaybeNet for Poly<'a, R> { fn maybe_net(&self) -> Option { - self.layout - .drawing() - .compound_weight(self.index.into()) - .maybe_net() + self.drawing.compound_weight(self.index.into()).maybe_net() } } @@ -79,8 +74,7 @@ impl<'a, R: AccessRules> MakePolygon for Poly<'a, R> { fn shape(&self) -> Polygon { Polygon::new( LineString::from( - self.layout - .drawing() + self.drawing .geometry() .compound_members(self.index.into()) .filter_map(|primitive_node| { @@ -91,13 +85,7 @@ impl<'a, R: AccessRules> MakePolygon for Poly<'a, R> { if self.is_apex(dot) { None } else { - Some( - self.layout - .drawing() - .geometry() - .dot_weight(dot.into()) - .pos(), - ) + Some(self.drawing.geometry().dot_weight(dot.into()).pos()) } }) .collect::>(), @@ -109,8 +97,7 @@ impl<'a, R: AccessRules> MakePolygon for Poly<'a, R> { impl<'a, R: AccessRules> GetMaybeApex for Poly<'a, R> { fn maybe_apex(&self) -> Option { - self.layout - .drawing() + self.drawing .geometry() .compound_members(self.index.into()) .find_map(|primitive_node| { diff --git a/src/layout/via.rs b/src/layout/via.rs index a478df5..667d8fe 100644 --- a/src/layout/via.rs +++ b/src/layout/via.rs @@ -11,39 +11,35 @@ use crate::{ graph::{GetMaybeNet, IsInLayer}, primitive::MakePrimitiveShape, rules::AccessRules, + Drawing, }, geometry::primitive::{DotShape, PrimitiveShape}, graph::{GenericIndex, GetPetgraphIndex}, - layout::{CompoundWeight, Layout}, + layout::CompoundWeight, math::Circle, }; #[derive(Debug)] pub struct Via<'a, R> { pub index: GenericIndex, - layout: &'a Layout, + drawing: &'a Drawing, } impl<'a, R> Via<'a, R> { - pub fn new(index: GenericIndex, layout: &'a Layout) -> Self { - Self { index, layout } + pub fn new(index: GenericIndex, drawing: &'a Drawing) -> Self { + Self { index, drawing } } } impl<'a, R: AccessRules> GetMaybeNet for Via<'a, R> { fn maybe_net(&self) -> Option { - self.layout - .drawing() - .compound_weight(self.index.into()) - .maybe_net() + self.drawing.compound_weight(self.index.into()).maybe_net() } } impl<'a, R: AccessRules> MakePrimitiveShape for Via<'a, R> { fn shape(&self) -> PrimitiveShape { - if let CompoundWeight::Via(weight) = - self.layout.drawing().compound_weight(self.index.into()) - { + if let CompoundWeight::Via(weight) = self.drawing.compound_weight(self.index.into()) { weight.shape() } else { unreachable!();