mirror of https://codeberg.org/topola/topola.git
Load outlines to its own separate layer and group
This commit is contained in:
parent
ca517f62bd
commit
f9ea3940d2
|
|
@ -76,11 +76,10 @@ impl Board {
|
||||||
|
|
||||||
pub fn with_names(
|
pub fn with_names(
|
||||||
boundary: Vec<Vector2<i64>>,
|
boundary: Vec<Vector2<i64>>,
|
||||||
layer_groups: impl Into<Vec<LayerGroupId>>,
|
layer_groups: Vec<LayerGroupId>,
|
||||||
layer_names: BiBTreeMap<LayerId, String>,
|
layer_names: BiBTreeMap<LayerId, String>,
|
||||||
net_names: BiBTreeMap<NetId, String>,
|
net_names: BiBTreeMap<NetId, String>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let layer_groups = layer_groups.into();
|
|
||||||
Self {
|
Self {
|
||||||
layout: Layout::new(
|
layout: Layout::new(
|
||||||
boundary.into_iter().map(Into::into).collect(),
|
boundary.into_iter().map(Into::into).collect(),
|
||||||
|
|
@ -171,6 +170,10 @@ impl Board {
|
||||||
self.layer_names.as_ref().get_by_right(layer_name).copied()
|
self.layer_names.as_ref().get_by_right(layer_name).copied()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -218,7 +218,7 @@ impl NavmesherBoard {
|
||||||
polygon_multiobstacles: Recorder::new(StableVec::new()),
|
polygon_multiobstacles: Recorder::new(StableVec::new()),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (i, joint) in this.board.layout().joints().container().iter() {
|
/*for (i, joint) in this.board.layout().joints().container().iter() {
|
||||||
this.joint_multiobstacles.insert(
|
this.joint_multiobstacles.insert(
|
||||||
i,
|
i,
|
||||||
this.navmesher
|
this.navmesher
|
||||||
|
|
@ -240,7 +240,7 @@ impl NavmesherBoard {
|
||||||
this.navmesher
|
this.navmesher
|
||||||
.insert_multiobstacle(polygon.layer, polygon.vertices.clone()),
|
.insert_multiobstacle(polygon.layer, polygon.vertices.clone()),
|
||||||
);
|
);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use specctra::{
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
board::Board,
|
board::{Board, LayerGroupId},
|
||||||
layout::LayerId,
|
layout::LayerId,
|
||||||
layout::compounds::{ComponentId, NetId, PinId},
|
layout::compounds::{ComponentId, NetId, PinId},
|
||||||
math::Vector2,
|
math::Vector2,
|
||||||
|
|
@ -20,37 +20,43 @@ use crate::{
|
||||||
|
|
||||||
impl Board {
|
impl Board {
|
||||||
pub fn from_specctra(dsn: DsnFile) -> Self {
|
pub fn from_specctra(dsn: DsnFile) -> Self {
|
||||||
let layer_names = BiBTreeMap::from_iter(
|
let top_outline_layer_id = LayerId::new(0);
|
||||||
dsn.pcb
|
let pcb_layer_offset = 1;
|
||||||
.structure
|
let bottom_outline_layer_id =
|
||||||
.layers
|
LayerId::new(dsn.pcb.structure.layers.len() + pcb_layer_offset);
|
||||||
.iter()
|
let mut layer_names =
|
||||||
.enumerate()
|
BiBTreeMap::from_iter(dsn.pcb.structure.layers.iter().enumerate().map(
|
||||||
.map(|(index, layer)| (LayerId::new(index), layer.name.clone())),
|
|(index, layer)| (LayerId::new(index + pcb_layer_offset), layer.name.clone()),
|
||||||
);
|
));
|
||||||
|
layer_names.insert(top_outline_layer_id, "outlines.top".to_string());
|
||||||
|
layer_names.insert(bottom_outline_layer_id, "outlines.bottom".to_string());
|
||||||
|
|
||||||
// assign IDs to all nets named in pcb.network
|
// assign IDs to all nets named in pcb.network
|
||||||
let net_names = {
|
let net_names = {
|
||||||
let mut tmp: Vec<_> = dsn
|
let mut tmp: Vec<String> = dsn
|
||||||
.pcb
|
.pcb
|
||||||
.network
|
.network
|
||||||
.classes
|
.classes
|
||||||
.iter()
|
.iter()
|
||||||
.flat_map(|class| &class.nets)
|
.flat_map(|class| &class.nets)
|
||||||
.chain(dsn.pcb.network.nets.iter().map(|net| &net.name))
|
.chain(dsn.pcb.network.nets.iter().map(|net| &net.name))
|
||||||
|
.cloned()
|
||||||
.collect();
|
.collect();
|
||||||
// deduplicate net names
|
// deduplicate net names
|
||||||
|
tmp.push("outlines".to_string());
|
||||||
tmp.sort_unstable();
|
tmp.sort_unstable();
|
||||||
tmp.dedup();
|
tmp.dedup();
|
||||||
|
|
||||||
BiBTreeMap::from_iter(
|
BiBTreeMap::from_iter(tmp.into_iter().enumerate().map(|(i, v)| (NetId::new(i), v)))
|
||||||
tmp.into_iter()
|
|
||||||
.cloned()
|
|
||||||
.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
|
||||||
|
|
@ -62,10 +68,11 @@ impl Board {
|
||||||
.rev()
|
.rev()
|
||||||
.map(|p| Vector2::new(p.x as i64, p.y as i64))
|
.map(|p| Vector2::new(p.x as i64, p.y as i64))
|
||||||
.collect(),
|
.collect(),
|
||||||
vec![crate::board::LayerGroupId::new(0); dsn.pcb.structure.layers.len()],
|
layer_groups,
|
||||||
layer_names,
|
layer_names,
|
||||||
net_names,
|
net_names,
|
||||||
);
|
);
|
||||||
|
let outline_net = board.net_id("outlines").unwrap();
|
||||||
|
|
||||||
// Mapping of pin -> net prepared for adding pins.
|
// Mapping of pin -> net prepared for adding pins.
|
||||||
let pin_nets: BTreeMap<String, NetId> = dsn
|
let pin_nets: BTreeMap<String, NetId> = dsn
|
||||||
|
|
@ -105,6 +112,26 @@ impl Board {
|
||||||
Self::layer(board, &dsn.pcb.structure.layers, name, place_side_is_front)
|
Self::layer(board, &dsn.pcb.structure.layers, name, place_side_is_front)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
for outline in &image.outlines {
|
||||||
|
let outline_layer_id = if place_side_is_front {
|
||||||
|
top_outline_layer_id
|
||||||
|
} else {
|
||||||
|
bottom_outline_layer_id
|
||||||
|
};
|
||||||
|
Self::place_path(
|
||||||
|
&mut board,
|
||||||
|
place.point_with_rotation(),
|
||||||
|
PointWithRotation::default(),
|
||||||
|
&outline.path.coords,
|
||||||
|
outline.path.width,
|
||||||
|
outline_layer_id,
|
||||||
|
outline_net,
|
||||||
|
Some(component_id),
|
||||||
|
None,
|
||||||
|
!place_side_is_front,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
for pin in &image.pins {
|
for pin in &image.pins {
|
||||||
let pin_name = format!("{}-{}", place.name, pin.id);
|
let pin_name = format!("{}-{}", place.name, pin.id);
|
||||||
|
|
||||||
|
|
@ -413,12 +440,14 @@ impl Board {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn layer(board: &Board, layers: &[Layer], name: &str, front: bool) -> LayerId {
|
fn layer(board: &Board, layers: &[Layer], name: &str, front: bool) -> LayerId {
|
||||||
|
let pcb_layer_offset = 1;
|
||||||
let image_layer = board.layer_id(name).unwrap();
|
let image_layer = board.layer_id(name).unwrap();
|
||||||
|
let image_layer_index = image_layer.index() - pcb_layer_offset;
|
||||||
|
|
||||||
if front {
|
if front {
|
||||||
image_layer
|
image_layer
|
||||||
} else {
|
} else {
|
||||||
LayerId::new(layers.len() - image_layer.index() - 1)
|
LayerId::new(layers.len() - image_layer_index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue