From 41dd0a91f861c9cadfb8d5f25697b577df216ecf Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Mon, 16 Mar 2026 22:28:25 +0100 Subject: [PATCH] Revert "Store primitive id for each navpolygon to go back from navmesh to board" This reverts commit 269e14645ed315a092a9177e4596b2064d4a2169. --- topola/src/navmesher.rs | 66 ++++++++++++---------------------------- topola/src/primitives.rs | 9 +----- 2 files changed, 20 insertions(+), 55 deletions(-) diff --git a/topola/src/navmesher.rs b/topola/src/navmesher.rs index b291d61..1d7e33f 100644 --- a/topola/src/navmesher.rs +++ b/topola/src/navmesher.rs @@ -6,15 +6,15 @@ use dearcut::RecordingTriangulator; use derive_getters::Getters; use crate::{ - Board, math, - primitives::{Joint, JointId, Polygon, PolygonId, PrimitiveId, Segment, SegmentId, Via, ViaId}, + math, + Board, + primitives::{Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Via, ViaId}, }; #[derive(Clone, Debug, Getters)] pub struct LayerNavmesher { boundary: Vec<[i64; 2]>, navmeshes: Vec>, - navpolygon_primitive_ids: Vec, inflation_factors: Vec, } @@ -23,16 +23,11 @@ impl LayerNavmesher { Self { boundary: boundary.into_iter().collect(), navmeshes: vec![RecordingTriangulator::new()], - navpolygon_primitive_ids: vec![], inflation_factors: vec![0.0], } } - pub fn insert_navpolygon( - &mut self, - primitive_id: PrimitiveId, - polygon: impl IntoIterator, - ) { + pub fn insert_polygon(&mut self, polygon: impl IntoIterator) { let polygon: Vec<[i64; 2]> = polygon.into_iter().collect(); for i in 0..self.navmeshes.len() { @@ -41,8 +36,6 @@ impl LayerNavmesher { self.boundary.clone(), ); } - - self.navpolygon_primitive_ids.push(primitive_id); } fn inflate_polygon( @@ -94,13 +87,8 @@ impl Navmesher { } } - pub fn insert_navpolygon( - &mut self, - layer: usize, - primitive_id: PrimitiveId, - polygon: impl IntoIterator, - ) { - self.layers[layer].insert_navpolygon(primitive_id, polygon); + pub fn insert_polygon(&mut self, layer: usize, polygon: impl IntoIterator) { + self.layers[layer].insert_polygon(polygon); } } @@ -117,36 +105,28 @@ impl NavmesherBoard { *board.layout().layer_count(), ); - for (i, joint) in board.layout().joints().collection() { - Self::insert_joint_in_navmesher(&mut navmesher, JointId::new(i), *joint); + for (_, joint) in board.layout().joints().collection() { + Self::insert_joint_in_navmesher(&mut navmesher, *joint); } for (i, segment) in board.layout().segments().collection() { Self::insert_segment_in_navmesher(&mut navmesher, &board, SegmentId::new(i), *segment); } - // TODO: vias. - - for (i, polygon) in board.layout().polygons().collection() { - Self::insert_polygon_in_navmesher(&mut navmesher, PolygonId::new(i), polygon.clone()); + for (_, polygon) in board.layout().polygons().collection() { + Self::insert_polygon_in_navmesher(&mut navmesher, polygon.clone()); } Self { navmesher, board } } pub fn insert_joint(&mut self, joint: Joint) -> JointId { - let joint_id = self.board.add_joint(joint); - Self::insert_joint_in_navmesher(&mut self.navmesher, joint_id, joint); - - joint_id + Self::insert_joint_in_navmesher(&mut self.navmesher, joint); + self.board.add_joint(joint) } - fn insert_joint_in_navmesher(navmesher: &mut Navmesher, joint_id: JointId, joint: Joint) { - navmesher.insert_navpolygon( - joint.layer, - PrimitiveId::Joint(joint_id), - Self::joint_circumscribed_octagon(joint), - ); + fn insert_joint_in_navmesher(navmesher: &mut Navmesher, joint: Joint) { + navmesher.insert_polygon(joint.layer, Self::joint_circumscribed_octagon(joint)); } fn joint_circumscribed_octagon(joint: Joint) -> [[i64; 2]; 8] { @@ -181,9 +161,8 @@ impl NavmesherBoard { ) { let endpoints = board.layout().segment_endpoints(segment_id); - navmesher.insert_navpolygon( + navmesher.insert_polygon( segment.layer, - PrimitiveId::Segment(segment_id), math::inflated_segment( endpoints[0].x, endpoints[0].y, @@ -202,20 +181,13 @@ impl NavmesherBoard { } pub fn insert_polygon(&mut self, polygon: Polygon) -> PolygonId { - let polygon_id = self.board.add_polygon(polygon.clone()); - Self::insert_polygon_in_navmesher(&mut self.navmesher, polygon_id, polygon); - - polygon_id + Self::insert_polygon_in_navmesher(&mut self.navmesher, polygon.clone()); + self.board.add_polygon(polygon) } - fn insert_polygon_in_navmesher( - navmesher: &mut Navmesher, - polygon_id: PolygonId, - polygon: Polygon, - ) { - navmesher.insert_navpolygon( + fn insert_polygon_in_navmesher(navmesher: &mut Navmesher, polygon: Polygon) { + navmesher.insert_polygon( polygon.layer, - PrimitiveId::Polygon(polygon_id), polygon.vertices.into_iter().map(Into::into), ); } diff --git a/topola/src/primitives.rs b/topola/src/primitives.rs index d03a1a2..3debc0f 100644 --- a/topola/src/primitives.rs +++ b/topola/src/primitives.rs @@ -9,16 +9,9 @@ use serde::{Deserialize, Serialize}; use crate::{ Vector2, layout::{NetId, PinId}, + selection::PinSelector, }; -#[derive(Clone, Copy, Debug)] -pub enum PrimitiveId { - Joint(JointId), - Segment(SegmentId), - Via(ViaId), - Polygon(PolygonId), -} - #[derive( Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize, )]