mirror of https://codeberg.org/topola/topola.git
dsn: implement basic import of paths in pads
This commit is contained in:
parent
451d4da7a6
commit
fe89226072
|
|
@ -10,7 +10,7 @@ use crate::{
|
||||||
use super::{
|
use super::{
|
||||||
de,
|
de,
|
||||||
rules::DsnRules,
|
rules::DsnRules,
|
||||||
structure::{DsnFile, Pcb, Shape},
|
structure::{self, DsnFile, Pcb, Shape},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
|
|
@ -97,14 +97,22 @@ impl DsnDesign {
|
||||||
),
|
),
|
||||||
Shape::Rect(rect) => Self::add_rect(
|
Shape::Rect(rect) => Self::add_rect(
|
||||||
&mut layout,
|
&mut layout,
|
||||||
(place.x + rect.x1) as f64,
|
(place.x - pin.x + rect.x1) as f64,
|
||||||
-(place.y + rect.y1) as f64,
|
-(place.y - pin.y + rect.y1) as f64,
|
||||||
(place.x + rect.x2) as f64,
|
(place.x - pin.x + rect.x2) as f64,
|
||||||
-(place.y + rect.y2) as f64,
|
-(place.y - pin.y + rect.y2) as f64,
|
||||||
|
layer as u64,
|
||||||
|
*net_id as i64,
|
||||||
|
),
|
||||||
|
Shape::Path(path) => Self::add_path(
|
||||||
|
&mut layout,
|
||||||
|
(place.x - pin.x) as f64,
|
||||||
|
-(place.y - pin.y) as f64,
|
||||||
|
&path.coord_vec,
|
||||||
|
path.width as f64,
|
||||||
layer as u64,
|
layer as u64,
|
||||||
*net_id as i64,
|
*net_id as i64,
|
||||||
),
|
),
|
||||||
Shape::Path(_) => (),
|
|
||||||
Shape::Polygon(_) => (),
|
Shape::Polygon(_) => (),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -138,8 +146,30 @@ impl DsnDesign {
|
||||||
net_id as i64,
|
net_id as i64,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
Shape::Rect(_) => todo!(),
|
Shape::Rect(rect) => {
|
||||||
Shape::Path(_) => todo!(),
|
let layer = *layout.rules().layer_ids.get(&rect.layer).unwrap();
|
||||||
|
Self::add_rect(
|
||||||
|
&mut layout,
|
||||||
|
rect.x1 as f64,
|
||||||
|
rect.y1 as f64,
|
||||||
|
rect.x2 as f64,
|
||||||
|
rect.y2 as f64,
|
||||||
|
layer as u64,
|
||||||
|
net_id as i64,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Shape::Path(path) => {
|
||||||
|
let layer = *layout.rules().layer_ids.get(&path.layer).unwrap();
|
||||||
|
Self::add_path(
|
||||||
|
&mut layout,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
&path.coord_vec,
|
||||||
|
path.width as f64,
|
||||||
|
layer as u64,
|
||||||
|
net_id as i64,
|
||||||
|
)
|
||||||
|
}
|
||||||
Shape::Polygon(_) => todo!(),
|
Shape::Polygon(_) => todo!(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -149,50 +179,15 @@ impl DsnDesign {
|
||||||
let layer_id = *layout.rules().layer_ids.get(&wire.path.layer).unwrap();
|
let layer_id = *layout.rules().layer_ids.get(&wire.path.layer).unwrap();
|
||||||
let net_id = *layout.rules().net_ids.get(&wire.net).unwrap();
|
let net_id = *layout.rules().net_ids.get(&wire.net).unwrap();
|
||||||
|
|
||||||
// add the first coordinate in the wire path as a dot and save its index
|
Self::add_path(
|
||||||
let mut prev_index = layout
|
&mut layout,
|
||||||
.add_fixed_dot(FixedDotWeight {
|
0.0,
|
||||||
circle: Circle {
|
0.0,
|
||||||
pos: (
|
&wire.path.coord_vec,
|
||||||
wire.path.coord_vec[0].x as f64,
|
wire.path.width as f64,
|
||||||
-wire.path.coord_vec[0].y as f64,
|
layer_id as u64,
|
||||||
)
|
net_id as i64,
|
||||||
.into(),
|
);
|
||||||
r: wire.path.width as f64 / 2.0,
|
|
||||||
},
|
|
||||||
layer: layer_id as u64,
|
|
||||||
net: net_id as i64,
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// iterate through path coords starting from the second
|
|
||||||
for coord in wire.path.coord_vec.iter().skip(1) {
|
|
||||||
let index = layout
|
|
||||||
.add_fixed_dot(FixedDotWeight {
|
|
||||||
circle: Circle {
|
|
||||||
pos: (coord.x as f64, -coord.y as f64).into(),
|
|
||||||
r: wire.path.width as f64 / 2.0,
|
|
||||||
},
|
|
||||||
layer: layer_id as u64,
|
|
||||||
net: net_id as i64,
|
|
||||||
})
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
// add a seg between the current and previous coords
|
|
||||||
let _ = layout
|
|
||||||
.add_fixed_seg(
|
|
||||||
prev_index,
|
|
||||||
index,
|
|
||||||
FixedSegWeight {
|
|
||||||
width: wire.path.width as f64,
|
|
||||||
layer: layer_id as u64,
|
|
||||||
net: net_id as i64,
|
|
||||||
},
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
prev_index = index;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
layout
|
layout
|
||||||
|
|
@ -260,7 +255,8 @@ impl DsnDesign {
|
||||||
})
|
})
|
||||||
.unwrap();
|
.unwrap();
|
||||||
// Sides.
|
// Sides.
|
||||||
layout.add_fixed_seg(
|
layout
|
||||||
|
.add_fixed_seg(
|
||||||
dot_1_1,
|
dot_1_1,
|
||||||
dot_2_1,
|
dot_2_1,
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
|
|
@ -268,8 +264,10 @@ impl DsnDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
layout.add_fixed_seg(
|
.unwrap();
|
||||||
|
layout
|
||||||
|
.add_fixed_seg(
|
||||||
dot_2_1,
|
dot_2_1,
|
||||||
dot_2_2,
|
dot_2_2,
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
|
|
@ -277,8 +275,10 @@ impl DsnDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
layout.add_fixed_seg(
|
.unwrap();
|
||||||
|
layout
|
||||||
|
.add_fixed_seg(
|
||||||
dot_2_2,
|
dot_2_2,
|
||||||
dot_1_2,
|
dot_1_2,
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
|
|
@ -286,8 +286,10 @@ impl DsnDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
layout.add_fixed_seg(
|
.unwrap();
|
||||||
|
layout
|
||||||
|
.add_fixed_seg(
|
||||||
dot_1_2,
|
dot_1_2,
|
||||||
dot_1_1,
|
dot_1_1,
|
||||||
FixedSegWeight {
|
FixedSegWeight {
|
||||||
|
|
@ -295,6 +297,50 @@ impl DsnDesign {
|
||||||
layer,
|
layer,
|
||||||
net,
|
net,
|
||||||
},
|
},
|
||||||
);
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn add_path(
|
||||||
|
layout: &mut Layout<DsnRules>,
|
||||||
|
offset_x: f64,
|
||||||
|
offset_y: f64,
|
||||||
|
coords: &Vec<structure::Point>,
|
||||||
|
width: f64,
|
||||||
|
layer: u64,
|
||||||
|
net: i64,
|
||||||
|
) {
|
||||||
|
// add the first coordinate in the wire path as a dot and save its index
|
||||||
|
let mut prev_index = layout
|
||||||
|
.add_fixed_dot(FixedDotWeight {
|
||||||
|
circle: Circle {
|
||||||
|
pos: (offset_x + coords[0].x as f64, offset_y - coords[0].y as f64).into(),
|
||||||
|
r: width / 2.0,
|
||||||
|
},
|
||||||
|
layer,
|
||||||
|
net,
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// iterate through path coords starting from the second
|
||||||
|
for coord in coords.iter().skip(1) {
|
||||||
|
let index = layout
|
||||||
|
.add_fixed_dot(FixedDotWeight {
|
||||||
|
circle: Circle {
|
||||||
|
pos: (offset_x + coord.x as f64, offset_y - coord.y as f64).into(),
|
||||||
|
r: width / 2.0,
|
||||||
|
},
|
||||||
|
layer,
|
||||||
|
net,
|
||||||
|
})
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
// add a seg between the current and previous coords
|
||||||
|
let _ = layout
|
||||||
|
.add_fixed_seg(prev_index, index, FixedSegWeight { width, layer, net })
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
prev_index = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue