From c005337ea8c033c3ae0b5afdfcbfba9e5bb4a5d3 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 22 Feb 2024 21:23:01 +0000 Subject: [PATCH] layout: rename "component" to "continent" The term "component" has already a meaning in electronics, and moreover the term "connected component" from graph theory may apply to more things (e.g. landmasses made of continents connected with bands may collectively be considered connected components too). --- src/dsn/design.rs | 12 ++++++------ src/layout/bend.rs | 6 +++--- src/layout/connectivity.rs | 8 ++++---- src/layout/dot.rs | 6 +++--- src/layout/graph.rs | 22 +++++++++++----------- src/layout/layout.rs | 18 +++++++++--------- src/layout/primitive.rs | 12 ++++++------ src/layout/seg.rs | 6 +++--- 8 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/dsn/design.rs b/src/dsn/design.rs index 359c77f..90b174f 100644 --- a/src/dsn/design.rs +++ b/src/dsn/design.rs @@ -43,7 +43,7 @@ impl DsnDesign { .iter() .map(|via| { let net_id = net_ids.get(&via.net.0).unwrap(); - let component = layout.add_component(*net_id as i64); + let continent = layout.add_continent(*net_id as i64); // no way to resolve the name or layer support yet // pick the first layer of the first object found @@ -54,19 +54,19 @@ impl DsnDesign { }; layout - .add_fixed_dot(FixedDotWeight { component, circle }) + .add_fixed_dot(FixedDotWeight { continent, circle }) .unwrap() }) .collect(); for wire in self.pcb.wiring.wires.iter() { let net_id = net_ids.get(&wire.net.0).unwrap(); - let component = layout.add_component(*net_id as i64); + let continent = layout.add_continent(*net_id as i64); // add the first coordinate in the wire path as a dot and save its index let mut prev_index = layout .add_fixed_dot(FixedDotWeight { - component, + continent, circle: Circle { pos: ( wire.path.coords[0].x as f64 / 100.0, @@ -82,7 +82,7 @@ impl DsnDesign { for coord in wire.path.coords.iter().skip(1) { let index = layout .add_fixed_dot(FixedDotWeight { - component, + continent, circle: Circle { pos: (coord.x as f64 / 100.0, -coord.y as f64 / 100.0).into(), r: wire.path.width as f64 / 100.0, @@ -96,7 +96,7 @@ impl DsnDesign { prev_index, index, FixedSegWeight { - component, + continent, width: wire.path.width as f64 / 100.0, }, ) diff --git a/src/layout/bend.rs b/src/layout/bend.rs index 15c4a46..000840a 100644 --- a/src/layout/bend.rs +++ b/src/layout/bend.rs @@ -3,10 +3,10 @@ use enum_dispatch::enum_dispatch; use crate::{ graph::{GenericIndex, GetNodeIndex}, layout::{ - connectivity::{BandIndex, ComponentIndex}, + connectivity::{BandIndex, ContinentIndex}, geometry::{BendWeightTrait, GetOffset, GetWidth}, graph::{ - GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut, + GeometryIndex, GeometryWeight, GetBandIndex, GetContinentIndex, GetContinentIndexMut, MakePrimitive, Retag, }, primitive::{GenericPrimitive, Primitive}, @@ -79,7 +79,7 @@ impl BendWeightTrait for BendWeight {} #[derive(Debug, Clone, Copy, PartialEq)] pub struct FixedBendWeight { - pub component: ComponentIndex, + pub continent: ContinentIndex, pub width: f64, pub offset: f64, } diff --git a/src/layout/connectivity.rs b/src/layout/connectivity.rs index d21a1b9..c7ee7fd 100644 --- a/src/layout/connectivity.rs +++ b/src/layout/connectivity.rs @@ -13,22 +13,22 @@ pub type ConnectivityGraph = StableDiGraph i64 { self.net } } -pub type ComponentIndex = GenericIndex; +pub type ContinentIndex = GenericIndex; #[derive(Debug, Clone, Copy)] pub struct BandWeight { diff --git a/src/layout/dot.rs b/src/layout/dot.rs index c673c03..8729f72 100644 --- a/src/layout/dot.rs +++ b/src/layout/dot.rs @@ -6,10 +6,10 @@ use petgraph::stable_graph::NodeIndex; use crate::{ graph::{GenericIndex, GetNodeIndex}, layout::{ - connectivity::{BandIndex, ComponentIndex}, + connectivity::{BandIndex, ContinentIndex}, geometry::{DotWeightTrait, GetPos, GetWidth}, graph::{ - GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut, + GeometryIndex, GeometryWeight, GetBandIndex, GetContinentIndex, GetContinentIndexMut, MakePrimitive, Retag, }, primitive::{GenericPrimitive, Primitive}, @@ -81,7 +81,7 @@ impl DotWeightTrait for DotWeight {} #[derive(Debug, Clone, Copy, PartialEq)] pub struct FixedDotWeight { - pub component: ComponentIndex, + pub continent: ContinentIndex, pub circle: Circle, } diff --git a/src/layout/graph.rs b/src/layout/graph.rs index b58439b..546b6cd 100644 --- a/src/layout/graph.rs +++ b/src/layout/graph.rs @@ -5,7 +5,7 @@ use petgraph::stable_graph::NodeIndex; use crate::{ graph::GetNodeIndex, layout::{ - connectivity::{BandIndex, ComponentIndex}, + connectivity::{BandIndex, ContinentIndex}, Layout, }, }; @@ -27,12 +27,12 @@ pub trait Retag { } #[enum_dispatch] -pub trait GetComponentIndex { - fn component(&self) -> ComponentIndex; +pub trait GetContinentIndex { + fn continent(&self) -> ContinentIndex; } -pub trait GetComponentIndexMut { - fn component_mut(&mut self) -> &mut ComponentIndex; +pub trait GetContinentIndexMut { + fn continent_mut(&mut self) -> &mut ContinentIndex; } pub trait GetBandIndex { @@ -66,15 +66,15 @@ macro_rules! impl_fixed_weight { ($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => { impl_weight!($weight_struct, $weight_variant, $index_struct); - impl GetComponentIndex for $weight_struct { - fn component(&self) -> ComponentIndex { - self.component + impl GetContinentIndex for $weight_struct { + fn continent(&self) -> ContinentIndex { + self.continent } } - impl GetComponentIndexMut for $weight_struct { - fn component_mut(&mut self) -> &mut ComponentIndex { - &mut self.component + impl GetContinentIndexMut for $weight_struct { + fn continent_mut(&mut self) -> &mut ContinentIndex { + &mut self.continent } } }; diff --git a/src/layout/layout.rs b/src/layout/layout.rs index a61716b..5626dac 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -8,8 +8,8 @@ use thiserror::Error; use super::band::Band; use super::connectivity::{ - BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel, - ConnectivityWeight, GetNet, + BandIndex, BandWeight, ConnectivityGraph, ConnectivityLabel, ConnectivityWeight, + ContinentIndex, ContinentWeight, GetNet, }; use super::geometry::with_rtree::GeometryWithRtree; use super::loose::{GetNextLoose, Loose, LooseIndex}; @@ -30,7 +30,7 @@ use crate::layout::{ bend::{FixedBendIndex, LooseBendIndex, LooseBendWeight}, dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight}, geometry::shape::{Shape, ShapeTrait}, - graph::{GeometryIndex, GeometryWeight, GetComponentIndex, MakePrimitive}, + graph::{GeometryIndex, GeometryWeight, GetContinentIndex, MakePrimitive}, primitive::{GenericPrimitive, GetCore, GetInnerOuter, GetJoints, GetOtherJoint, MakeShape}, seg::{ FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, @@ -179,10 +179,10 @@ impl Layout { // TODO: This method shouldn't be public. #[debug_ensures(self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))] #[debug_ensures(self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count()))] - pub fn add_component(&mut self, net: i64) -> ComponentIndex { - ComponentIndex::new( + pub fn add_continent(&mut self, net: i64) -> ContinentIndex { + ContinentIndex::new( self.connectivity - .add_node(ConnectivityWeight::Component(ComponentWeight { net })), + .add_node(ConnectivityWeight::Continent(ContinentWeight { net })), ) } @@ -491,13 +491,13 @@ impl Layout { let seg = self.add_seg_infringably(from.into(), to.into(), weight, &[])?; self.connectivity.update_edge( - self.primitive(from).component().node_index(), + self.primitive(from).continent().node_index(), weight.band.node_index(), ConnectivityLabel::Band, ); self.connectivity.update_edge( weight.band.node_index(), - self.primitive(to).component().node_index(), + self.primitive(to).continent().node_index(), ConnectivityLabel::Band, ); @@ -518,7 +518,7 @@ impl Layout { if let DotIndex::Fixed(dot) = from { self.connectivity.update_edge( - self.primitive(dot).component().node_index(), + self.primitive(dot).continent().node_index(), weight.band.node_index(), ConnectivityLabel::Band, ); diff --git a/src/layout/primitive.rs b/src/layout/primitive.rs index f2b4d62..260f86f 100644 --- a/src/layout/primitive.rs +++ b/src/layout/primitive.rs @@ -9,13 +9,13 @@ use crate::layout::seg::{ }; use crate::layout::{ bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight}, - connectivity::{BandIndex, ComponentIndex, GetNet}, + connectivity::{BandIndex, ContinentIndex, GetNet}, dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight}, geometry::{ shape::{Shape, ShapeTrait}, GetOffset, GetWidth, }, - graph::{GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, Retag}, + graph::{GeometryIndex, GeometryWeight, GetBandIndex, GetContinentIndex, Retag}, loose::LooseIndex, Layout, }; @@ -132,9 +132,9 @@ macro_rules! impl_fixed_primitive { ($primitive_struct:ident, $weight_struct:ident) => { impl_primitive!($primitive_struct, $weight_struct); - impl<'a, R: RulesTrait> GetComponentIndex for $primitive_struct<'a, R> { - fn component(&self) -> ComponentIndex { - self.weight().component() + impl<'a, R: RulesTrait> GetContinentIndex for $primitive_struct<'a, R> { + fn continent(&self) -> ContinentIndex { + self.weight().continent() } } @@ -142,7 +142,7 @@ macro_rules! impl_fixed_primitive { fn net(&self) -> i64 { self.layout() .connectivity() - .node_weight(self.component().node_index()) + .node_weight(self.continent().node_index()) .unwrap() .net() } diff --git a/src/layout/seg.rs b/src/layout/seg.rs index afc1bd3..7c63f8e 100644 --- a/src/layout/seg.rs +++ b/src/layout/seg.rs @@ -3,10 +3,10 @@ use enum_dispatch::enum_dispatch; use crate::{ graph::{GenericIndex, GetNodeIndex}, layout::{ - connectivity::{BandIndex, ComponentIndex}, + connectivity::{BandIndex, ContinentIndex}, geometry::{GetWidth, SegWeightTrait}, graph::{ - GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut, + GeometryIndex, GeometryWeight, GetBandIndex, GetContinentIndex, GetContinentIndexMut, MakePrimitive, Retag, }, primitive::{GenericPrimitive, Primitive}, @@ -83,7 +83,7 @@ impl SegWeightTrait for SegWeight {} #[derive(Debug, Clone, Copy, PartialEq)] pub struct FixedSegWeight { - pub component: ComponentIndex, + pub continent: ContinentIndex, pub width: f64, }