mirror of https://codeberg.org/topola/topola.git
Don't connect different-net primitives with ratlines
This commit is contained in:
parent
1dc6519722
commit
fa6c1ca522
|
|
@ -2,11 +2,15 @@
|
||||||
//
|
//
|
||||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||||
|
|
||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use derive_getters::Getters;
|
use derive_getters::Getters;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use spade::{DelaunayTriangulation, HasPosition, Triangulation, handles::FixedVertexHandle};
|
use spade::{DelaunayTriangulation, HasPosition, Triangulation, handles::FixedVertexHandle};
|
||||||
|
|
||||||
use crate::{Board, JointId, PolygonId, SegmentId, Vector2, primitives::PrimitiveId};
|
use crate::{
|
||||||
|
Board, JointId, PolygonId, SegmentId, Vector2, layout::NetId, primitives::PrimitiveId,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Getters, Ord, PartialEq, PartialOrd, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, Getters, Ord, PartialEq, PartialOrd, Serialize)]
|
||||||
pub struct Ratline {
|
pub struct Ratline {
|
||||||
|
|
@ -39,53 +43,52 @@ impl Ratsnest {
|
||||||
pub fn new(board: &Board) -> Self {
|
pub fn new(board: &Board) -> Self {
|
||||||
let mut ratlines = Vec::new();
|
let mut ratlines = Vec::new();
|
||||||
|
|
||||||
for layer in 0..*board.layout().layer_count() {
|
let mut triangulations: BTreeMap<(NetId, usize), DelaunayTriangulation<DelaunayVertex>> =
|
||||||
let mut triangulation: DelaunayTriangulation<DelaunayVertex> =
|
BTreeMap::new();
|
||||||
DelaunayTriangulation::new();
|
|
||||||
|
|
||||||
for layer in 0..*board.layout().layer_count() {
|
for (i, joint) in board.layout().joints().collection() {
|
||||||
for (i, joint) in board.layout().joints().collection() {
|
let _ = triangulations
|
||||||
if joint.layer == layer {
|
.entry((joint.net, joint.layer))
|
||||||
triangulation.insert(DelaunayVertex {
|
.or_insert_with(DelaunayTriangulation::new)
|
||||||
layer,
|
.insert(DelaunayVertex {
|
||||||
center: joint.center(),
|
layer: joint.layer,
|
||||||
position: spade::Point2::new(
|
center: joint.center(),
|
||||||
joint.center().x as f64,
|
position: spade::Point2::new(joint.center().x as f64, joint.center().y as f64),
|
||||||
joint.center().y as f64,
|
primitive_id: PrimitiveId::Joint(JointId::new(i)),
|
||||||
),
|
});
|
||||||
primitive_id: PrimitiveId::Joint(JointId::new(i)),
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i, segment) in board.layout().segments().collection() {
|
for (i, segment) in board.layout().segments().collection() {
|
||||||
if segment.layer == layer {
|
let segment_center = board.layout().segment_center(SegmentId::new(i));
|
||||||
let segment_center = board.layout().segment_center(SegmentId::new(i));
|
let _ = triangulations
|
||||||
triangulation.insert(DelaunayVertex {
|
.entry((segment.net, segment.layer))
|
||||||
layer,
|
.or_insert_with(DelaunayTriangulation::new)
|
||||||
center: segment_center,
|
.insert(DelaunayVertex {
|
||||||
position: spade::Point2::new(
|
layer: segment.layer,
|
||||||
segment_center.x as f64,
|
center: segment_center,
|
||||||
segment_center.y as f64,
|
position: spade::Point2::new(segment_center.x as f64, segment_center.y as f64),
|
||||||
),
|
primitive_id: PrimitiveId::Segment(SegmentId::new(i)),
|
||||||
primitive_id: PrimitiveId::Segment(SegmentId::new(i)),
|
});
|
||||||
});
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i, polygon) in board.layout().polygons().collection() {
|
for (i, polygon) in board.layout().polygons().collection() {
|
||||||
if polygon.layer == layer {
|
let _ = triangulations
|
||||||
triangulation.insert(DelaunayVertex {
|
.entry((polygon.net, polygon.layer))
|
||||||
layer,
|
.or_insert_with(DelaunayTriangulation::new)
|
||||||
center: polygon.center(),
|
.insert(DelaunayVertex {
|
||||||
position: spade::Point2::new(
|
layer: polygon.layer,
|
||||||
polygon.center().x as f64,
|
center: polygon.center(),
|
||||||
polygon.center().y as f64,
|
position: spade::Point2::new(
|
||||||
),
|
polygon.center().x as f64,
|
||||||
primitive_id: PrimitiveId::Polygon(PolygonId::new(i)),
|
polygon.center().y as f64,
|
||||||
});
|
),
|
||||||
}
|
primitive_id: PrimitiveId::Polygon(PolygonId::new(i)),
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for triangulation in triangulations.into_values() {
|
||||||
|
if triangulation.num_vertices() < 2 {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut weighted_edges: Vec<(u64, [usize; 2])> = Vec::new();
|
let mut weighted_edges: Vec<(u64, [usize; 2])> = Vec::new();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue