mirror of https://codeberg.org/topola/topola.git
Revert "Store primitive id for each navpolygon to go back from navmesh to board"
This reverts commit 269e14645e.
This commit is contained in:
parent
269e14645e
commit
41dd0a91f8
|
|
@ -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<RecordingTriangulator<i64>>,
|
||||
navpolygon_primitive_ids: Vec<PrimitiveId>,
|
||||
inflation_factors: Vec<f64>,
|
||||
}
|
||||
|
||||
|
|
@ -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<Item = [i64; 2]>,
|
||||
) {
|
||||
pub fn insert_polygon(&mut self, polygon: impl IntoIterator<Item = [i64; 2]>) {
|
||||
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<Item = [i64; 2]>,
|
||||
) {
|
||||
self.layers[layer].insert_navpolygon(primitive_id, polygon);
|
||||
pub fn insert_polygon(&mut self, layer: usize, polygon: impl IntoIterator<Item = [i64; 2]>) {
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
)]
|
||||
|
|
|
|||
Loading…
Reference in New Issue