autorouter: move lazy apex accessor to `Board`

This commit is contained in:
Mikolaj Wielgus 2024-06-03 01:12:02 +02:00
parent a80dfc10be
commit fa8c11fa36
3 changed files with 28 additions and 24 deletions

View File

@ -183,7 +183,7 @@ impl<R: RulesTrait> Autorouter<R> {
.trianvertex_index() .trianvertex_index()
{ {
RatvertexIndex::FixedDot(dot) => dot, RatvertexIndex::FixedDot(dot) => dot,
RatvertexIndex::Zone(zone) => self.board.layout_mut().zone_apex(zone), RatvertexIndex::Zone(zone) => self.board.zone_apex(zone),
}; };
let target_dot = match self let target_dot = match self
@ -194,7 +194,7 @@ impl<R: RulesTrait> Autorouter<R> {
.trianvertex_index() .trianvertex_index()
{ {
RatvertexIndex::FixedDot(dot) => dot, RatvertexIndex::FixedDot(dot) => dot,
RatvertexIndex::Zone(zone) => self.board.layout_mut().zone_apex(zone), RatvertexIndex::Zone(zone) => self.board.zone_apex(zone),
}; };
(source_dot, target_dot) (source_dot, target_dot)

View File

@ -3,14 +3,18 @@ use std::collections::HashMap;
use crate::{ use crate::{
drawing::{ drawing::{
dot::{FixedDotIndex, FixedDotWeight}, dot::{FixedDotIndex, FixedDotWeight},
graph::PrimitiveIndex, graph::{GetLayer, GetMaybeNet, PrimitiveIndex},
rules::RulesTrait, rules::RulesTrait,
seg::{FixedSegIndex, FixedSegWeight}, seg::{FixedSegIndex, FixedSegWeight},
Infringement, Infringement,
}, },
geometry::GenericNode, geometry::{shape::ShapeTrait, GenericNode},
graph::GenericIndex, graph::GenericIndex,
layout::{zone::ZoneWeight, Layout}, layout::{
zone::{GetMaybeApex, MakePolyShape, ZoneWeight},
Layout,
},
math::Circle,
}; };
pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<ZoneWeight>>; pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<ZoneWeight>>;
@ -114,6 +118,25 @@ impl<R: RulesTrait> Board<R> {
self.net_to_netname.insert(net, netname); self.net_to_netname.insert(net, netname);
} }
pub fn zone_apex(&mut self, zone: GenericIndex<ZoneWeight>) -> FixedDotIndex {
if let Some(apex) = self.layout.zone(zone).maybe_apex() {
apex
} else {
self.add_zone_fixed_dot(
FixedDotWeight {
circle: Circle {
pos: self.layout.zone(zone).shape().center(),
r: 100.0,
},
layer: self.layout.zone(zone).layer(),
maybe_net: self.layout.zone(zone).maybe_net(),
},
zone,
)
.unwrap()
}
}
pub fn node_pin(&self, node: NodeIndex) -> Option<&String> { pub fn node_pin(&self, node: NodeIndex) -> Option<&String> {
self.node_to_pin.get(&node) self.node_to_pin.get(&node)
} }

View File

@ -180,25 +180,6 @@ impl<R: RulesTrait> Layout<R> {
.compound_members(GenericIndex::new(zone.node_index())) .compound_members(GenericIndex::new(zone.node_index()))
} }
pub fn zone_apex(&mut self, zone: GenericIndex<ZoneWeight>) -> FixedDotIndex {
if let Some(apex) = self.zone(zone).maybe_apex() {
apex
} else {
self.add_zone_fixed_dot(
FixedDotWeight {
circle: Circle {
pos: self.zone(zone).shape().center(),
r: 100.0,
},
layer: self.zone(zone).layer(),
maybe_net: self.zone(zone).maybe_net(),
},
zone,
)
.unwrap()
}
}
pub fn drawing(&self) -> &Drawing<ZoneWeight, R> { pub fn drawing(&self) -> &Drawing<ZoneWeight, R> {
&self.drawing &self.drawing
} }