From 39fb51d401b8c76de315dcf3ad363ba7ff00aeec Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Mon, 25 May 2026 01:11:29 +0200 Subject: [PATCH] Get rid of layer groups. `LayerDesc`s already do the job --- topola/src/board/layer.rs | 25 +------------------------ topola/src/board/mod.rs | 12 ++---------- topola/src/specctra.rs | 10 +--------- 3 files changed, 4 insertions(+), 43 deletions(-) diff --git a/topola/src/board/layer.rs b/topola/src/board/layer.rs index 1ad5e6e..a593b2c 100644 --- a/topola/src/board/layer.rs +++ b/topola/src/board/layer.rs @@ -3,33 +3,10 @@ // SPDX-License-Identifier: MIT OR Apache-2.0 use core::fmt::Display; -use derive_more::{Constructor, From}; +use derive_more::Constructor; use serde::{Deserialize, Serialize}; use std::fmt::Formatter; -#[derive( - Clone, - Constructor, - Copy, - Debug, - Default, - Deserialize, - Eq, - From, - Ord, - PartialEq, - PartialOrd, - Serialize, -)] -pub struct LayerGroupId(usize); - -impl LayerGroupId { - #[inline] - pub fn index(self) -> usize { - self.0 - } -} - #[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] pub enum LayerType { Copper, diff --git a/topola/src/board/mod.rs b/topola/src/board/mod.rs index 9254a85..398c1b1 100644 --- a/topola/src/board/mod.rs +++ b/topola/src/board/mod.rs @@ -8,7 +8,7 @@ mod select; pub mod selections; mod transforms; -pub use crate::board::layer::{LayerDesc, LayerGroupId, LayerTier, LayerType}; +pub use crate::board::layer::{LayerDesc, LayerTier, LayerType}; use bidimap::BiBTreeMap; use derive_getters::Getters; @@ -30,8 +30,6 @@ use crate::{ pub struct Board { layout: Layout, #[getter(skip)] - layer_groups: Recorder>, - #[getter(skip)] component_names: Recorder>, #[getter(skip)] pin_names: Recorder>, @@ -54,16 +52,14 @@ impl Board { pub fn with_names( boundary: Vec>, - layer_groups: Vec, layer_descs: BiBTreeMap, net_names: BiBTreeMap, ) -> Self { Self { layout: Layout::new( boundary.into_iter().map(Into::into).collect(), - layer_groups.len(), + layer_descs.len(), ), - layer_groups: Recorder::new(layer_groups), component_names: Recorder::new(BiBTreeMap::new()), pin_names: Recorder::new(BiBTreeMap::new()), layer_descs: Recorder::new(layer_descs), @@ -159,10 +155,6 @@ impl Board { }) } - pub fn layer_group(&self, layer: LayerId) -> LayerGroupId { - self.layer_groups[layer.index()] - } - pub fn net_name(&self, id: NetId) -> Option<&str> { self.net_names.get_by_left(&id).map(String::as_str) } diff --git a/topola/src/specctra.rs b/topola/src/specctra.rs index 7a4140e..5d9ff11 100644 --- a/topola/src/specctra.rs +++ b/topola/src/specctra.rs @@ -11,7 +11,7 @@ use specctra::{ }; use crate::{ - board::{Board, LayerDesc, LayerGroupId, LayerTier, LayerType}, + board::{Board, LayerDesc, LayerTier, LayerType}, layout::LayerId, layout::compounds::{ComponentId, NetId, PinId}, math::Vector2, @@ -80,13 +80,6 @@ impl Board { BiBTreeMap::from_iter(tmp.into_iter().enumerate().map(|(i, v)| (NetId::new(i), v))) }; - let mut layer_groups = vec![LayerGroupId::new(1)]; - layer_groups.extend(std::iter::repeat_n( - LayerGroupId::new(0), - dsn.pcb.structure.layers.len(), - )); - layer_groups.push(LayerGroupId::new(1)); - let mut board = Board::with_names( dsn.pcb .structure @@ -103,7 +96,6 @@ impl Board { ) }) .collect(), - layer_groups, layer_descs, net_names, );