layout: implement `MakePrimitiveShape` for vias

This commit is contained in:
Mikolaj Wielgus 2024-06-09 21:29:03 +02:00
parent c5148b0cb1
commit 5d082d81c0
3 changed files with 44 additions and 38 deletions

View File

@ -17,6 +17,7 @@ use topola::{
}, },
graph::{GenericIndex, GetNodeIndex}, graph::{GenericIndex, GetNodeIndex},
layout::{ layout::{
via::ViaWeight,
zone::{MakePolyShape, Zone, ZoneWeight}, zone::{MakePolyShape, Zone, ZoneWeight},
CompoundWeight, Layout, NodeIndex, CompoundWeight, Layout, NodeIndex,
}, },
@ -78,13 +79,22 @@ impl Overlay {
} }
NodeIndex::Compound(compound) => { NodeIndex::Compound(compound) => {
match board.layout().drawing().compound_weight(compound) { match board.layout().drawing().compound_weight(compound) {
CompoundWeight::Zone(zone) => Zone::new( /*CompoundWeight::Zone(zone) => Zone::new(
GenericIndex::<ZoneWeight>::new(compound.node_index()), GenericIndex::<ZoneWeight>::new(compound.node_index()),
board.layout(), board.layout(),
) )
.shape() .shape()
.into(),*/
CompoundWeight::Zone(weight) => board
.layout()
.zone(GenericIndex::<ZoneWeight>::new(compound.node_index()))
.shape()
.into(),
CompoundWeight::Via(weight) => board
.layout()
.via(GenericIndex::<ViaWeight>::new(compound.node_index()))
.shape()
.into(), .into(),
CompoundWeight::Via(via) => unreachable!(),
} }
} }
}; };

View File

@ -28,7 +28,7 @@ use crate::{
}, },
graph::{GenericIndex, GetNodeIndex}, graph::{GenericIndex, GetNodeIndex},
layout::{ layout::{
via::ViaWeight, via::{Via, ViaWeight},
zone::{GetMaybeApex, MakePolyShape, Zone, ZoneWeight}, zone::{GetMaybeApex, MakePolyShape, Zone, ZoneWeight},
}, },
math::Circle, math::Circle,
@ -256,33 +256,8 @@ impl<R: RulesTrait> Layout<R> {
pub fn zone(&self, index: GenericIndex<ZoneWeight>) -> Zone<R> { pub fn zone(&self, index: GenericIndex<ZoneWeight>) -> Zone<R> {
Zone::new(index, self) Zone::new(index, self)
} }
pub fn via(&self, index: GenericIndex<ViaWeight>) -> Via<R> {
Via::new(index, self)
}
} }
/*impl<R: RulesTrait> CompoundManagerTrait<ZoneWeight, GenericIndex<ZoneWeight>> for Layout<R> {
fn add_compound(&mut self, weight: ZoneWeight) -> GenericIndex<ZoneWeight> {
self.drawing.add_compound(weight)
}
fn remove_compound(&mut self, compound: GenericIndex<ZoneWeight>) {
self.drawing.remove_compound(compound);
}
fn add_to_compound<W>(
&mut self,
primitive: GenericIndex<W>,
compound: GenericIndex<ZoneWeight>,
) {
self.drawing.add_to_compound(primitive, compound);
}
fn compound_weight(&self, compound: GenericIndex<ZoneWeight>) -> ZoneWeight {
self.drawing.compound_weight(compound)
}
fn compounds<W>(
&self,
node: GenericIndex<W>,
) -> impl Iterator<Item = GenericIndex<ZoneWeight>> {
self.drawing.compounds(node)
}
}*/

View File

@ -1,6 +1,9 @@
use crate::{ use crate::{
drawing::{graph::GetMaybeNet, rules::RulesTrait}, drawing::{graph::GetMaybeNet, primitive::MakePrimitiveShape, rules::RulesTrait},
geometry::compound::CompoundManagerTrait, geometry::{
compound::CompoundManagerTrait,
primitive::{DotShape, PrimitiveShape},
},
graph::{GenericIndex, GetNodeIndex}, graph::{GenericIndex, GetNodeIndex},
layout::{CompoundWeight, Layout}, layout::{CompoundWeight, Layout},
math::Circle, math::Circle,
@ -27,6 +30,18 @@ impl<'a, R: RulesTrait> GetMaybeNet for Via<'a, R> {
} }
} }
impl<'a, R: RulesTrait> MakePrimitiveShape for Via<'a, R> {
fn shape(&self) -> PrimitiveShape {
if let CompoundWeight::Via(weight) =
self.layout.drawing().compound_weight(self.index.into())
{
weight.shape()
} else {
unreachable!();
}
}
}
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct ViaWeight { pub struct ViaWeight {
pub from_layer: u64, pub from_layer: u64,
@ -35,14 +50,20 @@ pub struct ViaWeight {
pub maybe_net: Option<usize>, pub maybe_net: Option<usize>,
} }
impl From<GenericIndex<ViaWeight>> for GenericIndex<CompoundWeight> {
fn from(via: GenericIndex<ViaWeight>) -> Self {
GenericIndex::<CompoundWeight>::new(via.node_index())
}
}
impl GetMaybeNet for ViaWeight { impl GetMaybeNet for ViaWeight {
fn maybe_net(&self) -> Option<usize> { fn maybe_net(&self) -> Option<usize> {
self.maybe_net self.maybe_net
} }
} }
impl From<GenericIndex<ViaWeight>> for GenericIndex<CompoundWeight> { impl MakePrimitiveShape for ViaWeight {
fn from(via: GenericIndex<ViaWeight>) -> Self { fn shape(&self) -> PrimitiveShape {
GenericIndex::<CompoundWeight>::new(via.node_index()) DotShape { c: self.circle }.into()
} }
} }