From d9927d12317cbb4fdb65f299de8b7dc3e4eb35a5 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Tue, 10 Mar 2026 14:23:55 +0100 Subject: [PATCH] Add and display polygons --- topola/src/specctra.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/topola/src/specctra.rs b/topola/src/specctra.rs index daba450..7ce39e8 100644 --- a/topola/src/specctra.rs +++ b/topola/src/specctra.rs @@ -4,7 +4,7 @@ use specctra::{ math::PointWithRotation, - structure::{DsnFile, Shape}, + structure::{DsnFile, Point, Shape}, }; use crate::{ @@ -66,6 +66,16 @@ impl Board { 0, false, ), + // ... TODO. + Shape::Polygon(polygon) => Self::place_polygon( + &mut board, + place.point_with_rotation(), + pin.point_with_rotation(), + &polygon.coords, + polygon.width, + 0, + false, + ), _ => (), } } @@ -113,6 +123,22 @@ impl Board { }); } + pub fn place_polygon( + board: &mut Board, + place: PointWithRotation, + pin: PointWithRotation, + coords: &[Point], + width: f64, + layer: usize, + flip: bool, + ) { + let vertices: Vec<[i64; 2]> = coords + .iter() + .map(|coord| Self::pos(place, pin, coord.x, coord.y, flip)) + .collect(); + board.add_polygon(Polygon { vertices, layer }); + } + fn pos( place: PointWithRotation, pin: PointWithRotation,