mirror of https://codeberg.org/topola/topola.git
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).
This commit is contained in:
parent
473a877845
commit
c005337ea8
|
|
@ -43,7 +43,7 @@ impl DsnDesign {
|
||||||
.iter()
|
.iter()
|
||||||
.map(|via| {
|
.map(|via| {
|
||||||
let net_id = net_ids.get(&via.net.0).unwrap();
|
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
|
// no way to resolve the name or layer support yet
|
||||||
// pick the first layer of the first object found
|
// pick the first layer of the first object found
|
||||||
|
|
@ -54,19 +54,19 @@ impl DsnDesign {
|
||||||
};
|
};
|
||||||
|
|
||||||
layout
|
layout
|
||||||
.add_fixed_dot(FixedDotWeight { component, circle })
|
.add_fixed_dot(FixedDotWeight { continent, circle })
|
||||||
.unwrap()
|
.unwrap()
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for wire in self.pcb.wiring.wires.iter() {
|
for wire in self.pcb.wiring.wires.iter() {
|
||||||
let net_id = net_ids.get(&wire.net.0).unwrap();
|
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
|
// add the first coordinate in the wire path as a dot and save its index
|
||||||
let mut prev_index = layout
|
let mut prev_index = layout
|
||||||
.add_fixed_dot(FixedDotWeight {
|
.add_fixed_dot(FixedDotWeight {
|
||||||
component,
|
continent,
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: (
|
pos: (
|
||||||
wire.path.coords[0].x as f64 / 100.0,
|
wire.path.coords[0].x as f64 / 100.0,
|
||||||
|
|
@ -82,7 +82,7 @@ impl DsnDesign {
|
||||||
for coord in wire.path.coords.iter().skip(1) {
|
for coord in wire.path.coords.iter().skip(1) {
|
||||||
let index = layout
|
let index = layout
|
||||||
.add_fixed_dot(FixedDotWeight {
|
.add_fixed_dot(FixedDotWeight {
|
||||||
component,
|
continent,
|
||||||
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,
|
||||||
|
|
@ -96,7 +96,7 @@ impl DsnDesign {
|
||||||
prev_index,
|
prev_index,
|
||||||
index,
|
index,
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
component,
|
continent,
|
||||||
width: wire.path.width as f64 / 100.0,
|
width: wire.path.width as f64 / 100.0,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ use enum_dispatch::enum_dispatch;
|
||||||
use crate::{
|
use crate::{
|
||||||
graph::{GenericIndex, GetNodeIndex},
|
graph::{GenericIndex, GetNodeIndex},
|
||||||
layout::{
|
layout::{
|
||||||
connectivity::{BandIndex, ComponentIndex},
|
connectivity::{BandIndex, ContinentIndex},
|
||||||
geometry::{BendWeightTrait, GetOffset, GetWidth},
|
geometry::{BendWeightTrait, GetOffset, GetWidth},
|
||||||
graph::{
|
graph::{
|
||||||
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut,
|
GeometryIndex, GeometryWeight, GetBandIndex, GetContinentIndex, GetContinentIndexMut,
|
||||||
MakePrimitive, Retag,
|
MakePrimitive, Retag,
|
||||||
},
|
},
|
||||||
primitive::{GenericPrimitive, Primitive},
|
primitive::{GenericPrimitive, Primitive},
|
||||||
|
|
@ -79,7 +79,7 @@ impl BendWeightTrait<GeometryWeight> for BendWeight {}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedBendWeight {
|
pub struct FixedBendWeight {
|
||||||
pub component: ComponentIndex,
|
pub continent: ContinentIndex,
|
||||||
pub width: f64,
|
pub width: f64,
|
||||||
pub offset: f64,
|
pub offset: f64,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,22 +13,22 @@ pub type ConnectivityGraph = StableDiGraph<ConnectivityWeight, ConnectivityLabel
|
||||||
#[enum_dispatch(GetNet)]
|
#[enum_dispatch(GetNet)]
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum ConnectivityWeight {
|
pub enum ConnectivityWeight {
|
||||||
Component(ComponentWeight),
|
Continent(ContinentWeight),
|
||||||
Band(BandWeight),
|
Band(BandWeight),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct ComponentWeight {
|
pub struct ContinentWeight {
|
||||||
pub net: i64,
|
pub net: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetNet for ComponentWeight {
|
impl GetNet for ContinentWeight {
|
||||||
fn net(&self) -> i64 {
|
fn net(&self) -> i64 {
|
||||||
self.net
|
self.net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type ComponentIndex = GenericIndex<ComponentWeight>;
|
pub type ContinentIndex = GenericIndex<ContinentWeight>;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub struct BandWeight {
|
pub struct BandWeight {
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,10 @@ use petgraph::stable_graph::NodeIndex;
|
||||||
use crate::{
|
use crate::{
|
||||||
graph::{GenericIndex, GetNodeIndex},
|
graph::{GenericIndex, GetNodeIndex},
|
||||||
layout::{
|
layout::{
|
||||||
connectivity::{BandIndex, ComponentIndex},
|
connectivity::{BandIndex, ContinentIndex},
|
||||||
geometry::{DotWeightTrait, GetPos, GetWidth},
|
geometry::{DotWeightTrait, GetPos, GetWidth},
|
||||||
graph::{
|
graph::{
|
||||||
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut,
|
GeometryIndex, GeometryWeight, GetBandIndex, GetContinentIndex, GetContinentIndexMut,
|
||||||
MakePrimitive, Retag,
|
MakePrimitive, Retag,
|
||||||
},
|
},
|
||||||
primitive::{GenericPrimitive, Primitive},
|
primitive::{GenericPrimitive, Primitive},
|
||||||
|
|
@ -81,7 +81,7 @@ impl DotWeightTrait<GeometryWeight> for DotWeight {}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedDotWeight {
|
pub struct FixedDotWeight {
|
||||||
pub component: ComponentIndex,
|
pub continent: ContinentIndex,
|
||||||
pub circle: Circle,
|
pub circle: Circle,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use petgraph::stable_graph::NodeIndex;
|
||||||
use crate::{
|
use crate::{
|
||||||
graph::GetNodeIndex,
|
graph::GetNodeIndex,
|
||||||
layout::{
|
layout::{
|
||||||
connectivity::{BandIndex, ComponentIndex},
|
connectivity::{BandIndex, ContinentIndex},
|
||||||
Layout,
|
Layout,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
@ -27,12 +27,12 @@ pub trait Retag<GeometryIndex> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[enum_dispatch]
|
#[enum_dispatch]
|
||||||
pub trait GetComponentIndex {
|
pub trait GetContinentIndex {
|
||||||
fn component(&self) -> ComponentIndex;
|
fn continent(&self) -> ContinentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait GetComponentIndexMut {
|
pub trait GetContinentIndexMut {
|
||||||
fn component_mut(&mut self) -> &mut ComponentIndex;
|
fn continent_mut(&mut self) -> &mut ContinentIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait GetBandIndex {
|
pub trait GetBandIndex {
|
||||||
|
|
@ -66,15 +66,15 @@ macro_rules! impl_fixed_weight {
|
||||||
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
|
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
|
||||||
impl_weight!($weight_struct, $weight_variant, $index_struct);
|
impl_weight!($weight_struct, $weight_variant, $index_struct);
|
||||||
|
|
||||||
impl GetComponentIndex for $weight_struct {
|
impl GetContinentIndex for $weight_struct {
|
||||||
fn component(&self) -> ComponentIndex {
|
fn continent(&self) -> ContinentIndex {
|
||||||
self.component
|
self.continent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl GetComponentIndexMut for $weight_struct {
|
impl GetContinentIndexMut for $weight_struct {
|
||||||
fn component_mut(&mut self) -> &mut ComponentIndex {
|
fn continent_mut(&mut self) -> &mut ContinentIndex {
|
||||||
&mut self.component
|
&mut self.continent
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,8 @@ use thiserror::Error;
|
||||||
|
|
||||||
use super::band::Band;
|
use super::band::Band;
|
||||||
use super::connectivity::{
|
use super::connectivity::{
|
||||||
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel,
|
BandIndex, BandWeight, ConnectivityGraph, ConnectivityLabel, ConnectivityWeight,
|
||||||
ConnectivityWeight, GetNet,
|
ContinentIndex, ContinentWeight, GetNet,
|
||||||
};
|
};
|
||||||
use super::geometry::with_rtree::GeometryWithRtree;
|
use super::geometry::with_rtree::GeometryWithRtree;
|
||||||
use super::loose::{GetNextLoose, Loose, LooseIndex};
|
use super::loose::{GetNextLoose, Loose, LooseIndex};
|
||||||
|
|
@ -30,7 +30,7 @@ use crate::layout::{
|
||||||
bend::{FixedBendIndex, LooseBendIndex, LooseBendWeight},
|
bend::{FixedBendIndex, LooseBendIndex, LooseBendWeight},
|
||||||
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||||
geometry::shape::{Shape, ShapeTrait},
|
geometry::shape::{Shape, ShapeTrait},
|
||||||
graph::{GeometryIndex, GeometryWeight, GetComponentIndex, MakePrimitive},
|
graph::{GeometryIndex, GeometryWeight, GetContinentIndex, MakePrimitive},
|
||||||
primitive::{GenericPrimitive, GetCore, GetInnerOuter, GetJoints, GetOtherJoint, MakeShape},
|
primitive::{GenericPrimitive, GetCore, GetInnerOuter, GetJoints, GetOtherJoint, MakeShape},
|
||||||
seg::{
|
seg::{
|
||||||
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
|
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex,
|
||||||
|
|
@ -179,10 +179,10 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
// TODO: This method shouldn't be public.
|
// 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().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()))]
|
#[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 {
|
pub fn add_continent(&mut self, net: i64) -> ContinentIndex {
|
||||||
ComponentIndex::new(
|
ContinentIndex::new(
|
||||||
self.connectivity
|
self.connectivity
|
||||||
.add_node(ConnectivityWeight::Component(ComponentWeight { net })),
|
.add_node(ConnectivityWeight::Continent(ContinentWeight { net })),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -491,13 +491,13 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
let seg = self.add_seg_infringably(from.into(), to.into(), weight, &[])?;
|
let seg = self.add_seg_infringably(from.into(), to.into(), weight, &[])?;
|
||||||
|
|
||||||
self.connectivity.update_edge(
|
self.connectivity.update_edge(
|
||||||
self.primitive(from).component().node_index(),
|
self.primitive(from).continent().node_index(),
|
||||||
weight.band.node_index(),
|
weight.band.node_index(),
|
||||||
ConnectivityLabel::Band,
|
ConnectivityLabel::Band,
|
||||||
);
|
);
|
||||||
self.connectivity.update_edge(
|
self.connectivity.update_edge(
|
||||||
weight.band.node_index(),
|
weight.band.node_index(),
|
||||||
self.primitive(to).component().node_index(),
|
self.primitive(to).continent().node_index(),
|
||||||
ConnectivityLabel::Band,
|
ConnectivityLabel::Band,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -518,7 +518,7 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
|
|
||||||
if let DotIndex::Fixed(dot) = from {
|
if let DotIndex::Fixed(dot) = from {
|
||||||
self.connectivity.update_edge(
|
self.connectivity.update_edge(
|
||||||
self.primitive(dot).component().node_index(),
|
self.primitive(dot).continent().node_index(),
|
||||||
weight.band.node_index(),
|
weight.band.node_index(),
|
||||||
ConnectivityLabel::Band,
|
ConnectivityLabel::Band,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -9,13 +9,13 @@ use crate::layout::seg::{
|
||||||
};
|
};
|
||||||
use crate::layout::{
|
use crate::layout::{
|
||||||
bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
|
bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
|
||||||
connectivity::{BandIndex, ComponentIndex, GetNet},
|
connectivity::{BandIndex, ContinentIndex, GetNet},
|
||||||
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
|
||||||
geometry::{
|
geometry::{
|
||||||
shape::{Shape, ShapeTrait},
|
shape::{Shape, ShapeTrait},
|
||||||
GetOffset, GetWidth,
|
GetOffset, GetWidth,
|
||||||
},
|
},
|
||||||
graph::{GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, Retag},
|
graph::{GeometryIndex, GeometryWeight, GetBandIndex, GetContinentIndex, Retag},
|
||||||
loose::LooseIndex,
|
loose::LooseIndex,
|
||||||
Layout,
|
Layout,
|
||||||
};
|
};
|
||||||
|
|
@ -132,9 +132,9 @@ macro_rules! impl_fixed_primitive {
|
||||||
($primitive_struct:ident, $weight_struct:ident) => {
|
($primitive_struct:ident, $weight_struct:ident) => {
|
||||||
impl_primitive!($primitive_struct, $weight_struct);
|
impl_primitive!($primitive_struct, $weight_struct);
|
||||||
|
|
||||||
impl<'a, R: RulesTrait> GetComponentIndex for $primitive_struct<'a, R> {
|
impl<'a, R: RulesTrait> GetContinentIndex for $primitive_struct<'a, R> {
|
||||||
fn component(&self) -> ComponentIndex {
|
fn continent(&self) -> ContinentIndex {
|
||||||
self.weight().component()
|
self.weight().continent()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ macro_rules! impl_fixed_primitive {
|
||||||
fn net(&self) -> i64 {
|
fn net(&self) -> i64 {
|
||||||
self.layout()
|
self.layout()
|
||||||
.connectivity()
|
.connectivity()
|
||||||
.node_weight(self.component().node_index())
|
.node_weight(self.continent().node_index())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.net()
|
.net()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,10 @@ use enum_dispatch::enum_dispatch;
|
||||||
use crate::{
|
use crate::{
|
||||||
graph::{GenericIndex, GetNodeIndex},
|
graph::{GenericIndex, GetNodeIndex},
|
||||||
layout::{
|
layout::{
|
||||||
connectivity::{BandIndex, ComponentIndex},
|
connectivity::{BandIndex, ContinentIndex},
|
||||||
geometry::{GetWidth, SegWeightTrait},
|
geometry::{GetWidth, SegWeightTrait},
|
||||||
graph::{
|
graph::{
|
||||||
GeometryIndex, GeometryWeight, GetBandIndex, GetComponentIndex, GetComponentIndexMut,
|
GeometryIndex, GeometryWeight, GetBandIndex, GetContinentIndex, GetContinentIndexMut,
|
||||||
MakePrimitive, Retag,
|
MakePrimitive, Retag,
|
||||||
},
|
},
|
||||||
primitive::{GenericPrimitive, Primitive},
|
primitive::{GenericPrimitive, Primitive},
|
||||||
|
|
@ -83,7 +83,7 @@ impl SegWeightTrait<GeometryWeight> for SegWeight {}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct FixedSegWeight {
|
pub struct FixedSegWeight {
|
||||||
pub component: ComponentIndex,
|
pub continent: ContinentIndex,
|
||||||
pub width: f64,
|
pub width: f64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue