specctra: a hack to attempt loading layers from EasyEDA

This commit is contained in:
Tomasz Cichoń 2024-09-28 11:16:47 +02:00
parent 479646d503
commit dfb2c20f1d
3 changed files with 19 additions and 9 deletions

View File

@ -55,7 +55,8 @@ impl SpecctraDesign {
///
pub fn load(reader: impl std::io::BufRead) -> Result<SpecctraDesign, LoadingError> {
let mut list_reader = ListTokenizer::new(reader);
let dsn = list_reader.read_value::<DsnFile>()?;
let mut dsn = list_reader.read_value::<DsnFile>()?;
dsn.pcb.structure.layers.append(&mut dsn.pcb.structure.layers_easyeda); // temporary hack
Ok(Self { pcb: dsn.pcb })
}

View File

@ -72,12 +72,17 @@ impl SpecctraMesadata {
/// layer-to-layer name mappings, net-to-net name mappings, and net class rules.
///
pub fn from_pcb(pcb: &Pcb) -> Self {
let layer_layername = BiHashMap::from_iter(
pcb.structure
.layers
.iter()
.map(|layer| (layer.property.index, layer.name.clone())),
);
let mut highest_layer: usize = 0;
let mut layer_layername = BiHashMap::new();
for layer in &pcb.structure.layers {
let index = if layer.property.is_some() {
layer.property.as_ref().unwrap().index
} else {
layer.name.parse().unwrap()
};
layer_layername.insert(index, layer.name.clone());
}
// keeping this as a separate iter pass because it might be moved into a different struct later?
let net_netname = BiHashMap::from_iter(

View File

@ -94,6 +94,10 @@ pub struct Structure {
// (in class rules it outputs a single rule with all clearances like KiCad)
#[vec("rule")]
pub rules: Vec<StructureRule>,
// EasyEDA outputs these last...
// this is a horrible hack to see what else causes trouble
#[vec("layer")]
pub layers_easyeda: Vec<Layer>,
}
#[derive(ReadDsn, WriteSes, Debug)]
@ -101,7 +105,7 @@ pub struct Layer {
#[anon]
pub name: String,
pub r#type: String,
pub property: Property,
pub property: Option<Property>,
}
#[derive(ReadDsn, WriteSes, Debug)]
@ -224,7 +228,7 @@ pub struct Padstack {
pub name: String,
#[vec("shape")]
pub shapes: Vec<Shape>,
pub attach: bool,
pub attach: Option<bool>,
}
// TODO: derive for enums if more than this single one is needed