mirror of https://codeberg.org/topola/topola.git
Get rid of layer groups. `LayerDesc`s already do the job
This commit is contained in:
parent
dd2ce0ce3b
commit
39fb51d401
|
|
@ -3,33 +3,10 @@
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||||
|
|
||||||
use core::fmt::Display;
|
use core::fmt::Display;
|
||||||
use derive_more::{Constructor, From};
|
use derive_more::Constructor;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::fmt::Formatter;
|
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)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||||
pub enum LayerType {
|
pub enum LayerType {
|
||||||
Copper,
|
Copper,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ mod select;
|
||||||
pub mod selections;
|
pub mod selections;
|
||||||
mod transforms;
|
mod transforms;
|
||||||
|
|
||||||
pub use crate::board::layer::{LayerDesc, LayerGroupId, LayerTier, LayerType};
|
pub use crate::board::layer::{LayerDesc, LayerTier, LayerType};
|
||||||
|
|
||||||
use bidimap::BiBTreeMap;
|
use bidimap::BiBTreeMap;
|
||||||
use derive_getters::Getters;
|
use derive_getters::Getters;
|
||||||
|
|
@ -30,8 +30,6 @@ use crate::{
|
||||||
pub struct Board {
|
pub struct Board {
|
||||||
layout: Layout,
|
layout: Layout,
|
||||||
#[getter(skip)]
|
#[getter(skip)]
|
||||||
layer_groups: Recorder<Vec<LayerGroupId>>,
|
|
||||||
#[getter(skip)]
|
|
||||||
component_names: Recorder<BiBTreeMap<ComponentId, String>>,
|
component_names: Recorder<BiBTreeMap<ComponentId, String>>,
|
||||||
#[getter(skip)]
|
#[getter(skip)]
|
||||||
pin_names: Recorder<BiBTreeMap<PinId, String>>,
|
pin_names: Recorder<BiBTreeMap<PinId, String>>,
|
||||||
|
|
@ -54,16 +52,14 @@ impl Board {
|
||||||
|
|
||||||
pub fn with_names(
|
pub fn with_names(
|
||||||
boundary: Vec<Vector2<i64>>,
|
boundary: Vec<Vector2<i64>>,
|
||||||
layer_groups: Vec<LayerGroupId>,
|
|
||||||
layer_descs: BiBTreeMap<LayerId, LayerDesc>,
|
layer_descs: BiBTreeMap<LayerId, LayerDesc>,
|
||||||
net_names: BiBTreeMap<NetId, String>,
|
net_names: BiBTreeMap<NetId, String>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Self {
|
Self {
|
||||||
layout: Layout::new(
|
layout: Layout::new(
|
||||||
boundary.into_iter().map(Into::into).collect(),
|
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()),
|
component_names: Recorder::new(BiBTreeMap::new()),
|
||||||
pin_names: Recorder::new(BiBTreeMap::new()),
|
pin_names: Recorder::new(BiBTreeMap::new()),
|
||||||
layer_descs: Recorder::new(layer_descs),
|
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> {
|
pub fn net_name(&self, id: NetId) -> Option<&str> {
|
||||||
self.net_names.get_by_left(&id).map(String::as_str)
|
self.net_names.get_by_left(&id).map(String::as_str)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use specctra::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
board::{Board, LayerDesc, LayerGroupId, LayerTier, LayerType},
|
board::{Board, LayerDesc, LayerTier, LayerType},
|
||||||
layout::LayerId,
|
layout::LayerId,
|
||||||
layout::compounds::{ComponentId, NetId, PinId},
|
layout::compounds::{ComponentId, NetId, PinId},
|
||||||
math::Vector2,
|
math::Vector2,
|
||||||
|
|
@ -80,13 +80,6 @@ impl Board {
|
||||||
BiBTreeMap::from_iter(tmp.into_iter().enumerate().map(|(i, v)| (NetId::new(i), v)))
|
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(
|
let mut board = Board::with_names(
|
||||||
dsn.pcb
|
dsn.pcb
|
||||||
.structure
|
.structure
|
||||||
|
|
@ -103,7 +96,6 @@ impl Board {
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
layer_groups,
|
|
||||||
layer_descs,
|
layer_descs,
|
||||||
net_names,
|
net_names,
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue