layout: rename "zone" to "poly"

We'll keep the term "zone" for higher-level concepts.
This commit is contained in:
Mikolaj Wielgus 2024-07-09 23:09:39 +02:00
parent 71a2a3ebbf
commit be9ff3a85a
12 changed files with 134 additions and 134 deletions

View File

@ -103,7 +103,7 @@ impl<M: AccessMesadata> Autorouter<M> {
.node_index() .node_index()
{ {
RatvertexIndex::FixedDot(dot) => dot, RatvertexIndex::FixedDot(dot) => dot,
RatvertexIndex::Zone(zone) => self.board.zone_apex(zone), RatvertexIndex::Poly(poly) => self.board.poly_apex(poly),
}; };
let target_dot = match self let target_dot = match self
@ -114,7 +114,7 @@ impl<M: AccessMesadata> Autorouter<M> {
.node_index() .node_index()
{ {
RatvertexIndex::FixedDot(dot) => dot, RatvertexIndex::FixedDot(dot) => dot,
RatvertexIndex::Zone(zone) => self.board.zone_apex(zone), RatvertexIndex::Poly(poly) => self.board.poly_apex(poly),
}; };
(source_dot, target_dot) (source_dot, target_dot)

View File

@ -21,7 +21,7 @@ use crate::{
geometry::{compound::ManageCompounds, shape::AccessShape}, geometry::{compound::ManageCompounds, shape::AccessShape},
graph::{GenericIndex, GetPetgraphIndex}, graph::{GenericIndex, GetPetgraphIndex},
layout::{ layout::{
zone::{MakePolyShape, ZoneWeight}, poly::{MakePolyShape, PolyWeight},
Layout, Layout,
}, },
triangulation::{GetTrianvertexNodeIndex, Triangulation}, triangulation::{GetTrianvertexNodeIndex, Triangulation},
@ -31,14 +31,14 @@ use crate::{
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub enum RatvertexIndex { pub enum RatvertexIndex {
FixedDot(FixedDotIndex), FixedDot(FixedDotIndex),
Zone(GenericIndex<ZoneWeight>), Poly(GenericIndex<PolyWeight>),
} }
impl From<RatvertexIndex> for crate::layout::NodeIndex { impl From<RatvertexIndex> for crate::layout::NodeIndex {
fn from(vertex: RatvertexIndex) -> crate::layout::NodeIndex { fn from(vertex: RatvertexIndex) -> crate::layout::NodeIndex {
match vertex { match vertex {
RatvertexIndex::FixedDot(dot) => crate::layout::NodeIndex::Primitive(dot.into()), RatvertexIndex::FixedDot(dot) => crate::layout::NodeIndex::Primitive(dot.into()),
RatvertexIndex::Zone(zone) => crate::layout::NodeIndex::Compound(zone.into()), RatvertexIndex::Poly(poly) => crate::layout::NodeIndex::Compound(poly.into()),
} }
} }
} }
@ -89,7 +89,7 @@ impl Ratsnest {
for node in layout.drawing().layer_primitive_nodes(layer) { for node in layout.drawing().layer_primitive_nodes(layer) {
match node { match node {
PrimitiveIndex::FixedDot(dot) => { PrimitiveIndex::FixedDot(dot) => {
if layout.zones(dot).next().is_none() { if layout.polys(dot).next().is_none() {
if let Some(net) = layout.drawing().primitive(dot).maybe_net() { if let Some(net) = layout.drawing().primitive(dot).maybe_net() {
if !triangulations.contains_key(&(layer, net)) { if !triangulations.contains_key(&(layer, net)) {
triangulations.insert( triangulations.insert(
@ -113,8 +113,8 @@ impl Ratsnest {
} }
} }
for zone in layout.layer_zone_nodes(layer) { for poly in layout.layer_poly_nodes(layer) {
if let Some(net) = layout.drawing().compound_weight(zone.into()).maybe_net() { if let Some(net) = layout.drawing().compound_weight(poly.into()).maybe_net() {
if !triangulations.contains_key(&(layer, net)) { if !triangulations.contains_key(&(layer, net)) {
triangulations.insert( triangulations.insert(
(layer, net), (layer, net),
@ -126,8 +126,8 @@ impl Ratsnest {
.get_mut(&(layer, net)) .get_mut(&(layer, net))
.unwrap() .unwrap()
.add_vertex(RatvertexWeight { .add_vertex(RatvertexWeight {
vertex: RatvertexIndex::Zone(zone), vertex: RatvertexIndex::Poly(poly),
pos: layout.zone(zone).shape().center(), pos: layout.poly(poly).shape().center(),
})? })?
} }
} }

View File

@ -7,7 +7,7 @@ use crate::{
drawing::graph::{GetLayer, MakePrimitive}, drawing::graph::{GetLayer, MakePrimitive},
geometry::compound::ManageCompounds, geometry::compound::ManageCompounds,
graph::{GenericIndex, GetPetgraphIndex}, graph::{GenericIndex, GetPetgraphIndex},
layout::{zone::ZoneWeight, CompoundWeight, NodeIndex}, layout::{poly::PolyWeight, CompoundWeight, NodeIndex},
}; };
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]
@ -66,11 +66,11 @@ impl Selection {
primitive.primitive(board.layout().drawing()).layer() primitive.primitive(board.layout().drawing()).layer()
} }
NodeIndex::Compound(compound) => { NodeIndex::Compound(compound) => {
if let CompoundWeight::Zone(..) = board.layout().drawing().compound_weight(compound) if let CompoundWeight::Poly(..) = board.layout().drawing().compound_weight(compound)
{ {
board board
.layout() .layout()
.zone(GenericIndex::<ZoneWeight>::new(compound.petgraph_index())) .poly(GenericIndex::<PolyWeight>::new(compound.petgraph_index()))
.layer() .layer()
} else { } else {
unreachable!() unreachable!()

View File

@ -29,7 +29,7 @@ use topola::{
shape::AccessShape, shape::AccessShape,
GenericNode, GenericNode,
}, },
layout::{via::ViaWeight, zone::MakePolyShape, Layout}, layout::{poly::MakePolyShape, via::ViaWeight, Layout},
math::Circle, math::Circle,
router::{ router::{
draw::DrawException, draw::DrawException,

View File

@ -17,8 +17,8 @@ use topola::{
}, },
graph::{GenericIndex, GetPetgraphIndex}, graph::{GenericIndex, GetPetgraphIndex},
layout::{ layout::{
poly::{MakePolyShape, Poly, PolyWeight},
via::ViaWeight, via::ViaWeight,
zone::{MakePolyShape, Zone, ZoneWeight},
CompoundWeight, Layout, NodeIndex, CompoundWeight, Layout, NodeIndex,
}, },
}; };
@ -76,9 +76,9 @@ impl Overlay {
} }
NodeIndex::Compound(compound) => { NodeIndex::Compound(compound) => {
match board.layout().drawing().compound_weight(compound) { match board.layout().drawing().compound_weight(compound) {
CompoundWeight::Zone(weight) => board CompoundWeight::Poly(weight) => board
.layout() .layout()
.zone(GenericIndex::<ZoneWeight>::new(compound.petgraph_index())) .poly(GenericIndex::<PolyWeight>::new(compound.petgraph_index()))
.shape() .shape()
.into(), .into(),
CompoundWeight::Via(weight) => board CompoundWeight::Via(weight) => board

View File

@ -14,7 +14,7 @@ use topola::{
primitive::MakePrimitiveShape, primitive::MakePrimitiveShape,
}, },
geometry::{shape::AccessShape, GenericNode}, geometry::{shape::AccessShape, GenericNode},
layout::{via::ViaWeight, zone::MakePolyShape}, layout::{poly::MakePolyShape, via::ViaWeight},
math::Circle, math::Circle,
specctra::mesadata::SpecctraMesadata, specctra::mesadata::SpecctraMesadata,
}; };
@ -126,17 +126,17 @@ impl Viewport {
painter.paint_primitive(&shape, color); painter.paint_primitive(&shape, color);
} }
for zone in board.layout().layer_zone_nodes(i) { for poly in board.layout().layer_poly_nodes(i) {
let color = if overlay let color = if overlay
.selection() .selection()
.contains_node(board, GenericNode::Compound(zone.into())) .contains_node(board, GenericNode::Compound(poly.into()))
{ {
layers.highlight_colors[i] layers.highlight_colors[i]
} else { } else {
layers.colors[i] layers.colors[i]
}; };
painter.paint_polygon(&board.layout().zone(zone).shape().polygon, color) painter.paint_polygon(&board.layout().poly(poly).shape().polygon, color)
} }
} }
} }

View File

@ -23,7 +23,7 @@ use topola::drawing::seg::FixedSegWeight;
use topola::drawing::{Infringement, LayoutException}; use topola::drawing::{Infringement, LayoutException};
use topola::geometry::primitive::{AccessPrimitiveShape, PrimitiveShape}; use topola::geometry::primitive::{AccessPrimitiveShape, PrimitiveShape};
use topola::geometry::shape::AccessShape; use topola::geometry::shape::AccessShape;
use topola::layout::zone::MakePolyShape; use topola::layout::poly::MakePolyShape;
use topola::layout::Layout; use topola::layout::Layout;
use topola::router::draw::DrawException; use topola::router::draw::DrawException;
use topola::router::navmesh::Navmesh; use topola::router::navmesh::Navmesh;
@ -303,9 +303,9 @@ fn render_times(
painter.paint_primitive(&shape, color, view.zoom); painter.paint_primitive(&shape, color, view.zoom);
} }
for zone in layout.layer_zone_nodes(1) { for poly in layout.layer_poly_nodes(1) {
painter.paint_polygon( painter.paint_polygon(
&layout.zone(zone).shape().polygon, &layout.poly(poly).shape().polygon,
ColorU::new(52, 52, 200, 255), ColorU::new(52, 52, 200, 255),
view.zoom, view.zoom,
); );
@ -322,9 +322,9 @@ fn render_times(
painter.paint_primitive(&shape, color, view.zoom); painter.paint_primitive(&shape, color, view.zoom);
} }
for zone in layout.layer_zone_nodes(0) { for poly in layout.layer_poly_nodes(0) {
painter.paint_polygon( painter.paint_polygon(
&layout.zone(zone).shape().polygon, &layout.poly(poly).shape().polygon,
ColorU::new(200, 52, 52, 255), ColorU::new(200, 52, 52, 255),
view.zoom, view.zoom,
); );

View File

@ -11,7 +11,7 @@ use crate::{
geometry::{shape::AccessShape, GenericNode}, geometry::{shape::AccessShape, GenericNode},
graph::GenericIndex, graph::GenericIndex,
layout::{ layout::{
zone::{GetMaybeApex, MakePolyShape, ZoneWeight}, poly::{GetMaybeApex, MakePolyShape, PolyWeight},
Layout, NodeIndex, Layout, NodeIndex,
}, },
math::Circle, math::Circle,
@ -49,14 +49,14 @@ impl<M: AccessMesadata> Board<M> {
dot dot
} }
pub fn add_zone_fixed_dot_infringably( pub fn add_poly_fixed_dot_infringably(
&mut self, &mut self,
weight: FixedDotWeight, weight: FixedDotWeight,
zone: GenericIndex<ZoneWeight>, poly: GenericIndex<PolyWeight>,
) -> FixedDotIndex { ) -> FixedDotIndex {
let dot = self.layout.add_zone_fixed_dot_infringably(weight, zone); let dot = self.layout.add_poly_fixed_dot_infringably(weight, poly);
if let Some(pin) = self.node_pinname(GenericNode::Compound(zone.into())) { if let Some(pin) = self.node_pinname(GenericNode::Compound(poly.into())) {
self.node_to_pinname self.node_to_pinname
.insert(GenericNode::Primitive(dot.into()), pin.to_string()); .insert(GenericNode::Primitive(dot.into()), pin.to_string());
} }
@ -81,18 +81,18 @@ impl<M: AccessMesadata> Board<M> {
seg seg
} }
pub fn add_zone_fixed_seg_infringably( pub fn add_poly_fixed_seg_infringably(
&mut self, &mut self,
from: FixedDotIndex, from: FixedDotIndex,
to: FixedDotIndex, to: FixedDotIndex,
weight: FixedSegWeight, weight: FixedSegWeight,
zone: GenericIndex<ZoneWeight>, poly: GenericIndex<PolyWeight>,
) -> FixedSegIndex { ) -> FixedSegIndex {
let seg = self let seg = self
.layout .layout
.add_zone_fixed_seg_infringably(from, to, weight, zone); .add_poly_fixed_seg_infringably(from, to, weight, poly);
if let Some(pin) = self.node_pinname(GenericNode::Compound(zone.into())) { if let Some(pin) = self.node_pinname(GenericNode::Compound(poly.into())) {
self.node_to_pinname self.node_to_pinname
.insert(GenericNode::Primitive(seg.into()), pin.to_string()); .insert(GenericNode::Primitive(seg.into()), pin.to_string());
} }
@ -100,35 +100,35 @@ impl<M: AccessMesadata> Board<M> {
seg seg
} }
pub fn add_zone( pub fn add_poly(
&mut self, &mut self,
weight: ZoneWeight, weight: PolyWeight,
maybe_pin: Option<String>, maybe_pin: Option<String>,
) -> GenericIndex<ZoneWeight> { ) -> GenericIndex<PolyWeight> {
let zone = self.layout.add_zone(weight); let poly = self.layout.add_poly(weight);
if let Some(pin) = maybe_pin { if let Some(pin) = maybe_pin {
self.node_to_pinname self.node_to_pinname
.insert(GenericNode::Compound(zone.into()), pin.to_string()); .insert(GenericNode::Compound(poly.into()), pin.to_string());
} }
zone poly
} }
pub fn zone_apex(&mut self, zone: GenericIndex<ZoneWeight>) -> FixedDotIndex { pub fn poly_apex(&mut self, poly: GenericIndex<PolyWeight>) -> FixedDotIndex {
if let Some(apex) = self.layout.zone(zone).maybe_apex() { if let Some(apex) = self.layout.poly(poly).maybe_apex() {
apex apex
} else { } else {
self.add_zone_fixed_dot_infringably( self.add_poly_fixed_dot_infringably(
FixedDotWeight { FixedDotWeight {
circle: Circle { circle: Circle {
pos: self.layout.zone(zone).shape().center(), pos: self.layout.poly(poly).shape().center(),
r: 100.0, r: 100.0,
}, },
layer: self.layout.zone(zone).layer(), layer: self.layout.poly(poly).layer(),
maybe_net: self.layout.zone(zone).maybe_net(), maybe_net: self.layout.poly(poly).maybe_net(),
}, },
zone, poly,
) )
} }
} }

View File

@ -25,15 +25,15 @@ use crate::{
}, },
graph::{GenericIndex, GetPetgraphIndex}, graph::{GenericIndex, GetPetgraphIndex},
layout::{ layout::{
poly::{Poly, PolyWeight},
via::{Via, ViaWeight}, via::{Via, ViaWeight},
zone::{Zone, ZoneWeight},
}, },
}; };
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
#[enum_dispatch(GetMaybeNet)] #[enum_dispatch(GetMaybeNet)]
pub enum CompoundWeight { pub enum CompoundWeight {
Zone(ZoneWeight), Poly(PolyWeight),
Via(ViaWeight), Via(ViaWeight),
} }
@ -107,27 +107,27 @@ impl<R: AccessRules> Layout<R> {
self.drawing.add_fixed_dot_infringably(weight) self.drawing.add_fixed_dot_infringably(weight)
} }
pub fn add_zone_fixed_dot( pub fn add_poly_fixed_dot(
&mut self, &mut self,
weight: FixedDotWeight, weight: FixedDotWeight,
zone: GenericIndex<ZoneWeight>, poly: GenericIndex<PolyWeight>,
) -> Result<FixedDotIndex, Infringement> { ) -> Result<FixedDotIndex, Infringement> {
let maybe_dot = self.drawing.add_fixed_dot(weight); let maybe_dot = self.drawing.add_fixed_dot(weight);
if let Ok(dot) = maybe_dot { if let Ok(dot) = maybe_dot {
self.drawing.add_to_compound(dot, zone.into()); self.drawing.add_to_compound(dot, poly.into());
} }
maybe_dot maybe_dot
} }
pub fn add_zone_fixed_dot_infringably( pub fn add_poly_fixed_dot_infringably(
&mut self, &mut self,
weight: FixedDotWeight, weight: FixedDotWeight,
zone: GenericIndex<ZoneWeight>, poly: GenericIndex<PolyWeight>,
) -> FixedDotIndex { ) -> FixedDotIndex {
let dot = self.drawing.add_fixed_dot_infringably(weight); let dot = self.drawing.add_fixed_dot_infringably(weight);
self.drawing.add_to_compound(dot, zone.into()); self.drawing.add_to_compound(dot, poly.into());
dot dot
} }
@ -149,31 +149,31 @@ impl<R: AccessRules> Layout<R> {
self.drawing.add_fixed_seg_infringably(from, to, weight) self.drawing.add_fixed_seg_infringably(from, to, weight)
} }
pub fn add_zone_fixed_seg( pub fn add_poly_fixed_seg(
&mut self, &mut self,
from: FixedDotIndex, from: FixedDotIndex,
to: FixedDotIndex, to: FixedDotIndex,
weight: FixedSegWeight, weight: FixedSegWeight,
zone: GenericIndex<ZoneWeight>, poly: GenericIndex<PolyWeight>,
) -> Result<FixedSegIndex, Infringement> { ) -> Result<FixedSegIndex, Infringement> {
let maybe_seg = self.add_fixed_seg(from, to, weight); let maybe_seg = self.add_fixed_seg(from, to, weight);
if let Ok(seg) = maybe_seg { if let Ok(seg) = maybe_seg {
self.drawing.add_to_compound(seg, zone.into()); self.drawing.add_to_compound(seg, poly.into());
} }
maybe_seg maybe_seg
} }
pub fn add_zone_fixed_seg_infringably( pub fn add_poly_fixed_seg_infringably(
&mut self, &mut self,
from: FixedDotIndex, from: FixedDotIndex,
to: FixedDotIndex, to: FixedDotIndex,
weight: FixedSegWeight, weight: FixedSegWeight,
zone: GenericIndex<ZoneWeight>, poly: GenericIndex<PolyWeight>,
) -> FixedSegIndex { ) -> FixedSegIndex {
let seg = self.add_fixed_seg_infringably(from, to, weight); let seg = self.add_fixed_seg_infringably(from, to, weight);
self.drawing.add_to_compound(seg, zone.into()); self.drawing.add_to_compound(seg, poly.into());
seg seg
} }
@ -199,10 +199,10 @@ impl<R: AccessRules> Layout<R> {
self.drawing.move_dot(dot, to) self.drawing.move_dot(dot, to)
} }
pub fn add_zone(&mut self, weight: ZoneWeight) -> GenericIndex<ZoneWeight> { pub fn add_poly(&mut self, weight: PolyWeight) -> GenericIndex<PolyWeight> {
GenericIndex::<ZoneWeight>::new( GenericIndex::<PolyWeight>::new(
self.drawing self.drawing
.add_compound(CompoundWeight::Zone(weight)) .add_compound(CompoundWeight::Poly(weight))
.petgraph_index(), .petgraph_index(),
) )
} }
@ -243,18 +243,18 @@ impl<R: AccessRules> Layout<R> {
} }
} }
pub fn zones<W: 'static>( pub fn polys<W: 'static>(
&self, &self,
node: GenericIndex<W>, node: GenericIndex<W>,
) -> impl Iterator<Item = GenericIndex<CompoundWeight>> + '_ { ) -> impl Iterator<Item = GenericIndex<CompoundWeight>> + '_ {
self.drawing.compounds(node) self.drawing.compounds(node)
} }
pub fn zone_nodes(&self) -> impl Iterator<Item = GenericIndex<ZoneWeight>> + '_ { pub fn poly_nodes(&self) -> impl Iterator<Item = GenericIndex<PolyWeight>> + '_ {
self.drawing.rtree().iter().filter_map(|wrapper| { self.drawing.rtree().iter().filter_map(|wrapper| {
if let NodeIndex::Compound(compound) = wrapper.data { if let NodeIndex::Compound(compound) = wrapper.data {
if let CompoundWeight::Zone(..) = self.drawing.compound_weight(compound) { if let CompoundWeight::Poly(..) = self.drawing.compound_weight(compound) {
return Some(GenericIndex::<ZoneWeight>::new(compound.petgraph_index())); return Some(GenericIndex::<PolyWeight>::new(compound.petgraph_index()));
} }
} }
@ -262,10 +262,10 @@ impl<R: AccessRules> Layout<R> {
}) })
} }
pub fn layer_zone_nodes( pub fn layer_poly_nodes(
&self, &self,
layer: usize, layer: usize,
) -> impl Iterator<Item = GenericIndex<ZoneWeight>> + '_ { ) -> impl Iterator<Item = GenericIndex<PolyWeight>> + '_ {
self.drawing self.drawing
.rtree() .rtree()
.locate_in_envelope_intersecting(&AABB::from_corners( .locate_in_envelope_intersecting(&AABB::from_corners(
@ -274,8 +274,8 @@ impl<R: AccessRules> Layout<R> {
)) ))
.filter_map(|wrapper| { .filter_map(|wrapper| {
if let NodeIndex::Compound(compound) = wrapper.data { if let NodeIndex::Compound(compound) = wrapper.data {
if let CompoundWeight::Zone(..) = self.drawing.compound_weight(compound) { if let CompoundWeight::Poly(..) = self.drawing.compound_weight(compound) {
return Some(GenericIndex::<ZoneWeight>::new(compound.petgraph_index())); return Some(GenericIndex::<PolyWeight>::new(compound.petgraph_index()));
} }
} }
@ -283,13 +283,13 @@ impl<R: AccessRules> Layout<R> {
}) })
} }
pub fn zone_members( pub fn poly_members(
&self, &self,
zone: GenericIndex<ZoneWeight>, poly: GenericIndex<PolyWeight>,
) -> impl Iterator<Item = PrimitiveIndex> + '_ { ) -> impl Iterator<Item = PrimitiveIndex> + '_ {
self.drawing self.drawing
.geometry() .geometry()
.compound_members(GenericIndex::new(zone.petgraph_index())) .compound_members(GenericIndex::new(poly.petgraph_index()))
} }
pub fn drawing(&self) -> &Drawing<CompoundWeight, R> { pub fn drawing(&self) -> &Drawing<CompoundWeight, R> {
@ -304,8 +304,8 @@ impl<R: AccessRules> Layout<R> {
self.drawing.rules_mut() self.drawing.rules_mut()
} }
pub fn zone(&self, index: GenericIndex<ZoneWeight>) -> Zone<R> { pub fn poly(&self, index: GenericIndex<PolyWeight>) -> Poly<R> {
Zone::new(index, self) Poly::new(index, self)
} }
pub fn via(&self, index: GenericIndex<ViaWeight>) -> Via<R> { pub fn via(&self, index: GenericIndex<ViaWeight>) -> Via<R> {

View File

@ -1,5 +1,5 @@
mod layout; mod layout;
pub mod poly;
pub mod via; pub mod via;
pub mod zone;
pub use layout::*; pub use layout::*;

View File

@ -26,13 +26,13 @@ pub trait GetMaybeApex {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct Zone<'a, R: AccessRules> { pub struct Poly<'a, R: AccessRules> {
pub index: GenericIndex<ZoneWeight>, pub index: GenericIndex<PolyWeight>,
layout: &'a Layout<R>, layout: &'a Layout<R>,
} }
impl<'a, R: AccessRules> Zone<'a, R> { impl<'a, R: AccessRules> Poly<'a, R> {
pub fn new(index: GenericIndex<ZoneWeight>, layout: &'a Layout<R>) -> Self { pub fn new(index: GenericIndex<PolyWeight>, layout: &'a Layout<R>) -> Self {
Self { index, layout } Self { index, layout }
} }
@ -48,9 +48,9 @@ impl<'a, R: AccessRules> Zone<'a, R> {
} }
} }
impl<'a, R: AccessRules> GetLayer for Zone<'a, R> { impl<'a, R: AccessRules> GetLayer for Poly<'a, R> {
fn layer(&self) -> usize { fn layer(&self) -> usize {
if let CompoundWeight::Zone(weight) = if let CompoundWeight::Poly(weight) =
self.layout.drawing().compound_weight(self.index.into()) self.layout.drawing().compound_weight(self.index.into())
{ {
weight.layer() weight.layer()
@ -60,7 +60,7 @@ impl<'a, R: AccessRules> GetLayer for Zone<'a, R> {
} }
} }
impl<'a, R: AccessRules> GetMaybeNet for Zone<'a, R> { impl<'a, R: AccessRules> GetMaybeNet for Poly<'a, R> {
fn maybe_net(&self) -> Option<usize> { fn maybe_net(&self) -> Option<usize> {
self.layout self.layout
.drawing() .drawing()
@ -69,7 +69,7 @@ impl<'a, R: AccessRules> GetMaybeNet for Zone<'a, R> {
} }
} }
impl<'a, R: AccessRules> MakePolyShape for Zone<'a, R> { impl<'a, R: AccessRules> MakePolyShape for Poly<'a, R> {
fn shape(&self) -> PolyShape { fn shape(&self) -> PolyShape {
PolyShape { PolyShape {
polygon: Polygon::new( polygon: Polygon::new(
@ -103,7 +103,7 @@ impl<'a, R: AccessRules> MakePolyShape for Zone<'a, R> {
} }
} }
impl<'a, R: AccessRules> GetMaybeApex for Zone<'a, R> { impl<'a, R: AccessRules> GetMaybeApex for Poly<'a, R> {
fn maybe_apex(&self) -> Option<FixedDotIndex> { fn maybe_apex(&self) -> Option<FixedDotIndex> {
self.layout self.layout
.drawing() .drawing()
@ -123,61 +123,61 @@ impl<'a, R: AccessRules> GetMaybeApex for Zone<'a, R> {
#[enum_dispatch(GetLayer, GetMaybeNet)] #[enum_dispatch(GetLayer, GetMaybeNet)]
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub enum ZoneWeight { pub enum PolyWeight {
Solid(SolidZoneWeight), Solid(SolidPolyWeight),
Pour(PourZoneWeight), Pour(PourPolyWeight),
} }
impl From<GenericIndex<ZoneWeight>> for GenericIndex<CompoundWeight> { impl From<GenericIndex<PolyWeight>> for GenericIndex<CompoundWeight> {
fn from(zone: GenericIndex<ZoneWeight>) -> Self { fn from(poly: GenericIndex<PolyWeight>) -> Self {
GenericIndex::<CompoundWeight>::new(zone.petgraph_index()) GenericIndex::<CompoundWeight>::new(poly.petgraph_index())
} }
} }
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct SolidZoneWeight { pub struct SolidPolyWeight {
pub layer: usize, pub layer: usize,
pub maybe_net: Option<usize>, pub maybe_net: Option<usize>,
} }
impl GetLayer for SolidZoneWeight { impl GetLayer for SolidPolyWeight {
fn layer(&self) -> usize { fn layer(&self) -> usize {
self.layer self.layer
} }
} }
impl GetMaybeNet for SolidZoneWeight { impl GetMaybeNet for SolidPolyWeight {
fn maybe_net(&self) -> Option<usize> { fn maybe_net(&self) -> Option<usize> {
self.maybe_net self.maybe_net
} }
} }
impl From<GenericIndex<SolidZoneWeight>> for GenericIndex<CompoundWeight> { impl From<GenericIndex<SolidPolyWeight>> for GenericIndex<CompoundWeight> {
fn from(zone: GenericIndex<SolidZoneWeight>) -> Self { fn from(poly: GenericIndex<SolidPolyWeight>) -> Self {
GenericIndex::<CompoundWeight>::new(zone.petgraph_index()) GenericIndex::<CompoundWeight>::new(poly.petgraph_index())
} }
} }
#[derive(Debug, Clone, Copy, PartialEq)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct PourZoneWeight { pub struct PourPolyWeight {
pub layer: usize, pub layer: usize,
pub maybe_net: Option<usize>, pub maybe_net: Option<usize>,
} }
impl<'a> GetLayer for PourZoneWeight { impl<'a> GetLayer for PourPolyWeight {
fn layer(&self) -> usize { fn layer(&self) -> usize {
self.layer self.layer
} }
} }
impl<'a> GetMaybeNet for PourZoneWeight { impl<'a> GetMaybeNet for PourPolyWeight {
fn maybe_net(&self) -> Option<usize> { fn maybe_net(&self) -> Option<usize> {
self.maybe_net self.maybe_net
} }
} }
impl From<GenericIndex<PourZoneWeight>> for GenericIndex<CompoundWeight> { impl From<GenericIndex<PourPolyWeight>> for GenericIndex<CompoundWeight> {
fn from(zone: GenericIndex<PourZoneWeight>) -> Self { fn from(poly: GenericIndex<PourPolyWeight>) -> Self {
GenericIndex::<CompoundWeight>::new(zone.petgraph_index()) GenericIndex::<CompoundWeight>::new(poly.petgraph_index())
} }
} }

View File

@ -6,7 +6,7 @@ use thiserror::Error;
use crate::{ use crate::{
board::{mesadata::AccessMesadata, Board}, board::{mesadata::AccessMesadata, Board},
drawing::{dot::FixedDotWeight, seg::FixedSegWeight, Drawing}, drawing::{dot::FixedDotWeight, seg::FixedSegWeight, Drawing},
layout::{zone::SolidZoneWeight, Layout}, layout::{poly::SolidPolyWeight, Layout},
math::Circle, math::Circle,
specctra::{ specctra::{
mesadata::SpecctraMesadata, mesadata::SpecctraMesadata,
@ -389,8 +389,8 @@ impl SpecctraDesign {
net: usize, net: usize,
maybe_pin: Option<String>, maybe_pin: Option<String>,
) { ) {
let zone = board.add_zone( let poly = board.add_poly(
SolidZoneWeight { SolidPolyWeight {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
} }
@ -399,7 +399,7 @@ impl SpecctraDesign {
); );
// Corners. // Corners.
let dot_1_1 = board.add_zone_fixed_dot_infringably( let dot_1_1 = board.add_poly_fixed_dot_infringably(
FixedDotWeight { FixedDotWeight {
circle: Circle { circle: Circle {
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x1, y1), pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x1, y1),
@ -408,9 +408,9 @@ impl SpecctraDesign {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
}, },
zone, poly,
); );
let dot_2_1 = board.add_zone_fixed_dot_infringably( let dot_2_1 = board.add_poly_fixed_dot_infringably(
FixedDotWeight { FixedDotWeight {
circle: Circle { circle: Circle {
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x2, y1), pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x2, y1),
@ -419,9 +419,9 @@ impl SpecctraDesign {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
}, },
zone, poly,
); );
let dot_2_2 = board.add_zone_fixed_dot_infringably( let dot_2_2 = board.add_poly_fixed_dot_infringably(
FixedDotWeight { FixedDotWeight {
circle: Circle { circle: Circle {
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x2, y2), pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x2, y2),
@ -430,9 +430,9 @@ impl SpecctraDesign {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
}, },
zone, poly,
); );
let dot_1_2 = board.add_zone_fixed_dot_infringably( let dot_1_2 = board.add_poly_fixed_dot_infringably(
FixedDotWeight { FixedDotWeight {
circle: Circle { circle: Circle {
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x1, y2), pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, x1, y2),
@ -441,10 +441,10 @@ impl SpecctraDesign {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
}, },
zone, poly,
); );
// Sides. // Sides.
board.add_zone_fixed_seg_infringably( board.add_poly_fixed_seg_infringably(
dot_1_1, dot_1_1,
dot_2_1, dot_2_1,
FixedSegWeight { FixedSegWeight {
@ -452,9 +452,9 @@ impl SpecctraDesign {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
}, },
zone, poly,
); );
board.add_zone_fixed_seg_infringably( board.add_poly_fixed_seg_infringably(
dot_2_1, dot_2_1,
dot_2_2, dot_2_2,
FixedSegWeight { FixedSegWeight {
@ -462,9 +462,9 @@ impl SpecctraDesign {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
}, },
zone, poly,
); );
board.add_zone_fixed_seg_infringably( board.add_poly_fixed_seg_infringably(
dot_2_2, dot_2_2,
dot_1_2, dot_1_2,
FixedSegWeight { FixedSegWeight {
@ -472,9 +472,9 @@ impl SpecctraDesign {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
}, },
zone, poly,
); );
board.add_zone_fixed_seg_infringably( board.add_poly_fixed_seg_infringably(
dot_1_2, dot_1_2,
dot_1_1, dot_1_1,
FixedSegWeight { FixedSegWeight {
@ -482,7 +482,7 @@ impl SpecctraDesign {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
}, },
zone, poly,
); );
} }
@ -568,8 +568,8 @@ impl SpecctraDesign {
net: usize, net: usize,
maybe_pin: Option<String>, maybe_pin: Option<String>,
) { ) {
let zone = board.add_zone( let poly = board.add_poly(
SolidZoneWeight { SolidPolyWeight {
layer, layer,
maybe_net: Some(net), maybe_net: Some(net),
} }
@ -578,7 +578,7 @@ impl SpecctraDesign {
); );
// 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 = board.add_zone_fixed_dot_infringably( let mut prev_index = board.add_poly_fixed_dot_infringably(
FixedDotWeight { FixedDotWeight {
circle: Circle { circle: Circle {
pos: Self::pos( pos: Self::pos(
@ -595,13 +595,13 @@ impl SpecctraDesign {
maybe_net: Some(net), maybe_net: Some(net),
}, },
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice. // TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
//GenericIndex::new(zone.petgraph_index()).into(), //GenericIndex::new(poly.petgraph_index()).into(),
zone, poly,
); );
// iterate through path coords starting from the second // iterate through path coords starting from the second
for coord in coords.iter().skip(1) { for coord in coords.iter().skip(1) {
let index = board.add_zone_fixed_dot_infringably( let index = board.add_poly_fixed_dot_infringably(
FixedDotWeight { FixedDotWeight {
circle: Circle { circle: Circle {
pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, coord.x, coord.y) pos: Self::pos(place_pos, place_rot, pin_pos, pin_rot, coord.x, coord.y)
@ -612,11 +612,11 @@ impl SpecctraDesign {
maybe_net: Some(net), maybe_net: Some(net),
}, },
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice. // TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
zone, poly,
); );
// add a seg between the current and previous coords // add a seg between the current and previous coords
let _ = board.add_zone_fixed_seg_infringably( let _ = board.add_poly_fixed_seg_infringably(
prev_index, prev_index,
index, index,
FixedSegWeight { FixedSegWeight {
@ -625,7 +625,7 @@ impl SpecctraDesign {
maybe_net: Some(net), maybe_net: Some(net),
}, },
// TODO: This manual retagging shouldn't be necessary, `.into()` should suffice. // TODO: This manual retagging shouldn't be necessary, `.into()` should suffice.
zone, poly,
); );
prev_index = index; prev_index = index;