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()
|
||||
.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,
|
||||
},
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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<GeometryWeight> for BendWeight {}
|
|||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct FixedBendWeight {
|
||||
pub component: ComponentIndex,
|
||||
pub continent: ContinentIndex,
|
||||
pub width: f64,
|
||||
pub offset: f64,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,22 +13,22 @@ pub type ConnectivityGraph = StableDiGraph<ConnectivityWeight, ConnectivityLabel
|
|||
#[enum_dispatch(GetNet)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum ConnectivityWeight {
|
||||
Component(ComponentWeight),
|
||||
Continent(ContinentWeight),
|
||||
Band(BandWeight),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct ComponentWeight {
|
||||
pub struct ContinentWeight {
|
||||
pub net: i64,
|
||||
}
|
||||
|
||||
impl GetNet for ComponentWeight {
|
||||
impl GetNet for ContinentWeight {
|
||||
fn net(&self) -> i64 {
|
||||
self.net
|
||||
}
|
||||
}
|
||||
|
||||
pub type ComponentIndex = GenericIndex<ComponentWeight>;
|
||||
pub type ContinentIndex = GenericIndex<ContinentWeight>;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct BandWeight {
|
||||
|
|
|
|||
|
|
@ -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<GeometryWeight> for DotWeight {}
|
|||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct FixedDotWeight {
|
||||
pub component: ComponentIndex,
|
||||
pub continent: ContinentIndex,
|
||||
pub circle: Circle,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<GeometryIndex> {
|
|||
}
|
||||
|
||||
#[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
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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<R: RulesTrait> Layout<R> {
|
|||
// 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<R: RulesTrait> Layout<R> {
|
|||
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<R: RulesTrait> Layout<R> {
|
|||
|
||||
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,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<GeometryWeight> for SegWeight {}
|
|||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct FixedSegWeight {
|
||||
pub component: ComponentIndex,
|
||||
pub continent: ContinentIndex,
|
||||
pub width: f64,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue