Get rid of layer groups. `LayerDesc`s already do the job

This commit is contained in:
Mikolaj Wielgus 2026-05-25 01:11:29 +02:00
parent dd2ce0ce3b
commit 39fb51d401
3 changed files with 4 additions and 43 deletions

View File

@ -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,

View File

@ -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<Vec<LayerGroupId>>,
#[getter(skip)]
component_names: Recorder<BiBTreeMap<ComponentId, String>>,
#[getter(skip)]
pin_names: Recorder<BiBTreeMap<PinId, String>>,
@ -54,16 +52,14 @@ impl Board {
pub fn with_names(
boundary: Vec<Vector2<i64>>,
layer_groups: Vec<LayerGroupId>,
layer_descs: BiBTreeMap<LayerId, LayerDesc>,
net_names: BiBTreeMap<NetId, String>,
) -> 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)
}

View File

@ -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,
);