dsn: add loading of simple images containing pins

This commit is contained in:
Tomasz Cichoń 2024-02-23 03:52:07 +01:00
parent 53fd88f408
commit 2014be1004
3 changed files with 101 additions and 7 deletions

View File

@ -246,9 +246,9 @@ fn main() -> Result<(), anyhow::Error> {
]),
}));*/
let design = DsnDesign::load_from_file("tests/data/test.dsn")?;
dbg!(&design);
let layout = design.make_layout();
let mut router = Router::new(layout);
//dbg!(&pcb);
render_times(
&mut event_pump,

View File

@ -87,14 +87,64 @@ pub struct Vias {
#[derive(Deserialize, Debug)]
#[serde(rename = "placement")]
pub struct Placement;
pub struct Placement {
pub components: Vec<Component>,
}
#[derive(Deserialize, Debug)]
#[serde(rename = "component")]
pub struct Component {
pub name: String,
pub places: Vec<Place>,
}
#[derive(Deserialize, Debug)]
#[serde(rename = "place")]
pub struct Place {
pub name: String,
pub x: f32,
pub y: f32,
pub side: String,
pub rotation: f32,
pub PN: Option<PN>,
}
#[derive(Deserialize, Debug)]
#[serde(rename = "PN")]
pub struct PN {
pub name: String,
}
#[derive(Deserialize, Debug)]
#[serde(rename = "library")]
pub struct Library {
pub images: Vec<Image>,
pub padstacks: Vec<Padstack>,
}
#[derive(Deserialize, Debug)]
#[serde(rename = "image")]
pub struct Image {
pub name: String,
pub outlines: Vec<Outline>,
pub pins: Vec<Pin>,
}
#[derive(Deserialize, Debug)]
#[serde(rename = "outline")]
pub struct Outline {
pub path: Path,
}
#[derive(Deserialize, Debug)]
#[serde(rename = "pin")]
pub struct Pin {
pub name: String,
pub id: String,
pub x: f32,
pub y: f32,
}
#[derive(Deserialize, Debug)]
#[serde(rename = "padstack")]
pub struct Padstack {
@ -167,15 +217,15 @@ pub struct Type(pub String);
#[derive(Deserialize, Debug)]
#[serde(rename = "unit")]
pub struct Point {
pub x: i32,
pub y: i32,
pub x: f32,
pub y: f32,
}
#[derive(Deserialize, Debug)]
#[serde(from = "FlatPath")]
pub struct Path {
pub layer: String,
pub width: u32,
pub width: f32,
pub coords: Vec<Point>,
}
@ -183,8 +233,8 @@ pub struct Path {
#[serde(rename = "path")]
struct FlatPath {
pub layer: String,
pub width: u32,
pub coords: Vec<i32>,
pub width: f32,
pub coords: Vec<f32>,
}
impl From<FlatPath> for Path {

View File

@ -33,8 +33,52 @@
)
)
(placement
(component Connector_Pin:Pin_D1.0mm_L10.0mm
(place REF** 55000.000000 -24900.000000 front 0.000000 (PN Pin_D1.0mm_L10.0mm))
)
)
(library
(image Connector_Pin:Pin_D1.0mm_L10.0mm
(outline (path signal 120 1251 0 1231.99 -217.234 1175.56 -427.867 1083.4 -625.5
958.322 -804.127 804.127 -958.322 625.5 -1083.4 427.867 -1175.56
217.234 -1231.99 0 -1251 -217.234 -1231.99 -427.867 -1175.56
-625.5 -1083.4 -804.127 -958.322 -958.322 -804.127 -1083.4 -625.5
-1175.56 -427.867 -1231.99 -217.234 -1251 0 -1231.99 217.234
-1175.56 427.867 -1083.4 625.5 -958.322 804.127 -804.127 958.322
-625.5 1083.4 -427.867 1175.56 -217.234 1231.99 0 1251 217.234 1231.99
427.867 1175.56 625.5 1083.4 804.127 958.322 958.322 804.127
1083.4 625.5 1175.56 427.867 1231.99 217.234 1251 0))
(outline (path signal 50 1500 0 1480.58 -240.617 1422.81 -475.002 1328.18 -697.085
1199.16 -901.113 1039.09 -1081.8 852.097 -1234.48 643.039 -1355.18
417.326 -1440.78 180.805 -1489.06 -60.399 -1498.78 -300.039 -1469.69
-531.907 -1402.52 -750 -1299.04 -948.668 -1161.91 -1122.77 -994.684
-1267.79 -801.699 -1379.97 -587.95 -1456.41 -358.973 -1495.14 -120.7
-1495.14 120.7 -1456.41 358.973 -1379.97 587.95 -1267.79 801.699
-1122.77 994.684 -948.668 1161.91 -750 1299.04 -531.907 1402.52
-300.039 1469.69 -60.399 1498.78 180.805 1489.06 417.326 1440.78
643.039 1355.18 852.097 1234.48 1039.09 1081.8 1199.16 901.113
1328.18 697.085 1422.81 475.002 1480.58 240.617 1500 0))
(outline (path signal 120 1000 0 980.785 -195.09 923.88 -382.683 831.47 -555.57
707.107 -707.107 555.57 -831.47 382.683 -923.88 195.09 -980.785
0 -1000 -195.09 -980.785 -382.683 -923.88 -555.57 -831.47
-707.107 -707.107 -831.47 -555.57 -923.88 -382.683 -980.785 -195.09
-1000 0 -980.785 195.09 -923.88 382.683 -831.47 555.57 -707.107 707.107
-555.57 831.47 -382.683 923.88 -195.09 980.785 0 1000 195.09 980.785
382.683 923.88 555.57 831.47 707.107 707.107 831.47 555.57
923.88 382.683 980.785 195.09 1000 0))
(outline (path signal 120 500 0 481.459 -134.898 427.21 -259.792 341.277 -365.418
230.033 -443.943 101.728 -489.542 -34.121 -498.834 -167.44 -471.13
-288.34 -408.485 -387.856 -315.544 -458.606 -199.201 -495.343 -68.083
-495.343 68.083 -458.606 199.201 -387.856 315.544 -288.34 408.485
-167.44 471.13 -34.121 498.834 101.728 489.542 230.033 443.943
341.277 365.418 427.21 259.792 481.459 134.898 500 0))
(pin Round[A]Pad_2000_um 1 0 0)
)
(padstack Round[A]Pad_2000_um
(shape (circle F.Cu 2000))
(shape (circle B.Cu 2000))
(attach off)
)
(padstack "Via[0-1]_800:400_um"
(shape (circle F.Cu 800))
(shape (circle B.Cu 800))