mirror of https://codeberg.org/topola/topola.git
Rename "polygon" to "poly", "segment" to "seg"
This follows the established pattern of narrowing the meaning of a word by its apocopation, like in the following examples: difference -> diff (visual representation of a difference) rectangle -> rect (axis-aligned rectangle) configuration -> config (a top-level configuration) application -> app specification -> spec
This commit is contained in:
parent
ec8b72823c
commit
b134f7eef2
|
|
@ -164,7 +164,7 @@ impl Boundary {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn to_polygon(&self) -> GeoPolygon {
|
||||
pub fn to_poly(&self) -> GeoPolygon {
|
||||
GeoPolygon::new(
|
||||
LineString(
|
||||
self.coords()
|
||||
|
|
@ -619,7 +619,7 @@ pub struct Polygon {
|
|||
}
|
||||
|
||||
impl Polygon {
|
||||
pub fn to_polygon(&self) -> GeoPolygon {
|
||||
pub fn to_poly(&self) -> GeoPolygon {
|
||||
GeoPolygon::new(
|
||||
LineString(
|
||||
self.coords
|
||||
|
|
|
|||
|
|
@ -219,8 +219,8 @@ impl DebugOverlay {
|
|||
);
|
||||
}
|
||||
|
||||
for segment_id in layout.layer_segments(layer) {
|
||||
let endpoints = layout.segment(segment_id).endpoints;
|
||||
for seg_id in layout.layer_segs(layer) {
|
||||
let endpoints = layout.seg(seg_id).endpoints;
|
||||
|
||||
ui.painter().rect_stroke(
|
||||
egui::Rect::from_two_pos(
|
||||
|
|
@ -248,9 +248,9 @@ impl DebugOverlay {
|
|||
);
|
||||
}
|
||||
|
||||
for polygon_id in layout.layer_polygons(layer) {
|
||||
let polygon = layout.polygon(polygon_id);
|
||||
let bbox = polygon.bbox();
|
||||
for poly_id in layout.layer_polys(layer) {
|
||||
let poly = layout.poly(poly_id);
|
||||
let bbox = poly.bbox();
|
||||
|
||||
ui.painter().rect_stroke(
|
||||
egui::Rect {
|
||||
|
|
|
|||
|
|
@ -3,12 +3,14 @@
|
|||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
use crate::{
|
||||
controller::Controller, debug_overlay::{DebugOverlay, DebugOverlayOptions}, menu_bar::MenuBar,
|
||||
controller::Controller,
|
||||
debug_overlay::{DebugOverlay, DebugOverlayOptions},
|
||||
menu_bar::MenuBar,
|
||||
viewport::Viewport,
|
||||
};
|
||||
use topola::{
|
||||
Workspace,
|
||||
layout::primitives::{Joint, Polygon, Segment, Via},
|
||||
layout::primitives::{Joint, Poly, Seg, Via},
|
||||
};
|
||||
|
||||
pub struct Display {}
|
||||
|
|
@ -93,26 +95,24 @@ impl Display {
|
|||
);
|
||||
}
|
||||
|
||||
for segment_id in layout.layer_segments(layer) {
|
||||
let segment = layout.segment(segment_id);
|
||||
for seg_id in layout.layer_segs(layer) {
|
||||
let seg = layout.seg(seg_id);
|
||||
let pin_selected =
|
||||
board.pins_contain_segment(&workspace.workspace.selection().pins, segment_id);
|
||||
board.pins_contain_seg(&workspace.workspace.selection().pins, seg_id);
|
||||
let net_selected =
|
||||
board.nets_contain_segment(&workspace.workspace.selection().nets, segment_id);
|
||||
let component_selected = board.components_contain_segment(
|
||||
&workspace.workspace.selection().components,
|
||||
segment_id,
|
||||
);
|
||||
self.paint_segment(
|
||||
board.nets_contain_seg(&workspace.workspace.selection().nets, seg_id);
|
||||
let component_selected = board
|
||||
.components_contain_seg(&workspace.workspace.selection().components, seg_id);
|
||||
self.paint_seg(
|
||||
ctx,
|
||||
ui,
|
||||
viewport,
|
||||
segment,
|
||||
seg,
|
||||
workspace.appearance_panel.layer_color(
|
||||
ctx,
|
||||
board.layer_desc(segment.layer),
|
||||
board.layer_desc(seg.layer),
|
||||
pin_selected,
|
||||
(segment.spec.pin.is_none() && net_selected) || component_selected,
|
||||
(seg.spec.pin.is_none() && net_selected) || component_selected,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -139,26 +139,24 @@ impl Display {
|
|||
);
|
||||
}
|
||||
|
||||
for polygon_id in layout.layer_polygons(layer) {
|
||||
let polygon = layout.polygon(polygon_id);
|
||||
for poly_id in layout.layer_polys(layer) {
|
||||
let poly = layout.poly(poly_id);
|
||||
let pin_selected =
|
||||
board.pins_contain_polygon(&workspace.workspace.selection().pins, polygon_id);
|
||||
board.pins_contain_poly(&workspace.workspace.selection().pins, poly_id);
|
||||
let net_selected =
|
||||
board.nets_contain_polygon(&workspace.workspace.selection().nets, polygon_id);
|
||||
let component_selected = board.components_contain_polygon(
|
||||
&workspace.workspace.selection().components,
|
||||
polygon_id,
|
||||
);
|
||||
self.paint_polygon(
|
||||
board.nets_contain_poly(&workspace.workspace.selection().nets, poly_id);
|
||||
let component_selected = board
|
||||
.components_contain_poly(&workspace.workspace.selection().components, poly_id);
|
||||
self.paint_poly(
|
||||
ctx,
|
||||
ui,
|
||||
viewport,
|
||||
polygon,
|
||||
poly,
|
||||
workspace.appearance_panel.layer_color(
|
||||
ctx,
|
||||
board.layer_desc(polygon.spec.layer),
|
||||
board.layer_desc(poly.spec.layer),
|
||||
pin_selected,
|
||||
(polygon.spec.pin.is_none() && net_selected) || component_selected,
|
||||
(poly.spec.pin.is_none() && net_selected) || component_selected,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
|
@ -192,20 +190,20 @@ impl Display {
|
|||
);
|
||||
}
|
||||
|
||||
fn paint_segment(
|
||||
fn paint_seg(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
ui: &egui::Ui,
|
||||
viewport: &Viewport,
|
||||
segment: &Segment,
|
||||
seg: &Seg,
|
||||
color: egui::Color32,
|
||||
) {
|
||||
ui.painter().line_segment(
|
||||
[
|
||||
egui::pos2(segment.endpoints[0].x as f32, segment.endpoints[0].y as f32),
|
||||
egui::pos2(segment.endpoints[1].x as f32, segment.endpoints[1].y as f32),
|
||||
egui::pos2(seg.endpoints[0].x as f32, seg.endpoints[0].y as f32),
|
||||
egui::pos2(seg.endpoints[1].x as f32, seg.endpoints[1].y as f32),
|
||||
],
|
||||
egui::Stroke::new(segment.spec.half_width as f32 * 2.0, color),
|
||||
egui::Stroke::new(seg.spec.half_width as f32 * 2.0, color),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -224,16 +222,17 @@ impl Display {
|
|||
);
|
||||
}
|
||||
|
||||
fn paint_polygon(
|
||||
fn paint_poly(
|
||||
&mut self,
|
||||
ctx: &egui::Context,
|
||||
ui: &egui::Ui,
|
||||
viewport: &Viewport,
|
||||
polygon: &Polygon,
|
||||
poly: &Poly,
|
||||
color: egui::Color32,
|
||||
) {
|
||||
let points: Vec<egui::Pos2> = polygon
|
||||
.spec.vertices
|
||||
let points: Vec<egui::Pos2> = poly
|
||||
.spec
|
||||
.vertices
|
||||
.iter()
|
||||
.map(|v| egui::pos2(v.x as f32, v.y as f32))
|
||||
.collect();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
use crate::{
|
||||
board::Board,
|
||||
layout::primitives::{JointId, PolygonId, SegmentId, ViaId},
|
||||
layout::primitives::{JointId, PolyId, SegId, ViaId},
|
||||
selections::{ComponentSelection, NetSelection, NetSelector, PinSelection},
|
||||
vector::Vector2,
|
||||
};
|
||||
|
|
@ -30,12 +30,12 @@ impl Board {
|
|||
selection.0.contains(&selector)
|
||||
}
|
||||
|
||||
pub fn components_contain_segment(
|
||||
pub fn components_contain_seg(
|
||||
&self,
|
||||
selection: &ComponentSelection,
|
||||
id: SegmentId,
|
||||
id: SegId,
|
||||
) -> bool {
|
||||
let Some(selector) = self.segment_component_selector(id) else {
|
||||
let Some(selector) = self.seg_component_selector(id) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -50,12 +50,12 @@ impl Board {
|
|||
selection.0.contains(&selector)
|
||||
}
|
||||
|
||||
pub fn components_contain_polygon(
|
||||
pub fn components_contain_poly(
|
||||
&self,
|
||||
selection: &ComponentSelection,
|
||||
id: PolygonId,
|
||||
id: PolyId,
|
||||
) -> bool {
|
||||
let Some(selector) = self.polygon_component_selector(id) else {
|
||||
let Some(selector) = self.poly_component_selector(id) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -73,9 +73,9 @@ impl Board {
|
|||
.contains(&NetSelector::new(net_name.to_string()))
|
||||
}
|
||||
|
||||
pub fn nets_contain_segment(&self, selection: &NetSelection, id: SegmentId) -> bool {
|
||||
let segment = self.layout.segment(id);
|
||||
let Some(net_name) = segment.net.and_then(|net| self.net_name(net)) else {
|
||||
pub fn nets_contain_seg(&self, selection: &NetSelection, id: SegId) -> bool {
|
||||
let seg = self.layout.seg(id);
|
||||
let Some(net_name) = seg.net.and_then(|net| self.net_name(net)) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -95,9 +95,9 @@ impl Board {
|
|||
.contains(&NetSelector::new(net_name.to_string()))
|
||||
}
|
||||
|
||||
pub fn nets_contain_polygon(&self, selection: &NetSelection, id: PolygonId) -> bool {
|
||||
let polygon = self.layout.polygon(id);
|
||||
let Some(net_name) = polygon.spec.net.and_then(|net| self.net_name(net)) else {
|
||||
pub fn nets_contain_poly(&self, selection: &NetSelection, id: PolyId) -> bool {
|
||||
let poly = self.layout.poly(id);
|
||||
let Some(net_name) = poly.spec.net.and_then(|net| self.net_name(net)) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -114,8 +114,8 @@ impl Board {
|
|||
selection.0.contains(&selector)
|
||||
}
|
||||
|
||||
pub fn pins_contain_segment(&self, selection: &PinSelection, id: SegmentId) -> bool {
|
||||
let Some(selector) = self.segment_pin_selector(id) else {
|
||||
pub fn pins_contain_seg(&self, selection: &PinSelection, id: SegId) -> bool {
|
||||
let Some(selector) = self.seg_pin_selector(id) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -130,8 +130,8 @@ impl Board {
|
|||
selection.0.contains(&selector)
|
||||
}
|
||||
|
||||
pub fn pins_contain_polygon(&self, selection: &PinSelection, id: PolygonId) -> bool {
|
||||
let Some(selector) = self.polygon_pin_selector(id) else {
|
||||
pub fn pins_contain_poly(&self, selection: &PinSelection, id: PolyId) -> bool {
|
||||
let Some(selector) = self.poly_pin_selector(id) else {
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
layout::{
|
||||
compounds::ComponentId,
|
||||
primitives::{
|
||||
JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId,
|
||||
JointId, JointSpec, Poly, PolyId, Seg, SegId, SegSpec, Via, ViaId,
|
||||
ViaSpec,
|
||||
},
|
||||
},
|
||||
|
|
@ -22,12 +22,12 @@ impl Board {
|
|||
self.layout.insert_joint(spec)
|
||||
}
|
||||
|
||||
pub fn insert_segment(&mut self, spec: SegmentSpec) -> SegmentId {
|
||||
self.layout.insert_segment(spec)
|
||||
pub fn insert_seg(&mut self, spec: SegSpec) -> SegId {
|
||||
self.layout.insert_seg(spec)
|
||||
}
|
||||
|
||||
pub fn insert_segment_raw(&mut self, segment: Segment) -> SegmentId {
|
||||
self.layout.insert_segment_raw(segment)
|
||||
pub fn insert_seg_raw(&mut self, seg: Seg) -> SegId {
|
||||
self.layout.insert_seg_raw(seg)
|
||||
}
|
||||
|
||||
pub fn insert_via(&mut self, spec: ViaSpec) -> ViaId {
|
||||
|
|
@ -38,7 +38,7 @@ impl Board {
|
|||
self.layout.insert_via_raw(via)
|
||||
}
|
||||
|
||||
pub fn insert_polygon(&mut self, polygon: Polygon) -> PolygonId {
|
||||
self.layout.insert_polygon(polygon)
|
||||
pub fn insert_poly(&mut self, poly: Poly) -> PolyId {
|
||||
self.layout.insert_poly(poly)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,16 +67,16 @@ impl Interactor for DragSelectInteractor {
|
|||
.all(|joint_id| board.layout().joint(joint_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_segments_prefer_layer_intersecting_rect(rect)
|
||||
.all(|segment_id| board.layout().segment(segment_id).spec.pin.is_some())
|
||||
.locate_segs_prefer_layer_intersecting_rect(rect)
|
||||
.all(|seg_id| board.layout().seg(seg_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_vias_prefer_layer_intersecting_rect(rect)
|
||||
.all(|via_id| board.layout().via(via_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_polygons_prefer_layer_intersecting_rect(rect)
|
||||
.all(|polygon_id| board.layout().polygon(polygon_id).spec.pin.is_some())
|
||||
.locate_polys_prefer_layer_intersecting_rect(rect)
|
||||
.all(|poly_id| board.layout().poly(poly_id).spec.pin.is_some())
|
||||
}
|
||||
SelectionContainMode::Window => {
|
||||
board
|
||||
|
|
@ -85,16 +85,16 @@ impl Interactor for DragSelectInteractor {
|
|||
.all(|joint_id| board.layout().joint(joint_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_segments_prefer_layer_inside_rect(rect)
|
||||
.all(|segment_id| board.layout().segment(segment_id).spec.pin.is_some())
|
||||
.locate_segs_prefer_layer_inside_rect(rect)
|
||||
.all(|seg_id| board.layout().seg(seg_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_vias_prefer_layer_inside_rect(rect)
|
||||
.all(|via_id| board.layout().via(via_id).spec.pin.is_some())
|
||||
&& board
|
||||
.layout()
|
||||
.locate_polygons_prefer_layer_inside_rect(rect)
|
||||
.all(|polygon_id| board.layout().polygon(polygon_id).spec.pin.is_some())
|
||||
.locate_polys_prefer_layer_inside_rect(rect)
|
||||
.all(|poly_id| board.layout().poly(poly_id).spec.pin.is_some())
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ impl Board {
|
|||
.filter_map(|joint_id| self.joint_component_selector(joint_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_prefer_layer_at_point(point)
|
||||
.filter_map(|segment_id| self.segment_component_selector(segment_id)),
|
||||
.locate_segs_prefer_layer_at_point(point)
|
||||
.filter_map(|seg_id| self.seg_component_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -30,8 +30,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_polygons_prefer_layer_at_point(point)
|
||||
.filter_map(|polygon_id| self.polygon_component_selector(polygon_id)),
|
||||
.locate_polys_prefer_layer_at_point(point)
|
||||
.filter_map(|poly_id| self.poly_component_selector(poly_id)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -44,8 +44,8 @@ impl Board {
|
|||
.filter_map(|joint_id| self.joint_component_selector(joint_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_at_point(point)
|
||||
.filter_map(|segment_id| self.segment_component_selector(segment_id)),
|
||||
.locate_segs_at_point(point)
|
||||
.filter_map(|seg_id| self.seg_component_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -54,8 +54,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_polygons_at_point(point)
|
||||
.filter_map(|polygon_id| self.polygon_component_selector(polygon_id)),
|
||||
.locate_polys_at_point(point)
|
||||
.filter_map(|poly_id| self.poly_component_selector(poly_id)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -68,8 +68,8 @@ impl Board {
|
|||
.filter_map(|joint_id| self.joint_component_selector(joint_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_prefer_layer_intersecting_rect(rect)
|
||||
.filter_map(|segment_id| self.segment_component_selector(segment_id)),
|
||||
.locate_segs_prefer_layer_intersecting_rect(rect)
|
||||
.filter_map(|seg_id| self.seg_component_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -78,8 +78,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_polygons_prefer_layer_intersecting_rect(rect)
|
||||
.filter_map(|polygon_id| self.polygon_component_selector(polygon_id)),
|
||||
.locate_polys_prefer_layer_intersecting_rect(rect)
|
||||
.filter_map(|poly_id| self.poly_component_selector(poly_id)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -92,8 +92,8 @@ impl Board {
|
|||
.filter_map(|joint_id| self.joint_component_selector(joint_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_intersecting_rect(rect)
|
||||
.filter_map(|segment_id| self.segment_component_selector(segment_id)),
|
||||
.locate_segs_intersecting_rect(rect)
|
||||
.filter_map(|seg_id| self.seg_component_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -102,8 +102,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_polygons_intersecting_rect(rect)
|
||||
.filter_map(|polygon_id| self.polygon_component_selector(polygon_id)),
|
||||
.locate_polys_intersecting_rect(rect)
|
||||
.filter_map(|poly_id| self.poly_component_selector(poly_id)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -116,8 +116,8 @@ impl Board {
|
|||
.filter_map(|joint_id| self.joint_component_selector(joint_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|segment_id| self.segment_component_selector(segment_id)),
|
||||
.locate_segs_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|seg_id| self.seg_component_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -126,8 +126,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_polygons_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|polygon_id| self.polygon_component_selector(polygon_id)),
|
||||
.locate_polys_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|poly_id| self.poly_component_selector(poly_id)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -140,8 +140,8 @@ impl Board {
|
|||
.filter_map(|joint_id| self.joint_component_selector(joint_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|segment_id| self.segment_component_selector(segment_id)),
|
||||
.locate_segs_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|seg_id| self.seg_component_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -150,8 +150,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_polygons_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|polygon_id| self.polygon_component_selector(polygon_id)),
|
||||
.locate_polys_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|poly_id| self.poly_component_selector(poly_id)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -164,8 +164,8 @@ impl Board {
|
|||
.filter_map(|joint_id| self.joint_net_selector(joint_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_prefer_layer_at_point(point)
|
||||
.filter_map(|segment_id| self.segment_net_selector(segment_id)),
|
||||
.locate_segs_prefer_layer_at_point(point)
|
||||
.filter_map(|seg_id| self.seg_net_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -174,8 +174,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_polygons_prefer_layer_at_point(point)
|
||||
.filter_map(|polygon_id| self.polygon_net_selector(polygon_id)),
|
||||
.locate_polys_prefer_layer_at_point(point)
|
||||
.filter_map(|poly_id| self.poly_net_selector(poly_id)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -188,8 +188,8 @@ impl Board {
|
|||
.filter_map(|joint_id| self.joint_net_selector(joint_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_at_point(point)
|
||||
.filter_map(|segment_id| self.segment_net_selector(segment_id)),
|
||||
.locate_segs_at_point(point)
|
||||
.filter_map(|seg_id| self.seg_net_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -198,8 +198,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_polygons_at_point(point)
|
||||
.filter_map(|polygon_id| self.polygon_net_selector(polygon_id)),
|
||||
.locate_polys_at_point(point)
|
||||
.filter_map(|poly_id| self.poly_net_selector(poly_id)),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -276,8 +276,8 @@ impl Board {
|
|||
point: Vector3<i64>,
|
||||
) -> impl Iterator<Item = PinSelector> + '_ {
|
||||
self.layout
|
||||
.locate_polygons_prefer_layer_at_point(point)
|
||||
.filter_map(|polygon_id| self.polygon_pin_selector(polygon_id))
|
||||
.locate_polys_prefer_layer_at_point(point)
|
||||
.filter_map(|poly_id| self.poly_pin_selector(poly_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_joints_prefer_layer_at_point(point)
|
||||
|
|
@ -285,8 +285,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_prefer_layer_at_point(point)
|
||||
.filter_map(|segment_id| self.segment_pin_selector(segment_id)),
|
||||
.locate_segs_prefer_layer_at_point(point)
|
||||
.filter_map(|seg_id| self.seg_pin_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -300,8 +300,8 @@ impl Board {
|
|||
point: Vector3<i64>,
|
||||
) -> impl Iterator<Item = PinSelector> + '_ {
|
||||
self.layout
|
||||
.locate_polygons_at_point(point)
|
||||
.filter_map(|polygon_id| self.polygon_pin_selector(polygon_id))
|
||||
.locate_polys_at_point(point)
|
||||
.filter_map(|poly_id| self.poly_pin_selector(poly_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_joints_at_point(point)
|
||||
|
|
@ -309,8 +309,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_at_point(point)
|
||||
.filter_map(|segment_id| self.segment_pin_selector(segment_id)),
|
||||
.locate_segs_at_point(point)
|
||||
.filter_map(|seg_id| self.seg_pin_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -324,8 +324,8 @@ impl Board {
|
|||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = PinSelector> + '_ {
|
||||
self.layout
|
||||
.locate_polygons_prefer_layer_intersecting_rect(rect)
|
||||
.filter_map(|polygon_id| self.polygon_pin_selector(polygon_id))
|
||||
.locate_polys_prefer_layer_intersecting_rect(rect)
|
||||
.filter_map(|poly_id| self.poly_pin_selector(poly_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_joints_prefer_layer_intersecting_rect(rect)
|
||||
|
|
@ -333,8 +333,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_prefer_layer_intersecting_rect(rect)
|
||||
.filter_map(|segment_id| self.segment_pin_selector(segment_id)),
|
||||
.locate_segs_prefer_layer_intersecting_rect(rect)
|
||||
.filter_map(|seg_id| self.seg_pin_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -348,8 +348,8 @@ impl Board {
|
|||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = PinSelector> + '_ {
|
||||
self.layout
|
||||
.locate_polygons_intersecting_rect(rect)
|
||||
.filter_map(|polygon_id| self.polygon_pin_selector(polygon_id))
|
||||
.locate_polys_intersecting_rect(rect)
|
||||
.filter_map(|poly_id| self.poly_pin_selector(poly_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_joints_intersecting_rect(rect)
|
||||
|
|
@ -357,8 +357,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_intersecting_rect(rect)
|
||||
.filter_map(|segment_id| self.segment_pin_selector(segment_id)),
|
||||
.locate_segs_intersecting_rect(rect)
|
||||
.filter_map(|seg_id| self.seg_pin_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -372,8 +372,8 @@ impl Board {
|
|||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = PinSelector> + '_ {
|
||||
self.layout
|
||||
.locate_polygons_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|polygon_id| self.polygon_pin_selector(polygon_id))
|
||||
.locate_polys_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|poly_id| self.poly_pin_selector(poly_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_joints_prefer_layer_inside_rect(rect)
|
||||
|
|
@ -381,8 +381,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|segment_id| self.segment_pin_selector(segment_id)),
|
||||
.locate_segs_prefer_layer_inside_rect(rect)
|
||||
.filter_map(|seg_id| self.seg_pin_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
@ -396,8 +396,8 @@ impl Board {
|
|||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = PinSelector> + '_ {
|
||||
self.layout
|
||||
.locate_polygons_inside_rect(rect)
|
||||
.filter_map(|polygon_id| self.polygon_pin_selector(polygon_id))
|
||||
.locate_polys_inside_rect(rect)
|
||||
.filter_map(|poly_id| self.poly_pin_selector(poly_id))
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_joints_inside_rect(rect)
|
||||
|
|
@ -405,8 +405,8 @@ impl Board {
|
|||
)
|
||||
.chain(
|
||||
self.layout
|
||||
.locate_segments_inside_rect(rect)
|
||||
.filter_map(|segment_id| self.segment_pin_selector(segment_id)),
|
||||
.locate_segs_inside_rect(rect)
|
||||
.filter_map(|seg_id| self.seg_pin_selector(seg_id)),
|
||||
)
|
||||
.chain(
|
||||
self.layout
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
board::{Board, selections::ComponentSelection},
|
||||
layout::{
|
||||
compounds::ComponentId,
|
||||
primitives::{JointId, PolygonId, SegmentId, ViaId},
|
||||
primitives::{JointId, PolyId, SegId, ViaId},
|
||||
},
|
||||
selections::NetSelection,
|
||||
};
|
||||
|
|
@ -41,22 +41,22 @@ impl Board {
|
|||
resolved_joints.into_iter()
|
||||
}
|
||||
|
||||
pub fn resolve_net_segments(&self, selection: NetSelection) -> impl Iterator<Item = SegmentId> {
|
||||
let mut resolved_segments = Vec::new();
|
||||
pub fn resolve_net_segs(&self, selection: NetSelection) -> impl Iterator<Item = SegId> {
|
||||
let mut resolved_segs = Vec::new();
|
||||
|
||||
for (index, _) in self.layout.segments().container() {
|
||||
let segment_id = SegmentId::new(index);
|
||||
for (index, _) in self.layout.segs().container() {
|
||||
let seg_id = SegId::new(index);
|
||||
|
||||
let Some(selector) = self.segment_net_selector(segment_id) else {
|
||||
let Some(selector) = self.seg_net_selector(seg_id) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if selection.0.contains(&selector) {
|
||||
resolved_segments.push(segment_id);
|
||||
resolved_segs.push(seg_id);
|
||||
}
|
||||
}
|
||||
|
||||
resolved_segments.into_iter()
|
||||
resolved_segs.into_iter()
|
||||
}
|
||||
|
||||
pub fn resolve_net_vias(&self, selection: NetSelection) -> impl Iterator<Item = ViaId> {
|
||||
|
|
@ -77,21 +77,21 @@ impl Board {
|
|||
resolved_vias.into_iter()
|
||||
}
|
||||
|
||||
pub fn resolve_net_polygons(&self, selection: NetSelection) -> impl Iterator<Item = PolygonId> {
|
||||
let mut resolved_polygons = Vec::new();
|
||||
pub fn resolve_net_polys(&self, selection: NetSelection) -> impl Iterator<Item = PolyId> {
|
||||
let mut resolved_polys = Vec::new();
|
||||
|
||||
for (index, _) in self.layout.polygons().container() {
|
||||
let polygon_id = PolygonId::new(index);
|
||||
for (index, _) in self.layout.polys().container() {
|
||||
let poly_id = PolyId::new(index);
|
||||
|
||||
let Some(selector) = self.polygon_net_selector(polygon_id) else {
|
||||
let Some(selector) = self.poly_net_selector(poly_id) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
if selection.0.contains(&selector) {
|
||||
resolved_polygons.push(polygon_id);
|
||||
resolved_polys.push(poly_id);
|
||||
}
|
||||
}
|
||||
|
||||
resolved_polygons.into_iter()
|
||||
resolved_polys.into_iter()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
ComponentSelection, ComponentSelector, NetSelector, PinSelection, PinSelector,
|
||||
},
|
||||
},
|
||||
layout::primitives::{JointId, PolygonId, SegmentId, ViaId},
|
||||
layout::primitives::{JointId, PolyId, SegId, ViaId},
|
||||
};
|
||||
|
||||
impl Board {
|
||||
|
|
@ -49,24 +49,24 @@ impl Board {
|
|||
component_selection.0.insert(component_selector);
|
||||
}
|
||||
|
||||
for segment_id in self.layout.layer_segments(layer_id) {
|
||||
if self.layout.segment(segment_id).spec.pin != Some(pin_id) {
|
||||
for seg_id in self.layout.layer_segs(layer_id) {
|
||||
if self.layout.seg(seg_id).spec.pin != Some(pin_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let Some(component_selector) = self.segment_component_selector(segment_id) else {
|
||||
let Some(component_selector) = self.seg_component_selector(seg_id) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
component_selection.0.insert(component_selector);
|
||||
}
|
||||
|
||||
for polygon_id in self.layout.layer_polygons(layer_id) {
|
||||
if self.layout.polygon(polygon_id).spec.pin != Some(pin_id) {
|
||||
for poly_id in self.layout.layer_polys(layer_id) {
|
||||
if self.layout.poly(poly_id).spec.pin != Some(pin_id) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let Some(component_selector) = self.polygon_component_selector(polygon_id) else {
|
||||
let Some(component_selector) = self.poly_component_selector(poly_id) else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
|
@ -85,11 +85,11 @@ impl Board {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn segment_component_selector(&self, id: SegmentId) -> Option<ComponentSelector> {
|
||||
let segment = self.layout.segment(id);
|
||||
pub fn seg_component_selector(&self, id: SegId) -> Option<ComponentSelector> {
|
||||
let seg = self.layout.seg(id);
|
||||
|
||||
Some(ComponentSelector {
|
||||
component: self.component_name(segment.spec.component?)?.to_string(),
|
||||
component: self.component_name(seg.spec.component?)?.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -101,11 +101,11 @@ impl Board {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn polygon_component_selector(&self, id: PolygonId) -> Option<ComponentSelector> {
|
||||
let polygon = self.layout.polygon(id);
|
||||
pub fn poly_component_selector(&self, id: PolyId) -> Option<ComponentSelector> {
|
||||
let poly = self.layout.poly(id);
|
||||
|
||||
Some(ComponentSelector {
|
||||
component: self.component_name(polygon.spec.component?)?.to_string(),
|
||||
component: self.component_name(poly.spec.component?)?.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -117,11 +117,11 @@ impl Board {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn segment_net_selector(&self, id: SegmentId) -> Option<NetSelector> {
|
||||
let segment = self.layout.segment(id);
|
||||
pub fn seg_net_selector(&self, id: SegId) -> Option<NetSelector> {
|
||||
let seg = self.layout.seg(id);
|
||||
|
||||
Some(NetSelector {
|
||||
net: self.net_name(segment.net?)?.to_string(),
|
||||
net: self.net_name(seg.net?)?.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -133,11 +133,11 @@ impl Board {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn polygon_net_selector(&self, id: PolygonId) -> Option<NetSelector> {
|
||||
let polygon = self.layout.polygon(id);
|
||||
pub fn poly_net_selector(&self, id: PolyId) -> Option<NetSelector> {
|
||||
let poly = self.layout.poly(id);
|
||||
|
||||
Some(NetSelector {
|
||||
net: self.net_name(polygon.spec.net?)?.to_string(),
|
||||
net: self.net_name(poly.spec.net?)?.to_string(),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -150,12 +150,12 @@ impl Board {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn segment_pin_selector(&self, id: SegmentId) -> Option<PinSelector> {
|
||||
let segment = self.layout.segment(id);
|
||||
pub fn seg_pin_selector(&self, id: SegId) -> Option<PinSelector> {
|
||||
let seg = self.layout.seg(id);
|
||||
|
||||
Some(PinSelector {
|
||||
pin: self.pin_name(segment.spec.pin?)?.to_string(),
|
||||
layer: self.layer_name(segment.layer)?,
|
||||
pin: self.pin_name(seg.spec.pin?)?.to_string(),
|
||||
layer: self.layer_name(seg.layer)?,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -168,12 +168,12 @@ impl Board {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn polygon_pin_selector(&self, id: PolygonId) -> Option<PinSelector> {
|
||||
let polygon = self.layout.polygon(id);
|
||||
pub fn poly_pin_selector(&self, id: PolyId) -> Option<PinSelector> {
|
||||
let poly = self.layout.poly(id);
|
||||
|
||||
Some(PinSelector {
|
||||
pin: self.pin_name(polygon.spec.pin?)?.to_string(),
|
||||
layer: self.layer_name(polygon.spec.layer)?,
|
||||
pin: self.pin_name(poly.spec.pin?)?.to_string(),
|
||||
layer: self.layer_name(poly.spec.layer)?,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ impl Board {
|
|||
self.layout.delete_joint(joint_id);
|
||||
}
|
||||
|
||||
for segment_id in self
|
||||
.resolve_net_segments(selection.clone())
|
||||
.filter(|&segment_id| self.layout.segment(segment_id).spec.pin.is_none())
|
||||
for seg_id in self
|
||||
.resolve_net_segs(selection.clone())
|
||||
.filter(|&seg_id| self.layout.seg(seg_id).spec.pin.is_none())
|
||||
.collect::<Vec<_>>()
|
||||
.clone()
|
||||
{
|
||||
self.layout.delete_segment(segment_id);
|
||||
self.layout.delete_seg(seg_id);
|
||||
}
|
||||
|
||||
for via_id in self
|
||||
|
|
@ -33,13 +33,13 @@ impl Board {
|
|||
self.layout.delete_via(via_id);
|
||||
}
|
||||
|
||||
for polygon_id in self
|
||||
.resolve_net_polygons(selection.clone())
|
||||
.filter(|&polygon_id| self.layout.polygon(polygon_id).spec.pin.is_none())
|
||||
for poly_id in self
|
||||
.resolve_net_polys(selection.clone())
|
||||
.filter(|&poly_id| self.layout.poly(poly_id).spec.pin.is_none())
|
||||
.collect::<Vec<_>>()
|
||||
.clone()
|
||||
{
|
||||
self.layout.delete_polygon(polygon_id);
|
||||
self.layout.delete_poly(poly_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,14 @@
|
|||
//
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
use polygon_unionfind::UnionFind;
|
||||
use poly_unionfind::UnionFind;
|
||||
|
||||
use crate::board::Board;
|
||||
|
||||
pub struct Connectivity {
|
||||
joints_unionfind: UnionFind,
|
||||
segments_unionfind: UnionFind,
|
||||
polygons_unionfind: UnionFind,
|
||||
segs_unionfind: UnionFind,
|
||||
polys_unionfind: UnionFind,
|
||||
}
|
||||
|
||||
impl Connectivity {
|
||||
|
|
@ -18,11 +18,11 @@ impl Connectivity {
|
|||
joints_unionfind: UnionFind::with_len(
|
||||
board.layout().joints().container().num_elements(),
|
||||
),
|
||||
segments_unionfind: UnionFind::with_len(
|
||||
board.layout().segments().container().num_elements(),
|
||||
segs_unionfind: UnionFind::with_len(
|
||||
board.layout().segs().container().num_elements(),
|
||||
),
|
||||
polygons_unionfind: UnionFind::with_len(
|
||||
board.layout().polygons().container().num_elements(),
|
||||
polys_unionfind: UnionFind::with_len(
|
||||
board.layout().polys().container().num_elements(),
|
||||
),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -16,16 +16,16 @@ impl Layout {
|
|||
unionize(&mut maybe_accum_bbox2, self.joint(joint_id).bbox().xy());
|
||||
}
|
||||
|
||||
for &segment_id in &component.segments {
|
||||
unionize(&mut maybe_accum_bbox2, self.segment(segment_id).bbox().xy());
|
||||
for &seg_id in &component.segs {
|
||||
unionize(&mut maybe_accum_bbox2, self.seg(seg_id).bbox().xy());
|
||||
}
|
||||
|
||||
for &via_id in &component.vias {
|
||||
unionize(&mut maybe_accum_bbox2, self.via(via_id).bbox().xy());
|
||||
}
|
||||
|
||||
for &polygon_id in &component.polygons {
|
||||
unionize(&mut maybe_accum_bbox2, self.polygon(polygon_id).bbox().xy());
|
||||
for &poly_id in &component.polys {
|
||||
unionize(&mut maybe_accum_bbox2, self.poly(poly_id).bbox().xy());
|
||||
}
|
||||
|
||||
maybe_accum_bbox2
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use serde::{Deserialize, Serialize};
|
|||
|
||||
use crate::layout::{
|
||||
compounds::PinId,
|
||||
primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId},
|
||||
primitives::{JointId, PolyId, PrimitiveId, SegId, ViaId},
|
||||
};
|
||||
|
||||
#[derive(
|
||||
|
|
@ -37,9 +37,9 @@ impl ComponentId {
|
|||
pub struct Component {
|
||||
pub pins: Vec<PinId>,
|
||||
pub joints: Vec<JointId>,
|
||||
pub segments: Vec<SegmentId>,
|
||||
pub segs: Vec<SegId>,
|
||||
pub vias: Vec<ViaId>,
|
||||
pub polygons: Vec<PolygonId>,
|
||||
pub polys: Vec<PolyId>,
|
||||
}
|
||||
|
||||
impl Component {
|
||||
|
|
@ -52,15 +52,15 @@ impl Component {
|
|||
.iter()
|
||||
.map(|&joint_id| PrimitiveId::Joint(joint_id))
|
||||
.chain(
|
||||
self.segments
|
||||
self.segs
|
||||
.iter()
|
||||
.map(|&segment_id| PrimitiveId::Segment(segment_id)),
|
||||
.map(|&seg_id| PrimitiveId::Seg(seg_id)),
|
||||
)
|
||||
.chain(self.vias.iter().map(|&via_id| PrimitiveId::Via(via_id)))
|
||||
.chain(
|
||||
self.polygons
|
||||
self.polys
|
||||
.iter()
|
||||
.map(|&polygon_id| PrimitiveId::Polygon(polygon_id)),
|
||||
.map(|&poly_id| PrimitiveId::Poly(poly_id)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
layout::{
|
||||
Layout,
|
||||
compounds::{ComponentId, NetId},
|
||||
primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId},
|
||||
primitives::{JointId, PolyId, PrimitiveId, SegId, ViaId},
|
||||
},
|
||||
vector::Vector2,
|
||||
};
|
||||
|
|
@ -47,9 +47,9 @@ pub struct PinSpec {
|
|||
pub struct Pin {
|
||||
pub spec: PinSpec,
|
||||
pub joints: Vec<JointId>,
|
||||
pub segments: Vec<SegmentId>,
|
||||
pub segs: Vec<SegId>,
|
||||
pub vias: Vec<ViaId>,
|
||||
pub polygons: Vec<PolygonId>,
|
||||
pub polys: Vec<PolyId>,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
|
|
@ -57,9 +57,9 @@ impl Pin {
|
|||
Pin {
|
||||
spec,
|
||||
joints: Vec::new(),
|
||||
segments: Vec::new(),
|
||||
segs: Vec::new(),
|
||||
vias: Vec::new(),
|
||||
polygons: Vec::new(),
|
||||
polys: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -68,15 +68,15 @@ impl Pin {
|
|||
.iter()
|
||||
.map(|&joint_id| PrimitiveId::Joint(joint_id))
|
||||
.chain(
|
||||
self.segments
|
||||
self.segs
|
||||
.iter()
|
||||
.map(|&segment_id| PrimitiveId::Segment(segment_id)),
|
||||
.map(|&seg_id| PrimitiveId::Seg(seg_id)),
|
||||
)
|
||||
.chain(self.vias.iter().map(|&via_id| PrimitiveId::Via(via_id)))
|
||||
.chain(
|
||||
self.polygons
|
||||
self.polys
|
||||
.iter()
|
||||
.map(|&polygon_id| PrimitiveId::Polygon(polygon_id)),
|
||||
.map(|&poly_id| PrimitiveId::Poly(poly_id)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -92,16 +92,16 @@ impl Layout {
|
|||
sum = sum + self.joint(joint_id).center();
|
||||
count += 1;
|
||||
}
|
||||
for &segment_id in &pin.segments {
|
||||
sum = sum + self.segment(segment_id).center();
|
||||
for &seg_id in &pin.segs {
|
||||
sum = sum + self.seg(seg_id).center();
|
||||
count += 1;
|
||||
}
|
||||
for &via_id in &pin.vias {
|
||||
sum = sum + self.via(via_id).position;
|
||||
count += 1;
|
||||
}
|
||||
for &polygon_id in &pin.polygons {
|
||||
sum = sum + self.polygon(polygon_id).centroid;
|
||||
for &poly_id in &pin.polys {
|
||||
sum = sum + self.poly(poly_id).centroid;
|
||||
count += 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use rstar::primitives::GeomWithData;
|
|||
|
||||
use crate::layout::{
|
||||
Layout,
|
||||
primitives::{JointId, PolygonId, SegmentId, ViaId},
|
||||
primitives::{JointId, PolyId, SegId, ViaId},
|
||||
};
|
||||
|
||||
impl Layout {
|
||||
|
|
@ -37,35 +37,35 @@ impl Layout {
|
|||
self.joints.remove(&joint_id.index());
|
||||
}
|
||||
|
||||
pub fn delete_segment(&mut self, segment_id: SegmentId) {
|
||||
let segment = self.segment(segment_id);
|
||||
let bbox = segment.bbox();
|
||||
let component = segment.spec.component;
|
||||
let pin = segment.spec.pin;
|
||||
pub fn delete_seg(&mut self, seg_id: SegId) {
|
||||
let seg = self.seg(seg_id);
|
||||
let bbox = seg.bbox();
|
||||
let component = seg.spec.component;
|
||||
let pin = seg.spec.pin;
|
||||
|
||||
if let Some(component_id) = component {
|
||||
self.components.modify(component_id.index(), |component| {
|
||||
if let Some(index) = component
|
||||
.segments
|
||||
.segs
|
||||
.iter()
|
||||
.position(|&curr| curr == segment_id)
|
||||
.position(|&curr| curr == seg_id)
|
||||
{
|
||||
component.segments.remove(index);
|
||||
component.segs.remove(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(pin_id) = pin {
|
||||
self.pins.modify(pin_id.index(), |pin| {
|
||||
if let Some(index) = pin.segments.iter().position(|&curr| curr == segment_id) {
|
||||
pin.segments.remove(index);
|
||||
if let Some(index) = pin.segs.iter().position(|&curr| curr == seg_id) {
|
||||
pin.segs.remove(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
self.segments_rtree
|
||||
.remove(&GeomWithData::new(bbox.rtree_rectangle(), segment_id));
|
||||
self.segments.remove(&segment_id.index());
|
||||
self.segs_rtree
|
||||
.remove(&GeomWithData::new(bbox.rtree_rectangle(), seg_id));
|
||||
self.segs.remove(&seg_id.index());
|
||||
}
|
||||
|
||||
pub fn delete_via(&mut self, via_id: ViaId) {
|
||||
|
|
@ -95,34 +95,34 @@ impl Layout {
|
|||
self.vias.remove(&via_id.index());
|
||||
}
|
||||
|
||||
pub fn delete_polygon(&mut self, polygon_id: PolygonId) {
|
||||
let polygon = self.polygon(polygon_id);
|
||||
let bbox = polygon.bbox();
|
||||
let component = polygon.spec.component;
|
||||
let pin = polygon.spec.pin;
|
||||
pub fn delete_poly(&mut self, poly_id: PolyId) {
|
||||
let poly = self.poly(poly_id);
|
||||
let bbox = poly.bbox();
|
||||
let component = poly.spec.component;
|
||||
let pin = poly.spec.pin;
|
||||
|
||||
if let Some(component_id) = component {
|
||||
self.components.modify(component_id.index(), |component| {
|
||||
if let Some(index) = component
|
||||
.polygons
|
||||
.polys
|
||||
.iter()
|
||||
.position(|&curr| curr == polygon_id)
|
||||
.position(|&curr| curr == poly_id)
|
||||
{
|
||||
component.polygons.remove(index);
|
||||
component.polys.remove(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(pin_id) = pin {
|
||||
self.pins.modify(pin_id.index(), |pin| {
|
||||
if let Some(index) = pin.polygons.iter().position(|&curr| curr == polygon_id) {
|
||||
pin.polygons.remove(index);
|
||||
if let Some(index) = pin.polys.iter().position(|&curr| curr == poly_id) {
|
||||
pin.polys.remove(index);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
self.polygons_rtree
|
||||
.remove(&GeomWithData::new(bbox.rtree_rectangle(), polygon_id));
|
||||
self.polygons.remove(&polygon_id.index());
|
||||
self.polys_rtree
|
||||
.remove(&GeomWithData::new(bbox.rtree_rectangle(), poly_id));
|
||||
self.polys.remove(&poly_id.index());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use crate::layout::primitives::PrimitiveId;
|
|||
|
||||
use super::Layout;
|
||||
use super::compounds::{ComponentId, NetId, PinId};
|
||||
use super::primitives::{JointId, PolygonId, SegmentId, ViaId};
|
||||
use super::primitives::{JointId, PolyId, SegId, ViaId};
|
||||
|
||||
#[derive(
|
||||
Clone, Copy, Constructor, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
||||
|
|
@ -43,9 +43,9 @@ mod sealed {
|
|||
pub trait IntoPrimitiveId: Into<PrimitiveId> {}
|
||||
|
||||
impl IntoPrimitiveId for JointId {}
|
||||
impl IntoPrimitiveId for SegmentId {}
|
||||
impl IntoPrimitiveId for SegId {}
|
||||
impl IntoPrimitiveId for ViaId {}
|
||||
impl IntoPrimitiveId for PolygonId {}
|
||||
impl IntoPrimitiveId for PolyId {}
|
||||
}
|
||||
|
||||
impl<T: sealed::IntoPrimitiveId, U: sealed::IntoPrimitiveId> From<Infringement<T, U>>
|
||||
|
|
@ -120,8 +120,8 @@ impl Layout {
|
|||
.iter()
|
||||
.copied()
|
||||
.flat_map(|joint_id| self.locate_joint_infringements(joint_id).map(Into::into));
|
||||
let segment_infringements = component.segments.iter().copied().flat_map(|segment_id| {
|
||||
self.locate_segment_infringements(segment_id)
|
||||
let seg_infringements = component.segs.iter().copied().flat_map(|seg_id| {
|
||||
self.locate_seg_infringements(seg_id)
|
||||
.map(Into::into)
|
||||
});
|
||||
let via_infringements = component
|
||||
|
|
@ -129,15 +129,15 @@ impl Layout {
|
|||
.iter()
|
||||
.copied()
|
||||
.flat_map(|via_id| self.locate_via_infringements(via_id).map(Into::into));
|
||||
let polygon_infringements = component.polygons.iter().copied().flat_map(|polygon_id| {
|
||||
self.locate_polygon_infringements(polygon_id)
|
||||
let poly_infringements = component.polys.iter().copied().flat_map(|poly_id| {
|
||||
self.locate_poly_infringements(poly_id)
|
||||
.map(Into::into)
|
||||
});
|
||||
|
||||
joint_infringements
|
||||
.chain(segment_infringements)
|
||||
.chain(seg_infringements)
|
||||
.chain(via_infringements)
|
||||
.chain(polygon_infringements)
|
||||
.chain(poly_infringements)
|
||||
}
|
||||
|
||||
pub fn locate_pin_infringements(
|
||||
|
|
@ -176,8 +176,8 @@ impl Layout {
|
|||
.iter()
|
||||
.copied()
|
||||
.flat_map(|joint_id| self.locate_joint_infringements(joint_id).map(Into::into))
|
||||
.chain(pin.segments.iter().copied().flat_map(|segment_id| {
|
||||
self.locate_segment_infringements(segment_id)
|
||||
.chain(pin.segs.iter().copied().flat_map(|seg_id| {
|
||||
self.locate_seg_infringements(seg_id)
|
||||
.map(Into::into)
|
||||
}))
|
||||
.chain(
|
||||
|
|
@ -186,8 +186,8 @@ impl Layout {
|
|||
.copied()
|
||||
.flat_map(|via_id| self.locate_via_infringements(via_id).map(Into::into)),
|
||||
)
|
||||
.chain(pin.polygons.iter().copied().flat_map(|polygon_id| {
|
||||
self.locate_polygon_infringements(polygon_id)
|
||||
.chain(pin.polys.iter().copied().flat_map(|poly_id| {
|
||||
self.locate_poly_infringements(poly_id)
|
||||
.map(Into::into)
|
||||
}))
|
||||
}
|
||||
|
|
@ -199,7 +199,7 @@ impl Layout {
|
|||
self.locate_joint_joint_infringements(infringer)
|
||||
.map(Into::into)
|
||||
.chain(
|
||||
self.locate_joint_segment_infringements(infringer)
|
||||
self.locate_joint_seg_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
.chain(
|
||||
|
|
@ -207,7 +207,7 @@ impl Layout {
|
|||
.map(Into::into),
|
||||
)
|
||||
.chain(
|
||||
self.locate_joint_polygon_infringements(infringer)
|
||||
self.locate_joint_poly_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
}
|
||||
|
|
@ -219,11 +219,11 @@ impl Layout {
|
|||
self.locate_same_infringements(infringer, self.joints_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_joint_segment_infringements(
|
||||
pub fn locate_joint_seg_infringements(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
) -> impl Iterator<Item = Infringement<JointId, SegmentId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.segments_rtree().as_ref())
|
||||
) -> impl Iterator<Item = Infringement<JointId, SegId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.segs_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_joint_via_infringements(
|
||||
|
|
@ -233,59 +233,59 @@ impl Layout {
|
|||
self.locate_cross_infringements(infringer, self.vias_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_joint_polygon_infringements(
|
||||
pub fn locate_joint_poly_infringements(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
) -> impl Iterator<Item = Infringement<JointId, PolygonId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.polygons_rtree().as_ref())
|
||||
) -> impl Iterator<Item = Infringement<JointId, PolyId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.polys_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_segment_infringements(
|
||||
pub fn locate_seg_infringements(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId>> + '_ {
|
||||
self.locate_segment_joint_infringements(infringer)
|
||||
infringer: SegId,
|
||||
) -> impl Iterator<Item = Infringement<SegId>> + '_ {
|
||||
self.locate_seg_joint_infringements(infringer)
|
||||
.map(Into::into)
|
||||
.chain(
|
||||
self.locate_segment_segment_infringements(infringer)
|
||||
self.locate_seg_seg_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
.chain(
|
||||
self.locate_segment_via_infringements(infringer)
|
||||
self.locate_seg_via_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
.chain(
|
||||
self.locate_segment_polygon_infringements(infringer)
|
||||
self.locate_seg_poly_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn locate_segment_joint_infringements(
|
||||
pub fn locate_seg_joint_infringements(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId, JointId>> + '_ {
|
||||
infringer: SegId,
|
||||
) -> impl Iterator<Item = Infringement<SegId, JointId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.joints_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_segment_segment_infringements(
|
||||
pub fn locate_seg_seg_infringements(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId, SegmentId>> + '_ {
|
||||
self.locate_same_infringements(infringer, self.segments_rtree().as_ref())
|
||||
infringer: SegId,
|
||||
) -> impl Iterator<Item = Infringement<SegId, SegId>> + '_ {
|
||||
self.locate_same_infringements(infringer, self.segs_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_segment_via_infringements(
|
||||
pub fn locate_seg_via_infringements(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId, ViaId>> + '_ {
|
||||
infringer: SegId,
|
||||
) -> impl Iterator<Item = Infringement<SegId, ViaId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.vias_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_segment_polygon_infringements(
|
||||
pub fn locate_seg_poly_infringements(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId, PolygonId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.polygons_rtree().as_ref())
|
||||
infringer: SegId,
|
||||
) -> impl Iterator<Item = Infringement<SegId, PolyId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.polys_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_via_infringements(
|
||||
|
|
@ -295,12 +295,12 @@ impl Layout {
|
|||
self.locate_via_joint_infringements(infringer)
|
||||
.map(Into::into)
|
||||
.chain(
|
||||
self.locate_via_segment_infringements(infringer)
|
||||
self.locate_via_seg_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
.chain(self.locate_via_via_infringements(infringer).map(Into::into))
|
||||
.chain(
|
||||
self.locate_via_polygon_infringements(infringer)
|
||||
self.locate_via_poly_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
}
|
||||
|
|
@ -312,11 +312,11 @@ impl Layout {
|
|||
self.locate_cross_infringements(infringer, self.joints_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_via_segment_infringements(
|
||||
pub fn locate_via_seg_infringements(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
) -> impl Iterator<Item = Infringement<ViaId, SegmentId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.segments_rtree().as_ref())
|
||||
) -> impl Iterator<Item = Infringement<ViaId, SegId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.segs_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_via_via_infringements(
|
||||
|
|
@ -326,59 +326,59 @@ impl Layout {
|
|||
self.locate_same_infringements(infringer, self.vias_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_via_polygon_infringements(
|
||||
pub fn locate_via_poly_infringements(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
) -> impl Iterator<Item = Infringement<ViaId, PolygonId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.polygons_rtree().as_ref())
|
||||
) -> impl Iterator<Item = Infringement<ViaId, PolyId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.polys_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_polygon_infringements(
|
||||
pub fn locate_poly_infringements(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId>> + '_ {
|
||||
self.locate_polygon_joint_infringements(infringer)
|
||||
infringer: PolyId,
|
||||
) -> impl Iterator<Item = Infringement<PolyId>> + '_ {
|
||||
self.locate_poly_joint_infringements(infringer)
|
||||
.map(Into::into)
|
||||
.chain(
|
||||
self.locate_polygon_segment_infringements(infringer)
|
||||
self.locate_poly_seg_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
.chain(
|
||||
self.locate_polygon_via_infringements(infringer)
|
||||
self.locate_poly_via_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
.chain(
|
||||
self.locate_polygon_polygon_infringements(infringer)
|
||||
self.locate_poly_poly_infringements(infringer)
|
||||
.map(Into::into),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn locate_polygon_joint_infringements(
|
||||
pub fn locate_poly_joint_infringements(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId, JointId>> + '_ {
|
||||
infringer: PolyId,
|
||||
) -> impl Iterator<Item = Infringement<PolyId, JointId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.joints_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_polygon_segment_infringements(
|
||||
pub fn locate_poly_seg_infringements(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId, SegmentId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.segments_rtree().as_ref())
|
||||
infringer: PolyId,
|
||||
) -> impl Iterator<Item = Infringement<PolyId, SegId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.segs_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_polygon_via_infringements(
|
||||
pub fn locate_poly_via_infringements(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId, ViaId>> + '_ {
|
||||
infringer: PolyId,
|
||||
) -> impl Iterator<Item = Infringement<PolyId, ViaId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.vias_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_polygon_polygon_infringements(
|
||||
pub fn locate_poly_poly_infringements(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId, PolygonId>> + '_ {
|
||||
self.locate_same_infringements(infringer, self.polygons_rtree().as_ref())
|
||||
infringer: PolyId,
|
||||
) -> impl Iterator<Item = Infringement<PolyId, PolyId>> + '_ {
|
||||
self.locate_same_infringements(infringer, self.polys_rtree().as_ref())
|
||||
}
|
||||
|
||||
fn locate_cross_infringements<
|
||||
|
|
@ -429,27 +429,27 @@ impl Layout {
|
|||
fn primitive_component(&self, primitive: PrimitiveId) -> Option<ComponentId> {
|
||||
match primitive {
|
||||
PrimitiveId::Joint(joint_id) => self.joint(joint_id).spec.component,
|
||||
PrimitiveId::Segment(segment_id) => self.segment(segment_id).spec.component,
|
||||
PrimitiveId::Seg(seg_id) => self.seg(seg_id).spec.component,
|
||||
PrimitiveId::Via(via_id) => self.via(via_id).spec.component,
|
||||
PrimitiveId::Polygon(polygon_id) => self.polygon(polygon_id).spec.component,
|
||||
PrimitiveId::Poly(poly_id) => self.poly(poly_id).spec.component,
|
||||
}
|
||||
}
|
||||
|
||||
fn primitive_bbox_envelope(&self, primitive: PrimitiveId) -> AABB<[i64; 3]> {
|
||||
match primitive {
|
||||
PrimitiveId::Joint(joint_id) => self.joint(joint_id).bbox().aabb(),
|
||||
PrimitiveId::Segment(segment_id) => self.segment(segment_id).bbox().aabb(),
|
||||
PrimitiveId::Seg(seg_id) => self.seg(seg_id).bbox().aabb(),
|
||||
PrimitiveId::Via(via_id) => self.via(via_id).bbox().aabb(),
|
||||
PrimitiveId::Polygon(polygon_id) => self.polygon(polygon_id).bbox().aabb(),
|
||||
PrimitiveId::Poly(poly_id) => self.poly(poly_id).bbox().aabb(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn primitive_net(&self, primitive: PrimitiveId) -> Option<NetId> {
|
||||
match primitive {
|
||||
PrimitiveId::Joint(joint_id) => self.joint(joint_id).spec.net,
|
||||
PrimitiveId::Segment(segment_id) => self.segment(segment_id).net,
|
||||
PrimitiveId::Seg(seg_id) => self.seg(seg_id).net,
|
||||
PrimitiveId::Via(via_id) => self.via(via_id).net,
|
||||
PrimitiveId::Polygon(polygon_id) => self.polygon(polygon_id).spec.net,
|
||||
PrimitiveId::Poly(poly_id) => self.poly(poly_id).spec.net,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::layout::{
|
|||
Layout,
|
||||
compounds::{Component, ComponentId, Pin, PinId, PinSpec},
|
||||
primitives::{
|
||||
Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId,
|
||||
Joint, JointId, JointSpec, Poly, PolyId, Seg, SegId, SegSpec, Via, ViaId,
|
||||
ViaSpec,
|
||||
},
|
||||
};
|
||||
|
|
@ -59,8 +59,8 @@ impl Layout {
|
|||
joint_id
|
||||
}
|
||||
|
||||
pub fn insert_segment(&mut self, spec: SegmentSpec) -> SegmentId {
|
||||
self.insert_segment_raw(Segment {
|
||||
pub fn insert_seg(&mut self, spec: SegSpec) -> SegId {
|
||||
self.insert_seg_raw(Seg {
|
||||
spec,
|
||||
endpoints: [
|
||||
self.joint(spec.endjoints[0]).spec.position,
|
||||
|
|
@ -71,36 +71,36 @@ impl Layout {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn insert_segment_raw(&mut self, segment: Segment) -> SegmentId {
|
||||
let component_id = segment.spec.component;
|
||||
let pin_id = segment.spec.pin;
|
||||
let bbox = segment.bbox();
|
||||
let segment_id = SegmentId::new(self.segments.push(segment));
|
||||
pub fn insert_seg_raw(&mut self, seg: Seg) -> SegId {
|
||||
let component_id = seg.spec.component;
|
||||
let pin_id = seg.spec.pin;
|
||||
let bbox = seg.bbox();
|
||||
let seg_id = SegId::new(self.segs.push(seg));
|
||||
|
||||
self.joints
|
||||
.modify(segment.spec.endjoints[0].index(), |joint| {
|
||||
joint.segments.push(segment_id)
|
||||
.modify(seg.spec.endjoints[0].index(), |joint| {
|
||||
joint.segs.push(seg_id)
|
||||
});
|
||||
self.joints
|
||||
.modify(segment.spec.endjoints[1].index(), |joint| {
|
||||
joint.segments.push(segment_id)
|
||||
.modify(seg.spec.endjoints[1].index(), |joint| {
|
||||
joint.segs.push(seg_id)
|
||||
});
|
||||
|
||||
self.segments_rtree
|
||||
.insert(GeomWithData::new(bbox.rtree_rectangle(), segment_id), ());
|
||||
self.segs_rtree
|
||||
.insert(GeomWithData::new(bbox.rtree_rectangle(), seg_id), ());
|
||||
|
||||
if let Some(component_id) = component_id {
|
||||
self.components.modify(component_id.index(), |component| {
|
||||
component.segments.push(segment_id)
|
||||
component.segs.push(seg_id)
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(pin_id) = pin_id {
|
||||
self.pins
|
||||
.modify(pin_id.index(), |pin| pin.segments.push(segment_id));
|
||||
.modify(pin_id.index(), |pin| pin.segs.push(seg_id));
|
||||
}
|
||||
|
||||
segment_id
|
||||
seg_id
|
||||
}
|
||||
|
||||
pub fn insert_via(&mut self, spec: ViaSpec) -> ViaId {
|
||||
|
|
@ -145,26 +145,26 @@ impl Layout {
|
|||
via_id
|
||||
}
|
||||
|
||||
pub fn insert_polygon(&mut self, polygon: Polygon) -> PolygonId {
|
||||
let bbox = polygon.bbox();
|
||||
let component_id = polygon.spec.component;
|
||||
let pin_id = polygon.spec.pin;
|
||||
let polygon_id = PolygonId::new(self.polygons.push(polygon));
|
||||
pub fn insert_poly(&mut self, poly: Poly) -> PolyId {
|
||||
let bbox = poly.bbox();
|
||||
let component_id = poly.spec.component;
|
||||
let pin_id = poly.spec.pin;
|
||||
let poly_id = PolyId::new(self.polys.push(poly));
|
||||
|
||||
self.polygons_rtree
|
||||
.insert(GeomWithData::new(bbox.rtree_rectangle(), polygon_id), ());
|
||||
self.polys_rtree
|
||||
.insert(GeomWithData::new(bbox.rtree_rectangle(), poly_id), ());
|
||||
|
||||
if let Some(component_id) = component_id {
|
||||
self.components.modify(component_id.index(), |component| {
|
||||
component.polygons.push(polygon_id)
|
||||
component.polys.push(poly_id)
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(pin_id) = pin_id {
|
||||
self.pins
|
||||
.modify(pin_id.index(), |pin| pin.polygons.push(polygon_id));
|
||||
.modify(pin_id.index(), |pin| pin.polys.push(poly_id));
|
||||
}
|
||||
|
||||
polygon_id
|
||||
poly_id
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use crate::{
|
|||
layout::{
|
||||
Layout,
|
||||
compounds::NetId,
|
||||
primitives::{JointId, PolygonId, SegmentId, ViaId},
|
||||
primitives::{JointId, PolyId, SegId, ViaId},
|
||||
},
|
||||
rect::{Rect2, Rect3},
|
||||
vector::{Vector2, Vector3},
|
||||
|
|
@ -144,53 +144,53 @@ impl Layout {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn locate_segments_prefer_layer_at_point(
|
||||
pub fn locate_segs_prefer_layer_at_point(
|
||||
&self,
|
||||
point: Vector3<i64>,
|
||||
) -> impl Iterator<Item = SegmentId> {
|
||||
let at_point = self.locate_segments_at_point(point).collect::<Vec<_>>();
|
||||
) -> impl Iterator<Item = SegId> {
|
||||
let at_point = self.locate_segs_at_point(point).collect::<Vec<_>>();
|
||||
|
||||
let segments = if at_point.is_empty() {
|
||||
self.locate_segments_any_layer_at_point(point.xy())
|
||||
let segs = if at_point.is_empty() {
|
||||
self.locate_segs_any_layer_at_point(point.xy())
|
||||
.collect()
|
||||
} else {
|
||||
at_point
|
||||
};
|
||||
|
||||
segments.into_iter()
|
||||
segs.into_iter()
|
||||
}
|
||||
|
||||
pub fn locate_segments_at_point(&self, point: Vector3<i64>) -> impl Iterator<Item = SegmentId> {
|
||||
self.segments_rtree
|
||||
pub fn locate_segs_at_point(&self, point: Vector3<i64>) -> impl Iterator<Item = SegId> {
|
||||
self.segs_rtree
|
||||
.as_ref()
|
||||
.locate_all_at_point(&[point.x, point.y, point.z])
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&segment_id| self.segment(segment_id).contains_point2(point.xy()))
|
||||
.filter(move |&seg_id| self.seg(seg_id).contains_point2(point.xy()))
|
||||
}
|
||||
|
||||
pub fn locate_segments_any_layer_at_point(
|
||||
pub fn locate_segs_any_layer_at_point(
|
||||
&self,
|
||||
point: Vector2<i64>,
|
||||
) -> impl Iterator<Item = SegmentId> {
|
||||
) -> impl Iterator<Item = SegId> {
|
||||
let envelope = point.z_extruded_infinitely().aabb();
|
||||
|
||||
self.segments_rtree
|
||||
self.segs_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope_intersecting(&envelope)
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&segment_id| self.segments[segment_id.index()].contains_point2(point))
|
||||
.filter(move |&seg_id| self.segs[seg_id.index()].contains_point2(point))
|
||||
}
|
||||
|
||||
pub fn locate_segments_prefer_layer_intersecting_rect(
|
||||
pub fn locate_segs_prefer_layer_intersecting_rect(
|
||||
&self,
|
||||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = SegmentId> {
|
||||
) -> impl Iterator<Item = SegId> {
|
||||
let at_point = self
|
||||
.locate_segments_intersecting_rect(rect)
|
||||
.locate_segs_intersecting_rect(rect)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let joints = if at_point.is_empty() {
|
||||
self.locate_segments_any_layer_intersecting_rect(rect.xy())
|
||||
self.locate_segs_any_layer_intersecting_rect(rect.xy())
|
||||
.collect()
|
||||
} else {
|
||||
at_point
|
||||
|
|
@ -199,44 +199,44 @@ impl Layout {
|
|||
joints.into_iter()
|
||||
}
|
||||
|
||||
pub fn locate_segments_intersecting_rect(
|
||||
pub fn locate_segs_intersecting_rect(
|
||||
&self,
|
||||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = SegmentId> {
|
||||
self.segments_rtree
|
||||
) -> impl Iterator<Item = SegId> {
|
||||
self.segs_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope_intersecting(&rect.aabb())
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&segment_id| {
|
||||
let segment = self.segment(segment_id);
|
||||
rect.xy().intersects_polygon(&segment.bounding_rectangle())
|
||||
.filter(move |&seg_id| {
|
||||
let seg = self.seg(seg_id);
|
||||
rect.xy().intersects_poly(&seg.bounding_rectangle())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn locate_segments_any_layer_intersecting_rect(
|
||||
pub fn locate_segs_any_layer_intersecting_rect(
|
||||
&self,
|
||||
rect: Rect2<i64>,
|
||||
) -> impl Iterator<Item = SegmentId> {
|
||||
) -> impl Iterator<Item = SegId> {
|
||||
let envelope = rect.z_extruded_infinitely().aabb();
|
||||
|
||||
self.segments_rtree
|
||||
self.segs_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope_intersecting(&envelope)
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&segment_id| {
|
||||
let segment = self.segment(segment_id);
|
||||
rect.intersects_polygon(&segment.bounding_rectangle())
|
||||
.filter(move |&seg_id| {
|
||||
let seg = self.seg(seg_id);
|
||||
rect.intersects_poly(&seg.bounding_rectangle())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn locate_segments_prefer_layer_inside_rect(
|
||||
pub fn locate_segs_prefer_layer_inside_rect(
|
||||
&self,
|
||||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = SegmentId> {
|
||||
let at_point = self.locate_segments_inside_rect(rect).collect::<Vec<_>>();
|
||||
) -> impl Iterator<Item = SegId> {
|
||||
let at_point = self.locate_segs_inside_rect(rect).collect::<Vec<_>>();
|
||||
|
||||
let joints = if at_point.is_empty() {
|
||||
self.locate_segments_any_layer_inside_rect(rect.xy())
|
||||
self.locate_segs_any_layer_inside_rect(rect.xy())
|
||||
.collect()
|
||||
} else {
|
||||
at_point
|
||||
|
|
@ -245,30 +245,30 @@ impl Layout {
|
|||
joints.into_iter()
|
||||
}
|
||||
|
||||
pub fn locate_segments_inside_rect(&self, rect: Rect3<i64>) -> impl Iterator<Item = SegmentId> {
|
||||
self.segments_rtree
|
||||
pub fn locate_segs_inside_rect(&self, rect: Rect3<i64>) -> impl Iterator<Item = SegId> {
|
||||
self.segs_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope(&rect.aabb())
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&segment_id| {
|
||||
let segment = self.segment(segment_id);
|
||||
rect.xy().contains_polygon(&segment.bounding_rectangle())
|
||||
.filter(move |&seg_id| {
|
||||
let seg = self.seg(seg_id);
|
||||
rect.xy().contains_poly(&seg.bounding_rectangle())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn locate_segments_any_layer_inside_rect(
|
||||
pub fn locate_segs_any_layer_inside_rect(
|
||||
&self,
|
||||
rect: Rect2<i64>,
|
||||
) -> impl Iterator<Item = SegmentId> {
|
||||
) -> impl Iterator<Item = SegId> {
|
||||
let envelope = rect.z_extruded_infinitely().aabb();
|
||||
|
||||
self.segments_rtree
|
||||
self.segs_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope(&envelope)
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&segment_id| {
|
||||
let segment = self.segment(segment_id);
|
||||
rect.contains_polygon(&segment.bounding_rectangle())
|
||||
.filter(move |&seg_id| {
|
||||
let seg = self.seg(seg_id);
|
||||
rect.contains_poly(&seg.bounding_rectangle())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -395,133 +395,133 @@ impl Layout {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn locate_polygons_prefer_layer_at_point(
|
||||
pub fn locate_polys_prefer_layer_at_point(
|
||||
&self,
|
||||
point: Vector3<i64>,
|
||||
) -> impl Iterator<Item = PolygonId> {
|
||||
let at_point = self.locate_polygons_at_point(point).collect::<Vec<_>>();
|
||||
) -> impl Iterator<Item = PolyId> {
|
||||
let at_point = self.locate_polys_at_point(point).collect::<Vec<_>>();
|
||||
|
||||
let polygons = if at_point.is_empty() {
|
||||
self.locate_polygons_any_layer_at_point(point.xy())
|
||||
let polys = if at_point.is_empty() {
|
||||
self.locate_polys_any_layer_at_point(point.xy())
|
||||
.collect()
|
||||
} else {
|
||||
at_point
|
||||
};
|
||||
|
||||
polygons.into_iter()
|
||||
polys.into_iter()
|
||||
}
|
||||
|
||||
pub fn locate_polygons_at_point(&self, point: Vector3<i64>) -> impl Iterator<Item = PolygonId> {
|
||||
self.polygons_rtree
|
||||
pub fn locate_polys_at_point(&self, point: Vector3<i64>) -> impl Iterator<Item = PolyId> {
|
||||
self.polys_rtree
|
||||
.as_ref()
|
||||
.locate_all_at_point(&[point.x, point.y, point.z])
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&polygon_id| {
|
||||
self.polygons[polygon_id.index()].contains_point2(point.xy())
|
||||
.filter(move |&poly_id| {
|
||||
self.polys[poly_id.index()].contains_point2(point.xy())
|
||||
})
|
||||
}
|
||||
|
||||
pub fn locate_polygons_any_layer_at_point(
|
||||
pub fn locate_polys_any_layer_at_point(
|
||||
&self,
|
||||
point: Vector2<i64>,
|
||||
) -> impl Iterator<Item = PolygonId> {
|
||||
) -> impl Iterator<Item = PolyId> {
|
||||
let envelope = point.z_extruded_infinitely().aabb();
|
||||
|
||||
self.polygons_rtree
|
||||
self.polys_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope_intersecting(&envelope)
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&polygon_id| self.polygons[polygon_id.index()].contains_point2(point))
|
||||
.filter(move |&poly_id| self.polys[poly_id.index()].contains_point2(point))
|
||||
}
|
||||
|
||||
pub fn locate_polygons_prefer_layer_intersecting_rect(
|
||||
pub fn locate_polys_prefer_layer_intersecting_rect(
|
||||
&self,
|
||||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = PolygonId> {
|
||||
) -> impl Iterator<Item = PolyId> {
|
||||
let at_rect = self
|
||||
.locate_polygons_intersecting_rect(rect)
|
||||
.locate_polys_intersecting_rect(rect)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let polygons = if at_rect.is_empty() {
|
||||
self.locate_polygons_any_layer_intersecting_rect(rect.xy())
|
||||
let polys = if at_rect.is_empty() {
|
||||
self.locate_polys_any_layer_intersecting_rect(rect.xy())
|
||||
.collect()
|
||||
} else {
|
||||
at_rect
|
||||
};
|
||||
|
||||
polygons.into_iter()
|
||||
polys.into_iter()
|
||||
}
|
||||
|
||||
pub fn locate_polygons_intersecting_rect(
|
||||
pub fn locate_polys_intersecting_rect(
|
||||
&self,
|
||||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = PolygonId> {
|
||||
self.polygons_rtree
|
||||
) -> impl Iterator<Item = PolyId> {
|
||||
self.polys_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope_intersecting(&rect.aabb())
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&polygon_id| {
|
||||
let polygon = self.polygon(polygon_id);
|
||||
rect.xy().intersects_polygon(&polygon.spec.vertices)
|
||||
.filter(move |&poly_id| {
|
||||
let poly = self.poly(poly_id);
|
||||
rect.xy().intersects_poly(&poly.spec.vertices)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn locate_polygons_any_layer_intersecting_rect(
|
||||
pub fn locate_polys_any_layer_intersecting_rect(
|
||||
&self,
|
||||
rect: Rect2<i64>,
|
||||
) -> impl Iterator<Item = PolygonId> {
|
||||
) -> impl Iterator<Item = PolyId> {
|
||||
let envelope = rect.z_extruded_infinitely().aabb();
|
||||
|
||||
self.polygons_rtree
|
||||
self.polys_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope_intersecting(&envelope)
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&polygon_id| {
|
||||
let polygon = self.polygon(polygon_id);
|
||||
rect.intersects_polygon(&polygon.spec.vertices)
|
||||
.filter(move |&poly_id| {
|
||||
let poly = self.poly(poly_id);
|
||||
rect.intersects_poly(&poly.spec.vertices)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn locate_polygons_prefer_layer_inside_rect(
|
||||
pub fn locate_polys_prefer_layer_inside_rect(
|
||||
&self,
|
||||
rect: Rect3<i64>,
|
||||
) -> impl Iterator<Item = PolygonId> {
|
||||
let at_rect = self.locate_polygons_inside_rect(rect).collect::<Vec<_>>();
|
||||
) -> impl Iterator<Item = PolyId> {
|
||||
let at_rect = self.locate_polys_inside_rect(rect).collect::<Vec<_>>();
|
||||
|
||||
let polygons = if at_rect.is_empty() {
|
||||
self.locate_polygons_any_layer_inside_rect(rect.xy())
|
||||
let polys = if at_rect.is_empty() {
|
||||
self.locate_polys_any_layer_inside_rect(rect.xy())
|
||||
.collect()
|
||||
} else {
|
||||
at_rect
|
||||
};
|
||||
|
||||
polygons.into_iter()
|
||||
polys.into_iter()
|
||||
}
|
||||
|
||||
pub fn locate_polygons_inside_rect(&self, rect: Rect3<i64>) -> impl Iterator<Item = PolygonId> {
|
||||
self.polygons_rtree
|
||||
pub fn locate_polys_inside_rect(&self, rect: Rect3<i64>) -> impl Iterator<Item = PolyId> {
|
||||
self.polys_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope(&rect.aabb())
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&polygon_id| {
|
||||
let polygon = self.polygon(polygon_id);
|
||||
rect.xy().contains_polygon(&polygon.spec.vertices)
|
||||
.filter(move |&poly_id| {
|
||||
let poly = self.poly(poly_id);
|
||||
rect.xy().contains_poly(&poly.spec.vertices)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn locate_polygons_any_layer_inside_rect(
|
||||
pub fn locate_polys_any_layer_inside_rect(
|
||||
&self,
|
||||
rect: Rect2<i64>,
|
||||
) -> impl Iterator<Item = PolygonId> {
|
||||
) -> impl Iterator<Item = PolyId> {
|
||||
let envelope = rect.z_extruded_infinitely().aabb();
|
||||
|
||||
self.polygons_rtree
|
||||
self.polys_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope(&envelope)
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&polygon_id| {
|
||||
let polygon = self.polygon(polygon_id);
|
||||
rect.contains_polygon(&polygon.spec.vertices)
|
||||
.filter(move |&poly_id| {
|
||||
let poly = self.poly(poly_id);
|
||||
rect.contains_poly(&poly.spec.vertices)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -537,8 +537,8 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
for segment_id in self.locate_segments_prefer_layer_intersecting_rect(rect) {
|
||||
if let Some(net) = self.segment(segment_id).net {
|
||||
for seg_id in self.locate_segs_prefer_layer_intersecting_rect(rect) {
|
||||
if let Some(net) = self.seg(seg_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
|
@ -549,8 +549,8 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
for polygon_id in self.locate_polygons_prefer_layer_intersecting_rect(rect) {
|
||||
if let Some(net) = self.polygon(polygon_id).spec.net {
|
||||
for poly_id in self.locate_polys_prefer_layer_intersecting_rect(rect) {
|
||||
if let Some(net) = self.poly(poly_id).spec.net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
|
@ -567,8 +567,8 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
for segment_id in self.locate_segments_intersecting_rect(rect) {
|
||||
if let Some(net) = self.segment(segment_id).net {
|
||||
for seg_id in self.locate_segs_intersecting_rect(rect) {
|
||||
if let Some(net) = self.seg(seg_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
|
@ -579,8 +579,8 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
for polygon_id in self.locate_polygons_intersecting_rect(rect) {
|
||||
if let Some(net) = self.polygon(polygon_id).spec.net {
|
||||
for poly_id in self.locate_polys_intersecting_rect(rect) {
|
||||
if let Some(net) = self.poly(poly_id).spec.net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
|
@ -600,8 +600,8 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
for segment_id in self.locate_segments_prefer_layer_inside_rect(rect) {
|
||||
if let Some(net) = self.segment(segment_id).net {
|
||||
for seg_id in self.locate_segs_prefer_layer_inside_rect(rect) {
|
||||
if let Some(net) = self.seg(seg_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
|
@ -612,8 +612,8 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
for polygon_id in self.locate_polygons_prefer_layer_inside_rect(rect) {
|
||||
if let Some(net) = self.polygon(polygon_id).spec.net {
|
||||
for poly_id in self.locate_polys_prefer_layer_inside_rect(rect) {
|
||||
if let Some(net) = self.poly(poly_id).spec.net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
|
@ -630,8 +630,8 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
for segment_id in self.locate_segments_inside_rect(rect) {
|
||||
if let Some(net) = self.segment(segment_id).net {
|
||||
for seg_id in self.locate_segs_inside_rect(rect) {
|
||||
if let Some(net) = self.seg(seg_id).net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
|
@ -642,8 +642,8 @@ impl Layout {
|
|||
}
|
||||
}
|
||||
|
||||
for polygon_id in self.locate_polygons_inside_rect(rect) {
|
||||
if let Some(net) = self.polygon(polygon_id).spec.net {
|
||||
for poly_id in self.locate_polys_inside_rect(rect) {
|
||||
if let Some(net) = self.poly(poly_id).spec.net {
|
||||
nets.insert(net);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use undoredo::{Delta, Recorder};
|
|||
use crate::{
|
||||
layout::{
|
||||
compounds::{Component, ComponentId, Net, Pin, PinId},
|
||||
primitives::{Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Via, ViaId},
|
||||
primitives::{Joint, JointId, Poly, PolyId, Seg, SegId, Via, ViaId},
|
||||
},
|
||||
vector::Vector2,
|
||||
};
|
||||
|
|
@ -72,25 +72,25 @@ pub struct Layout {
|
|||
pins: Recorder<StableVec<Pin>>,
|
||||
|
||||
joints: Recorder<StableVec<Joint>>,
|
||||
segments: Recorder<StableVec<Segment>>,
|
||||
segs: Recorder<StableVec<Seg>>,
|
||||
vias: Recorder<StableVec<Via>>,
|
||||
polygons: Recorder<StableVec<Polygon>>,
|
||||
polys: Recorder<StableVec<Poly>>,
|
||||
|
||||
joints_rtree: Recorder<
|
||||
RTree<GeomWithData<Rectangle<[i64; 3]>, JointId>>,
|
||||
RTreeHalfDelta<GeomWithData<Rectangle<[i64; 3]>, JointId>>,
|
||||
>,
|
||||
segments_rtree: Recorder<
|
||||
RTree<GeomWithData<Rectangle<[i64; 3]>, SegmentId>>,
|
||||
RTreeHalfDelta<GeomWithData<Rectangle<[i64; 3]>, SegmentId>>,
|
||||
segs_rtree: Recorder<
|
||||
RTree<GeomWithData<Rectangle<[i64; 3]>, SegId>>,
|
||||
RTreeHalfDelta<GeomWithData<Rectangle<[i64; 3]>, SegId>>,
|
||||
>,
|
||||
vias_rtree: Recorder<
|
||||
RTree<GeomWithData<Rectangle<[i64; 3]>, ViaId>>,
|
||||
RTreeHalfDelta<GeomWithData<Rectangle<[i64; 3]>, ViaId>>,
|
||||
>,
|
||||
polygons_rtree: Recorder<
|
||||
RTree<GeomWithData<Rectangle<[i64; 3]>, PolygonId>>,
|
||||
RTreeHalfDelta<GeomWithData<Rectangle<[i64; 3]>, PolygonId>>,
|
||||
polys_rtree: Recorder<
|
||||
RTree<GeomWithData<Rectangle<[i64; 3]>, PolyId>>,
|
||||
RTreeHalfDelta<GeomWithData<Rectangle<[i64; 3]>, PolyId>>,
|
||||
>,
|
||||
}
|
||||
|
||||
|
|
@ -111,14 +111,14 @@ impl Layout {
|
|||
pins: Recorder::new(StableVec::new()),
|
||||
|
||||
joints: Recorder::new(StableVec::new()),
|
||||
segments: Recorder::new(StableVec::new()),
|
||||
segs: Recorder::new(StableVec::new()),
|
||||
vias: Recorder::new(StableVec::new()),
|
||||
polygons: Recorder::new(StableVec::new()),
|
||||
polys: Recorder::new(StableVec::new()),
|
||||
|
||||
joints_rtree: Recorder::new(RTree::new()),
|
||||
segments_rtree: Recorder::new(RTree::new()),
|
||||
segs_rtree: Recorder::new(RTree::new()),
|
||||
vias_rtree: Recorder::new(RTree::new()),
|
||||
polygons_rtree: Recorder::new(RTree::new()),
|
||||
polys_rtree: Recorder::new(RTree::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -131,13 +131,13 @@ impl Layout {
|
|||
.filter(move |&id| self.joint(id).spec.layer == layer)
|
||||
}
|
||||
|
||||
pub fn layer_segments(&self, layer: LayerId) -> impl Iterator<Item = SegmentId> + '_ {
|
||||
pub fn layer_segs(&self, layer: LayerId) -> impl Iterator<Item = SegId> + '_ {
|
||||
let envelope = Self::whole_layer_aabb(layer);
|
||||
self.segments_rtree
|
||||
self.segs_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope_intersecting(&envelope)
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&id| self.segment(id).layer == layer)
|
||||
.filter(move |&id| self.seg(id).layer == layer)
|
||||
}
|
||||
|
||||
pub fn layer_vias(&self, layer: LayerId) -> impl Iterator<Item = ViaId> + '_ {
|
||||
|
|
@ -152,13 +152,13 @@ impl Layout {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn layer_polygons(&self, layer: LayerId) -> impl Iterator<Item = PolygonId> + '_ {
|
||||
pub fn layer_polys(&self, layer: LayerId) -> impl Iterator<Item = PolyId> + '_ {
|
||||
let envelope = Self::whole_layer_aabb(layer);
|
||||
self.polygons_rtree
|
||||
self.polys_rtree
|
||||
.as_ref()
|
||||
.locate_in_envelope_intersecting(&envelope)
|
||||
.map(|geom_with_data| geom_with_data.data)
|
||||
.filter(move |&id| self.polygon(id).spec.layer == layer)
|
||||
.filter(move |&id| self.poly(id).spec.layer == layer)
|
||||
}
|
||||
|
||||
fn whole_layer_aabb(layer: LayerId) -> AABB<[i64; 3]> {
|
||||
|
|
@ -180,15 +180,15 @@ impl Layout {
|
|||
&self.joints[joint_id.index()]
|
||||
}
|
||||
|
||||
pub fn segment(&self, segment_id: SegmentId) -> &Segment {
|
||||
&self.segments[segment_id.index()]
|
||||
pub fn seg(&self, seg_id: SegId) -> &Seg {
|
||||
&self.segs[seg_id.index()]
|
||||
}
|
||||
|
||||
pub fn via(&self, via_id: ViaId) -> &Via {
|
||||
&self.vias[via_id.index()]
|
||||
}
|
||||
|
||||
pub fn polygon(&self, polygon_id: PolygonId) -> &Polygon {
|
||||
&self.polygons[polygon_id.index()]
|
||||
pub fn poly(&self, poly_id: PolyId) -> &Poly {
|
||||
&self.polys[poly_id.index()]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use rstar::primitives::GeomWithData;
|
|||
use crate::layout::{
|
||||
Layout,
|
||||
primitives::{
|
||||
Joint, JointId, JointSpec, Polygon, PolygonId, SegmentId, SegmentSpec, ViaId, ViaSpec,
|
||||
Joint, JointId, JointSpec, Poly, PolyId, SegId, SegSpec, ViaId, ViaSpec,
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -19,8 +19,8 @@ impl Layout {
|
|||
self.modify_joint_raw(id, |joint| f(&mut joint.spec));
|
||||
let new_joint = self.joints[id.index()].clone();
|
||||
|
||||
for &segment_id in &new_joint.segments {
|
||||
self.update_segment(segment_id);
|
||||
for &seg_id in &new_joint.segs {
|
||||
self.update_seg(seg_id);
|
||||
}
|
||||
|
||||
for &via_id in &new_joint.vias {
|
||||
|
|
@ -45,43 +45,43 @@ impl Layout {
|
|||
);
|
||||
}
|
||||
|
||||
pub fn modify_segment<F>(&mut self, id: SegmentId, f: F)
|
||||
pub fn modify_seg<F>(&mut self, id: SegId, f: F)
|
||||
where
|
||||
F: FnOnce(&mut SegmentSpec),
|
||||
F: FnOnce(&mut SegSpec),
|
||||
{
|
||||
let old_segment = &self.segments[id.index()];
|
||||
self.segments_rtree
|
||||
.remove(&GeomWithData::new(old_segment.bbox().rtree_rectangle(), id));
|
||||
let old_seg = &self.segs[id.index()];
|
||||
self.segs_rtree
|
||||
.remove(&GeomWithData::new(old_seg.bbox().rtree_rectangle(), id));
|
||||
|
||||
self.segments
|
||||
.modify(id.index(), |segment| f(&mut segment.spec));
|
||||
self.segs
|
||||
.modify(id.index(), |seg| f(&mut seg.spec));
|
||||
|
||||
let new_segment = &self.segments[id.index()];
|
||||
self.segments_rtree.insert(
|
||||
GeomWithData::new(new_segment.bbox().rtree_rectangle(), id),
|
||||
let new_seg = &self.segs[id.index()];
|
||||
self.segs_rtree.insert(
|
||||
GeomWithData::new(new_seg.bbox().rtree_rectangle(), id),
|
||||
(),
|
||||
);
|
||||
}
|
||||
|
||||
pub(super) fn update_segment(&mut self, id: SegmentId) {
|
||||
let old_segment = &self.segments[id.index()];
|
||||
self.segments_rtree
|
||||
.remove(&GeomWithData::new(old_segment.bbox().rtree_rectangle(), id));
|
||||
pub(super) fn update_seg(&mut self, id: SegId) {
|
||||
let old_seg = &self.segs[id.index()];
|
||||
self.segs_rtree
|
||||
.remove(&GeomWithData::new(old_seg.bbox().rtree_rectangle(), id));
|
||||
|
||||
let endjoint_ids = old_segment.spec.endjoints;
|
||||
let endjoint_ids = old_seg.spec.endjoints;
|
||||
let endjoint_specs = [
|
||||
self.joints[endjoint_ids[0].index()].spec,
|
||||
self.joints[endjoint_ids[1].index()].spec,
|
||||
];
|
||||
self.segments.modify(id.index(), |segment| {
|
||||
segment.endpoints = [endjoint_specs[0].position, endjoint_specs[1].position];
|
||||
segment.layer = endjoint_specs[0].layer;
|
||||
segment.net = endjoint_specs[0].net;
|
||||
self.segs.modify(id.index(), |seg| {
|
||||
seg.endpoints = [endjoint_specs[0].position, endjoint_specs[1].position];
|
||||
seg.layer = endjoint_specs[0].layer;
|
||||
seg.net = endjoint_specs[0].net;
|
||||
});
|
||||
|
||||
let new_segment = &self.segments[id.index()];
|
||||
self.segments_rtree.insert(
|
||||
GeomWithData::new(new_segment.bbox().rtree_rectangle(), id),
|
||||
let new_seg = &self.segs[id.index()];
|
||||
self.segs_rtree.insert(
|
||||
GeomWithData::new(new_seg.bbox().rtree_rectangle(), id),
|
||||
(),
|
||||
);
|
||||
}
|
||||
|
|
@ -123,19 +123,19 @@ impl Layout {
|
|||
.insert(GeomWithData::new(new_via.bbox().rtree_rectangle(), id), ());
|
||||
}
|
||||
|
||||
pub fn modify_polygon<F>(&mut self, id: PolygonId, f: F)
|
||||
pub fn modify_poly<F>(&mut self, id: PolyId, f: F)
|
||||
where
|
||||
F: FnOnce(&mut Polygon),
|
||||
F: FnOnce(&mut Poly),
|
||||
{
|
||||
let old_polygon = &self.polygons[id.index()];
|
||||
self.polygons_rtree
|
||||
.remove(&GeomWithData::new(old_polygon.bbox().rtree_rectangle(), id));
|
||||
let old_poly = &self.polys[id.index()];
|
||||
self.polys_rtree
|
||||
.remove(&GeomWithData::new(old_poly.bbox().rtree_rectangle(), id));
|
||||
|
||||
self.polygons.modify(id.index(), |polygon| f(polygon));
|
||||
self.polys.modify(id.index(), |poly| f(poly));
|
||||
|
||||
let new_polygon = &self.polygons[id.index()];
|
||||
self.polygons_rtree.insert(
|
||||
GeomWithData::new(new_polygon.bbox().rtree_rectangle(), id),
|
||||
let new_poly = &self.polys[id.index()];
|
||||
self.polys_rtree.insert(
|
||||
GeomWithData::new(new_poly.bbox().rtree_rectangle(), id),
|
||||
(),
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
Rect2,
|
||||
layout::{
|
||||
Layout,
|
||||
primitives::{JointId, PolygonId, SegmentId, ViaId},
|
||||
primitives::{JointId, PolyId, SegId, ViaId},
|
||||
},
|
||||
};
|
||||
|
||||
|
|
@ -22,13 +22,13 @@ impl Layout {
|
|||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn joint_segment_rect_overlap(
|
||||
pub fn joint_seg_rect_overlap(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
infringee: SegmentId,
|
||||
infringee: SegId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.segment(infringee).bbox().xy();
|
||||
let infringee_bbox = self.seg(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -44,57 +44,57 @@ impl Layout {
|
|||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn joint_polygon_rect_overlap(
|
||||
pub fn joint_poly_rect_overlap(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
infringee: PolygonId,
|
||||
infringee: PolyId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.polygon(infringee).bbox().xy();
|
||||
let infringee_bbox = self.poly(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn segment_joint_rect_overlap(
|
||||
pub fn seg_joint_rect_overlap(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringer: SegId,
|
||||
infringee: JointId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.segment(infringer).bbox().xy();
|
||||
let infringer_bbox = self.seg(infringer).bbox().xy();
|
||||
let infringee_bbox = self.joint(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn segment_segment_rect_overlap(
|
||||
pub fn seg_seg_rect_overlap(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringee: SegmentId,
|
||||
infringer: SegId,
|
||||
infringee: SegId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.segment(infringee).bbox().xy();
|
||||
let infringer_bbox = self.seg(infringer).bbox().xy();
|
||||
let infringee_bbox = self.seg(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn segment_via_rect_overlap(
|
||||
pub fn seg_via_rect_overlap(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringer: SegId,
|
||||
infringee: ViaId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.segment(infringer).bbox().xy();
|
||||
let infringer_bbox = self.seg(infringer).bbox().xy();
|
||||
let infringee_bbox = self.via(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn segment_polygon_rect_overlap(
|
||||
pub fn seg_poly_rect_overlap(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringee: PolygonId,
|
||||
infringer: SegId,
|
||||
infringee: PolyId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.polygon(infringee).bbox().xy();
|
||||
let infringer_bbox = self.seg(infringer).bbox().xy();
|
||||
let infringee_bbox = self.poly(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -110,13 +110,13 @@ impl Layout {
|
|||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn via_segment_rect_overlap(
|
||||
pub fn via_seg_rect_overlap(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
infringee: SegmentId,
|
||||
infringee: SegId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.segment(infringee).bbox().xy();
|
||||
let infringee_bbox = self.seg(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -128,57 +128,57 @@ impl Layout {
|
|||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn via_polygon_rect_overlap(
|
||||
pub fn via_poly_rect_overlap(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
infringee: PolygonId,
|
||||
infringee: PolyId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.polygon(infringee).bbox().xy();
|
||||
let infringee_bbox = self.poly(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn polygon_joint_rect_overlap(
|
||||
pub fn poly_joint_rect_overlap(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringer: PolyId,
|
||||
infringee: JointId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.polygon(infringer).bbox().xy();
|
||||
let infringer_bbox = self.poly(infringer).bbox().xy();
|
||||
let infringee_bbox = self.joint(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn polygon_segment_rect_overlap(
|
||||
pub fn poly_seg_rect_overlap(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringee: SegmentId,
|
||||
infringer: PolyId,
|
||||
infringee: SegId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.segment(infringee).bbox().xy();
|
||||
let infringer_bbox = self.poly(infringer).bbox().xy();
|
||||
let infringee_bbox = self.seg(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn polygon_via_rect_overlap(
|
||||
pub fn poly_via_rect_overlap(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringer: PolyId,
|
||||
infringee: ViaId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.polygon(infringer).bbox().xy();
|
||||
let infringer_bbox = self.poly(infringer).bbox().xy();
|
||||
let infringee_bbox = self.via(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
||||
pub fn polygon_polygon_rect_overlap(
|
||||
pub fn poly_poly_rect_overlap(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringee: PolygonId,
|
||||
infringer: PolyId,
|
||||
infringee: PolyId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.polygon(infringee).bbox().xy();
|
||||
let infringer_bbox = self.poly(infringer).bbox().xy();
|
||||
let infringee_bbox = self.poly(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use derive_more::{Constructor, From};
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::layout::compounds::{ComponentId, NetId, PinId};
|
||||
use crate::layout::primitives::{SegmentId, ViaId};
|
||||
use crate::layout::primitives::{SegId, ViaId};
|
||||
use crate::vector::Vector2;
|
||||
use crate::{Rect3, Vector3, layout::LayerId};
|
||||
|
||||
|
|
@ -47,7 +47,7 @@ pub struct JointSpec {
|
|||
#[derive(Clone, Debug)]
|
||||
pub struct Joint {
|
||||
pub spec: JointSpec,
|
||||
pub segments: Vec<SegmentId>,
|
||||
pub segs: Vec<SegId>,
|
||||
pub vias: Vec<ViaId>,
|
||||
}
|
||||
|
||||
|
|
@ -55,7 +55,7 @@ impl Joint {
|
|||
pub fn new(spec: JointSpec) -> Self {
|
||||
Joint {
|
||||
spec,
|
||||
segments: Vec::new(),
|
||||
segs: Vec::new(),
|
||||
vias: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,13 +6,13 @@ use derive_more::From;
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
mod joint;
|
||||
mod polygon;
|
||||
mod segment;
|
||||
mod poly;
|
||||
mod seg;
|
||||
mod via;
|
||||
|
||||
pub use joint::*;
|
||||
pub use polygon::*;
|
||||
pub use segment::*;
|
||||
pub use poly::*;
|
||||
pub use seg::*;
|
||||
pub use via::*;
|
||||
|
||||
use crate::{
|
||||
|
|
@ -23,27 +23,27 @@ use crate::{
|
|||
#[derive(Clone, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub enum PrimitiveId {
|
||||
Joint(JointId),
|
||||
Segment(SegmentId),
|
||||
Seg(SegId),
|
||||
Via(ViaId),
|
||||
Polygon(PolygonId),
|
||||
Poly(PolyId),
|
||||
}
|
||||
|
||||
impl Layout {
|
||||
pub fn primitive_pin(&self, primitive: PrimitiveId) -> Option<PinId> {
|
||||
match primitive {
|
||||
PrimitiveId::Joint(joint_id) => self.joint(joint_id).spec.pin,
|
||||
PrimitiveId::Segment(segment_id) => self.segment(segment_id).spec.pin,
|
||||
PrimitiveId::Seg(seg_id) => self.seg(seg_id).spec.pin,
|
||||
PrimitiveId::Via(via_id) => self.via(via_id).spec.pin,
|
||||
PrimitiveId::Polygon(polygon_id) => self.polygon(polygon_id).spec.pin,
|
||||
PrimitiveId::Poly(poly_id) => self.poly(poly_id).spec.pin,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn primitive_bbox2(&self, primitive: PrimitiveId) -> Rect2<i64> {
|
||||
match primitive {
|
||||
PrimitiveId::Joint(joint_id) => self.joint(joint_id).bbox().xy(),
|
||||
PrimitiveId::Segment(segment_id) => self.segment(segment_id).bbox().xy(),
|
||||
PrimitiveId::Seg(seg_id) => self.seg(seg_id).bbox().xy(),
|
||||
PrimitiveId::Via(via_id) => self.via(via_id).bbox().xy(),
|
||||
PrimitiveId::Polygon(polygon_id) => self.polygon(polygon_id).bbox().xy(),
|
||||
PrimitiveId::Poly(poly_id) => self.poly(poly_id).bbox().xy(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,9 @@ use crate::{Rect3, Vector3, layout::LayerId};
|
|||
PartialOrd,
|
||||
Serialize,
|
||||
)]
|
||||
pub struct PolygonId(usize);
|
||||
pub struct PolyId(usize);
|
||||
|
||||
impl PolygonId {
|
||||
impl PolyId {
|
||||
/// Returns the underlying index.
|
||||
#[inline]
|
||||
pub fn index(self) -> usize {
|
||||
|
|
@ -34,7 +34,7 @@ impl PolygonId {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct PolygonSpec {
|
||||
pub struct PolySpec {
|
||||
pub vertices: Vec<Vector2<i64>>,
|
||||
pub layer: LayerId,
|
||||
pub net: Option<NetId>,
|
||||
|
|
@ -43,12 +43,19 @@ pub struct PolygonSpec {
|
|||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Polygon {
|
||||
pub spec: PolygonSpec,
|
||||
pub struct Poly {
|
||||
pub spec: PolySpec,
|
||||
pub centroid: Vector2<i64>,
|
||||
}
|
||||
|
||||
impl Polygon {
|
||||
impl Poly {
|
||||
pub fn new(spec: PolySpec) -> Self {
|
||||
Self {
|
||||
centroid: Vector2::<i64>::poly_centroid(&spec.vertices),
|
||||
spec,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn bbox(&self) -> Rect3<i64> {
|
||||
let layer = self.spec.layer.index() as i64;
|
||||
let mut min = Vector2::new(i64::MAX, i64::MAX);
|
||||
|
|
@ -9,7 +9,7 @@ use crate::layout::compounds::{ComponentId, NetId, PinId};
|
|||
use crate::vector::Vector2;
|
||||
use crate::{Rect3, Vector3, layout::LayerId};
|
||||
|
||||
use super::JointId;
|
||||
use super::{Joint, JointId};
|
||||
|
||||
#[derive(
|
||||
Clone,
|
||||
|
|
@ -25,9 +25,9 @@ use super::JointId;
|
|||
PartialOrd,
|
||||
Serialize,
|
||||
)]
|
||||
pub struct SegmentId(usize);
|
||||
pub struct SegId(usize);
|
||||
|
||||
impl SegmentId {
|
||||
impl SegId {
|
||||
/// Returns the underlying index.
|
||||
#[inline]
|
||||
pub fn index(self) -> usize {
|
||||
|
|
@ -36,7 +36,7 @@ impl SegmentId {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct SegmentSpec {
|
||||
pub struct SegSpec {
|
||||
pub endjoints: [JointId; 2],
|
||||
pub half_width: u64,
|
||||
pub component: Option<ComponentId>,
|
||||
|
|
@ -44,20 +44,29 @@ pub struct SegmentSpec {
|
|||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
pub struct Segment {
|
||||
pub spec: SegmentSpec,
|
||||
pub struct Seg {
|
||||
pub spec: SegSpec,
|
||||
pub endpoints: [Vector2<i64>; 2],
|
||||
pub layer: LayerId,
|
||||
pub net: Option<NetId>,
|
||||
}
|
||||
|
||||
impl Segment {
|
||||
impl Seg {
|
||||
pub fn new(spec: SegSpec, endjoints: [&Joint; 2]) -> Self {
|
||||
Self {
|
||||
spec,
|
||||
endpoints: [endjoints[0].spec.position, endjoints[1].spec.position],
|
||||
layer: endjoints[0].spec.layer,
|
||||
net: endjoints[0].spec.net,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn center(&self) -> Vector2<i64> {
|
||||
(self.endpoints[0] + self.endpoints[1]) / 2
|
||||
}
|
||||
|
||||
pub fn contains_point2(&self, point: Vector2<i64>) -> bool {
|
||||
let vertices = crate::math::inflated_segment(
|
||||
let vertices = crate::math::inflated_seg(
|
||||
self.endpoints[0].x,
|
||||
self.endpoints[0].y,
|
||||
self.endpoints[1].x,
|
||||
|
|
@ -70,7 +79,7 @@ impl Segment {
|
|||
/// NOTE: This is not the bounding box. The output rectangle is in general
|
||||
/// not axis-aligned.
|
||||
pub fn bounding_rectangle(&self) -> [Vector2<i64>; 4] {
|
||||
crate::math::inflated_segment(
|
||||
crate::math::inflated_seg(
|
||||
self.endpoints[0].x,
|
||||
self.endpoints[0].y,
|
||||
self.endpoints[1].x,
|
||||
|
|
@ -7,7 +7,7 @@ use crate::{
|
|||
layout::{
|
||||
Layout,
|
||||
compounds::{ComponentId, PinId},
|
||||
primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId},
|
||||
primitives::{JointId, PolyId, PrimitiveId, SegId, ViaId},
|
||||
},
|
||||
orientation::Orientation,
|
||||
rect::Rect2,
|
||||
|
|
@ -97,14 +97,14 @@ impl Layout {
|
|||
PrimitiveId::Joint(infringer) => {
|
||||
self.joint_primitive_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Segment(infringer) => {
|
||||
self.segment_primitive_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Seg(infringer) => {
|
||||
self.seg_primitive_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Via(infringer) => {
|
||||
self.via_primitive_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Polygon(infringer) => {
|
||||
self.polygon_primitive_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Poly(infringer) => {
|
||||
self.poly_primitive_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -123,16 +123,16 @@ impl Layout {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn joint_segment_repulsion(
|
||||
pub fn joint_seg_repulsion(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
infringee: SegmentId,
|
||||
infringee: SegId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.joint_segment_rect_overlap(infringer, infringee),
|
||||
self.joint_seg_rect_overlap(infringer, infringee),
|
||||
self.joint(infringer).center(),
|
||||
self.segment(infringee).center(),
|
||||
self.seg(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -151,16 +151,16 @@ impl Layout {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn joint_polygon_repulsion(
|
||||
pub fn joint_poly_repulsion(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
infringee: PolygonId,
|
||||
infringee: PolyId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.joint_polygon_rect_overlap(infringer, infringee),
|
||||
self.joint_poly_rect_overlap(infringer, infringee),
|
||||
self.joint(infringer).center(),
|
||||
self.polygon(infringee).centroid,
|
||||
self.poly(infringee).centroid,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -175,92 +175,92 @@ impl Layout {
|
|||
PrimitiveId::Joint(infringee) => {
|
||||
self.joint_joint_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Segment(infringee) => {
|
||||
self.joint_segment_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Seg(infringee) => {
|
||||
self.joint_seg_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Via(infringee) => {
|
||||
self.joint_via_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Polygon(infringee) => {
|
||||
self.joint_polygon_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Poly(infringee) => {
|
||||
self.joint_poly_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn segment_joint_repulsion(
|
||||
pub fn seg_joint_repulsion(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringer: SegId,
|
||||
infringee: JointId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.segment_joint_rect_overlap(infringer, infringee),
|
||||
self.segment(infringer).center(),
|
||||
self.seg_joint_rect_overlap(infringer, infringee),
|
||||
self.seg(infringer).center(),
|
||||
self.joint(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn segment_segment_repulsion(
|
||||
pub fn seg_seg_repulsion(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringee: SegmentId,
|
||||
infringer: SegId,
|
||||
infringee: SegId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.segment_segment_rect_overlap(infringer, infringee),
|
||||
self.segment(infringer).center(),
|
||||
self.segment(infringee).center(),
|
||||
self.seg_seg_rect_overlap(infringer, infringee),
|
||||
self.seg(infringer).center(),
|
||||
self.seg(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn segment_via_repulsion(
|
||||
pub fn seg_via_repulsion(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringer: SegId,
|
||||
infringee: ViaId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.segment_via_rect_overlap(infringer, infringee),
|
||||
self.segment(infringer).center(),
|
||||
self.seg_via_rect_overlap(infringer, infringee),
|
||||
self.seg(infringer).center(),
|
||||
self.via(infringee).position,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn segment_polygon_repulsion(
|
||||
pub fn seg_poly_repulsion(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringee: PolygonId,
|
||||
infringer: SegId,
|
||||
infringee: PolyId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.segment_polygon_rect_overlap(infringer, infringee),
|
||||
self.segment(infringer).center(),
|
||||
self.polygon(infringee).centroid,
|
||||
self.seg_poly_rect_overlap(infringer, infringee),
|
||||
self.seg(infringer).center(),
|
||||
self.poly(infringee).centroid,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn segment_primitive_repulsion(
|
||||
pub fn seg_primitive_repulsion(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
infringer: SegId,
|
||||
infringee: PrimitiveId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
match infringee {
|
||||
PrimitiveId::Joint(infringee) => {
|
||||
self.segment_joint_repulsion(infringer, infringee, orientation)
|
||||
self.seg_joint_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Segment(infringee) => {
|
||||
self.segment_segment_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Seg(infringee) => {
|
||||
self.seg_seg_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Via(infringee) => {
|
||||
self.segment_via_repulsion(infringer, infringee, orientation)
|
||||
self.seg_via_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Polygon(infringee) => {
|
||||
self.segment_polygon_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Poly(infringee) => {
|
||||
self.seg_poly_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -279,16 +279,16 @@ impl Layout {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn via_segment_repulsion(
|
||||
pub fn via_seg_repulsion(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
infringee: SegmentId,
|
||||
infringee: SegId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.via_segment_rect_overlap(infringer, infringee),
|
||||
self.via_seg_rect_overlap(infringer, infringee),
|
||||
self.via(infringer).position,
|
||||
self.segment(infringee).center(),
|
||||
self.seg(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -307,16 +307,16 @@ impl Layout {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn via_polygon_repulsion(
|
||||
pub fn via_poly_repulsion(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
infringee: PolygonId,
|
||||
infringee: PolyId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.via_polygon_rect_overlap(infringer, infringee),
|
||||
self.via_poly_rect_overlap(infringer, infringee),
|
||||
self.via(infringer).position,
|
||||
self.polygon(infringee).centroid,
|
||||
self.poly(infringee).centroid,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -331,92 +331,92 @@ impl Layout {
|
|||
PrimitiveId::Joint(infringee) => {
|
||||
self.via_joint_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Segment(infringee) => {
|
||||
self.via_segment_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Seg(infringee) => {
|
||||
self.via_seg_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Via(infringee) => {
|
||||
self.via_via_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Polygon(infringee) => {
|
||||
self.via_polygon_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Poly(infringee) => {
|
||||
self.via_poly_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn polygon_joint_repulsion(
|
||||
pub fn poly_joint_repulsion(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringer: PolyId,
|
||||
infringee: JointId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.polygon_joint_rect_overlap(infringer, infringee),
|
||||
self.polygon(infringer).centroid,
|
||||
self.poly_joint_rect_overlap(infringer, infringee),
|
||||
self.poly(infringer).centroid,
|
||||
self.joint(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn polygon_segment_repulsion(
|
||||
pub fn poly_seg_repulsion(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringee: SegmentId,
|
||||
infringer: PolyId,
|
||||
infringee: SegId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.polygon_segment_rect_overlap(infringer, infringee),
|
||||
self.polygon(infringer).centroid,
|
||||
self.segment(infringee).center(),
|
||||
self.poly_seg_rect_overlap(infringer, infringee),
|
||||
self.poly(infringer).centroid,
|
||||
self.seg(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn polygon_via_repulsion(
|
||||
pub fn poly_via_repulsion(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringer: PolyId,
|
||||
infringee: ViaId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.polygon_via_rect_overlap(infringer, infringee),
|
||||
self.polygon(infringer).centroid,
|
||||
self.poly_via_rect_overlap(infringer, infringee),
|
||||
self.poly(infringer).centroid,
|
||||
self.via(infringee).position,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn polygon_polygon_repulsion(
|
||||
pub fn poly_poly_repulsion(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringee: PolygonId,
|
||||
infringer: PolyId,
|
||||
infringee: PolyId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.polygon_polygon_rect_overlap(infringer, infringee),
|
||||
self.polygon(infringer).centroid,
|
||||
self.polygon(infringee).centroid,
|
||||
self.poly_poly_rect_overlap(infringer, infringee),
|
||||
self.poly(infringer).centroid,
|
||||
self.poly(infringee).centroid,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn polygon_primitive_repulsion(
|
||||
pub fn poly_primitive_repulsion(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
infringer: PolyId,
|
||||
infringee: PrimitiveId,
|
||||
orientation: Orientation,
|
||||
) -> Vector2<i64> {
|
||||
match infringee {
|
||||
PrimitiveId::Joint(infringee) => {
|
||||
self.polygon_joint_repulsion(infringer, infringee, orientation)
|
||||
self.poly_joint_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Segment(infringee) => {
|
||||
self.polygon_segment_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Seg(infringee) => {
|
||||
self.poly_seg_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Via(infringee) => {
|
||||
self.polygon_via_repulsion(infringer, infringee, orientation)
|
||||
self.poly_via_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
PrimitiveId::Polygon(infringee) => {
|
||||
self.polygon_polygon_repulsion(infringer, infringee, orientation)
|
||||
PrimitiveId::Poly(infringee) => {
|
||||
self.poly_poly_repulsion(infringer, infringee, orientation)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,6 @@ impl Layout {
|
|||
return Vector2::new(0, 0);
|
||||
}
|
||||
|
||||
violator.closest_point_on_polygon_boundary(boundary) - violator
|
||||
violator.closest_point_on_poly_boundary(boundary) - violator
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,21 +21,21 @@ impl Layout {
|
|||
self.modify_joint_raw(joint_id, |joint| joint.spec.position += translation);
|
||||
}
|
||||
|
||||
for &segment_id in &component.segments {
|
||||
self.update_segment(segment_id);
|
||||
for &seg_id in &component.segs {
|
||||
self.update_seg(seg_id);
|
||||
}
|
||||
|
||||
for &via_id in &component.vias {
|
||||
self.update_via(via_id);
|
||||
}
|
||||
|
||||
for &polygon_id in &component.polygons {
|
||||
self.modify_polygon(polygon_id, |polygon| {
|
||||
polygon
|
||||
for &poly_id in &component.polys {
|
||||
self.modify_poly(poly_id, |poly| {
|
||||
poly
|
||||
.spec.vertices
|
||||
.iter_mut()
|
||||
.for_each(|vertex| *vertex += translation);
|
||||
polygon.centroid += translation;
|
||||
poly.centroid += translation;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ use polygon_unionfind::UnionFind;
|
|||
|
||||
use crate::Vector2;
|
||||
|
||||
/// Returns the four vertices of a segment inflated by `half_width`, forming a
|
||||
/// convex quadrilateral. The segment goes from (x1, y1) to (x2, y2).
|
||||
pub fn inflated_segment(x1: i64, y1: i64, x2: i64, y2: i64, half_width: u64) -> [Vector2<i64>; 4] {
|
||||
/// Returns the four vertices of a seg inflated by `half_width`, forming a
|
||||
/// convex quadrilateral. The seg goes from (x1, y1) to (x2, y2).
|
||||
pub fn inflated_seg(x1: i64, y1: i64, x2: i64, y2: i64, half_width: u64) -> [Vector2<i64>; 4] {
|
||||
let dx = x2 - x1;
|
||||
let dy = y2 - y1;
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
board::Board,
|
||||
layout::{
|
||||
LayerId,
|
||||
primitives::{Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId},
|
||||
primitives::{Joint, JointId, JointSpec, Poly, PolyId, Seg, SegId},
|
||||
},
|
||||
vector::Vector2,
|
||||
};
|
||||
|
|
@ -85,14 +85,14 @@ impl LayerNavmesher {
|
|||
|
||||
pub fn insert_multiobstacle(
|
||||
&mut self,
|
||||
polygon: impl IntoIterator<Item = Vector2<i64>>,
|
||||
poly: impl IntoIterator<Item = Vector2<i64>>,
|
||||
) -> usize {
|
||||
let polygon: Vec<Vector2<i64>> = polygon.into_iter().collect();
|
||||
let poly: Vec<Vector2<i64>> = poly.into_iter().collect();
|
||||
let mut index = 0;
|
||||
|
||||
for i in 0..self.navmeshes.len() {
|
||||
index = self.navmeshes[i].insert_obstacle_and_rebuild(
|
||||
Self::inflate_polygon(polygon.clone(), self.inflation_factors[i])
|
||||
Self::inflate_poly(poly.clone(), self.inflation_factors[i])
|
||||
.into_iter()
|
||||
.map(Into::into),
|
||||
self.boundary.iter().cloned().map(Into::into),
|
||||
|
|
@ -102,15 +102,15 @@ impl LayerNavmesher {
|
|||
index
|
||||
}
|
||||
|
||||
fn inflate_polygon(
|
||||
polygon: Vec<Vector2<i64>>,
|
||||
fn inflate_poly(
|
||||
poly: Vec<Vector2<i64>>,
|
||||
inflation_factor: f64,
|
||||
) -> impl IntoIterator<Item = Vector2<i64>> {
|
||||
// Centroid.
|
||||
let cx = polygon.iter().map(|p| p.x as f64).sum::<f64>() / polygon.len() as f64;
|
||||
let cy = polygon.iter().map(|p| p.y as f64).sum::<f64>() / polygon.len() as f64;
|
||||
let cx = poly.iter().map(|p| p.x as f64).sum::<f64>() / poly.len() as f64;
|
||||
let cy = poly.iter().map(|p| p.y as f64).sum::<f64>() / poly.len() as f64;
|
||||
|
||||
polygon.into_iter().map(move |p| {
|
||||
poly.into_iter().map(move |p| {
|
||||
let px = p.x as f64;
|
||||
let py = p.y as f64;
|
||||
// Delta.
|
||||
|
|
@ -198,8 +198,8 @@ pub struct NavmesherBoard {
|
|||
board: Board,
|
||||
|
||||
joint_multiobstacles: Recorder<StableVec<MultiObstacleId>>,
|
||||
segment_multiobstacles: Recorder<StableVec<MultiObstacleId>>,
|
||||
polygon_multiobstacles: Recorder<StableVec<MultiObstacleId>>,
|
||||
seg_multiobstacles: Recorder<StableVec<MultiObstacleId>>,
|
||||
poly_multiobstacles: Recorder<StableVec<MultiObstacleId>>,
|
||||
}
|
||||
|
||||
impl NavmesherBoard {
|
||||
|
|
@ -212,8 +212,8 @@ impl NavmesherBoard {
|
|||
board,
|
||||
|
||||
joint_multiobstacles: Recorder::new(StableVec::new()),
|
||||
segment_multiobstacles: Recorder::new(StableVec::new()),
|
||||
polygon_multiobstacles: Recorder::new(StableVec::new()),
|
||||
seg_multiobstacles: Recorder::new(StableVec::new()),
|
||||
poly_multiobstacles: Recorder::new(StableVec::new()),
|
||||
};
|
||||
|
||||
/*for (i, joint) in this.board.layout().joints().container().iter() {
|
||||
|
|
@ -224,19 +224,19 @@ impl NavmesherBoard {
|
|||
);
|
||||
}
|
||||
|
||||
for (i, segment) in this.board.layout().segments().container().iter() {
|
||||
this.segment_multiobstacles.insert(
|
||||
for (i, seg) in this.board.layout().segs().container().iter() {
|
||||
this.seg_multiobstacles.insert(
|
||||
i,
|
||||
this.navmesher
|
||||
.insert_multiobstacle(segment.layer, segment.bounding_rectangle()),
|
||||
.insert_multiobstacle(seg.layer, seg.bounding_rectangle()),
|
||||
);
|
||||
}
|
||||
|
||||
for (i, polygon) in this.board.layout().polygons().container().iter() {
|
||||
this.polygon_multiobstacles.insert(
|
||||
for (i, poly) in this.board.layout().polys().container().iter() {
|
||||
this.poly_multiobstacles.insert(
|
||||
i,
|
||||
this.navmesher
|
||||
.insert_multiobstacle(polygon.spec.layer, polygon.spec.vertices.clone()),
|
||||
.insert_multiobstacle(poly.spec.layer, poly.spec.vertices.clone()),
|
||||
);
|
||||
}*/
|
||||
|
||||
|
|
@ -247,7 +247,7 @@ impl NavmesherBoard {
|
|||
let layer = spec.layer;
|
||||
let obstacle = Self::joint_bounding_octagon(&Joint {
|
||||
spec,
|
||||
segments: Vec::new(),
|
||||
segs: Vec::new(),
|
||||
vias: Vec::new(),
|
||||
});
|
||||
let joint_id = self.board.insert_joint(spec);
|
||||
|
|
@ -276,26 +276,26 @@ impl NavmesherBoard {
|
|||
]
|
||||
}
|
||||
|
||||
pub fn insert_segment_with_cache(&mut self, segment: Segment) -> SegmentId {
|
||||
let layer = segment.layer;
|
||||
let obstacle = segment.bounding_rectangle();
|
||||
let segment_id = self.board.insert_segment_raw(segment);
|
||||
self.segment_multiobstacles.insert(
|
||||
segment_id.index(),
|
||||
pub fn insert_seg_with_cache(&mut self, seg: Seg) -> SegId {
|
||||
let layer = seg.layer;
|
||||
let obstacle = seg.bounding_rectangle();
|
||||
let seg_id = self.board.insert_seg_raw(seg);
|
||||
self.seg_multiobstacles.insert(
|
||||
seg_id.index(),
|
||||
self.navmesher.insert_multiobstacle(layer, obstacle),
|
||||
);
|
||||
|
||||
segment_id
|
||||
seg_id
|
||||
}
|
||||
|
||||
pub fn insert_polygon(&mut self, polygon: Polygon) -> PolygonId {
|
||||
let polygon_id = self.board.insert_polygon(polygon.clone());
|
||||
self.polygon_multiobstacles.insert(
|
||||
polygon_id.index(),
|
||||
pub fn insert_poly(&mut self, poly: Poly) -> PolyId {
|
||||
let poly_id = self.board.insert_poly(poly.clone());
|
||||
self.poly_multiobstacles.insert(
|
||||
poly_id.index(),
|
||||
self.navmesher
|
||||
.insert_multiobstacle(polygon.spec.layer, polygon.spec.vertices),
|
||||
.insert_multiobstacle(poly.spec.layer, poly.spec.vertices),
|
||||
);
|
||||
|
||||
polygon_id
|
||||
poly_id
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ use crate::{
|
|||
layout::{
|
||||
LayerId,
|
||||
compounds::NetId,
|
||||
primitives::{JointId, PolygonId, PrimitiveId, SegmentId},
|
||||
primitives::{JointId, PolyId, PrimitiveId, SegId},
|
||||
},
|
||||
vector::Vector2,
|
||||
};
|
||||
|
|
@ -68,39 +68,39 @@ impl Ratsnest {
|
|||
});
|
||||
}
|
||||
|
||||
for (i, segment) in board.layout().segments().container().iter() {
|
||||
let Some(net) = segment.net else {
|
||||
for (i, seg) in board.layout().segs().container().iter() {
|
||||
let Some(net) = seg.net else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let segment_center = segment.center();
|
||||
let seg_center = seg.center();
|
||||
let _ = triangulations
|
||||
.entry((net, segment.layer))
|
||||
.entry((net, seg.layer))
|
||||
.or_insert_with(DelaunayTriangulation::new)
|
||||
.insert(DelaunayVertex {
|
||||
layer: segment.layer,
|
||||
center: segment_center,
|
||||
position: spade::Point2::new(segment_center.x as f64, segment_center.y as f64),
|
||||
primitive_id: PrimitiveId::Segment(SegmentId::new(i)),
|
||||
layer: seg.layer,
|
||||
center: seg_center,
|
||||
position: spade::Point2::new(seg_center.x as f64, seg_center.y as f64),
|
||||
primitive_id: PrimitiveId::Seg(SegId::new(i)),
|
||||
});
|
||||
}
|
||||
|
||||
for (i, polygon) in board.layout().polygons().container().iter() {
|
||||
let Some(net) = polygon.spec.net else {
|
||||
for (i, poly) in board.layout().polys().container().iter() {
|
||||
let Some(net) = poly.spec.net else {
|
||||
continue;
|
||||
};
|
||||
|
||||
let _ = triangulations
|
||||
.entry((net, polygon.spec.layer))
|
||||
.entry((net, poly.spec.layer))
|
||||
.or_insert_with(DelaunayTriangulation::new)
|
||||
.insert(DelaunayVertex {
|
||||
layer: polygon.spec.layer,
|
||||
center: polygon.centroid,
|
||||
layer: poly.spec.layer,
|
||||
center: poly.centroid,
|
||||
position: spade::Point2::new(
|
||||
polygon.centroid.x as f64,
|
||||
polygon.centroid.y as f64,
|
||||
poly.centroid.x as f64,
|
||||
poly.centroid.y as f64,
|
||||
),
|
||||
primitive_id: PrimitiveId::Polygon(PolygonId::new(i)),
|
||||
primitive_id: PrimitiveId::Poly(PolyId::new(i)),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,46 +184,46 @@ impl_rect2_intersects_circle!(u128);
|
|||
impl_rect2_intersects_circle!(f32);
|
||||
impl_rect2_intersects_circle!(f64);
|
||||
|
||||
macro_rules! impl_rect2_contains_polygon {
|
||||
macro_rules! impl_rect2_contains_poly {
|
||||
($type:ty) => {
|
||||
impl Rect2<$type> {
|
||||
pub fn contains_polygon(&self, polygon: &[Vector2<$type>]) -> bool {
|
||||
pub fn contains_poly(&self, poly: &[Vector2<$type>]) -> bool {
|
||||
let corners = self.corners();
|
||||
polygon.iter().all(|point| point.inside_polygon(&corners))
|
||||
poly.iter().all(|point| point.inside_polygon(&corners))
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl_rect2_contains_polygon!(i8);
|
||||
impl_rect2_contains_polygon!(i16);
|
||||
impl_rect2_contains_polygon!(i32);
|
||||
impl_rect2_contains_polygon!(i64);
|
||||
impl_rect2_contains_polygon!(i128);
|
||||
impl_rect2_contains_polygon!(u8);
|
||||
impl_rect2_contains_polygon!(u16);
|
||||
impl_rect2_contains_polygon!(u32);
|
||||
impl_rect2_contains_polygon!(u64);
|
||||
impl_rect2_contains_polygon!(u128);
|
||||
impl_rect2_contains_polygon!(f32);
|
||||
impl_rect2_contains_polygon!(f64);
|
||||
impl_rect2_contains_poly!(i8);
|
||||
impl_rect2_contains_poly!(i16);
|
||||
impl_rect2_contains_poly!(i32);
|
||||
impl_rect2_contains_poly!(i64);
|
||||
impl_rect2_contains_poly!(i128);
|
||||
impl_rect2_contains_poly!(u8);
|
||||
impl_rect2_contains_poly!(u16);
|
||||
impl_rect2_contains_poly!(u32);
|
||||
impl_rect2_contains_poly!(u64);
|
||||
impl_rect2_contains_poly!(u128);
|
||||
impl_rect2_contains_poly!(f32);
|
||||
impl_rect2_contains_poly!(f64);
|
||||
|
||||
macro_rules! impl_rect2_intersects_polygon {
|
||||
macro_rules! impl_rect2_intersects_poly {
|
||||
($type:ty) => {
|
||||
impl Rect2<$type> {
|
||||
pub fn intersects_polygon(&self, polygon: &[Vector2<$type>]) -> bool {
|
||||
if polygon.is_empty() {
|
||||
pub fn intersects_poly(&self, poly: &[Vector2<$type>]) -> bool {
|
||||
if poly.is_empty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if polygon.iter().any(|&vertex| self.contains_point(vertex)) {
|
||||
if poly.iter().any(|&vertex| self.contains_point(vertex)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if self
|
||||
.corners()
|
||||
.iter()
|
||||
.any(|corner| corner.inside_polygon(polygon))
|
||||
.any(|corner| corner.inside_polygon(poly))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
@ -237,18 +237,18 @@ macro_rules! impl_rect2_intersects_polygon {
|
|||
};
|
||||
}
|
||||
|
||||
impl_rect2_intersects_polygon!(i8);
|
||||
impl_rect2_intersects_polygon!(i16);
|
||||
impl_rect2_intersects_polygon!(i32);
|
||||
impl_rect2_intersects_polygon!(i64);
|
||||
impl_rect2_intersects_polygon!(i128);
|
||||
impl_rect2_intersects_polygon!(u8);
|
||||
impl_rect2_intersects_polygon!(u16);
|
||||
impl_rect2_intersects_polygon!(u32);
|
||||
impl_rect2_intersects_polygon!(u64);
|
||||
impl_rect2_intersects_polygon!(u128);
|
||||
impl_rect2_intersects_polygon!(f32);
|
||||
impl_rect2_intersects_polygon!(f64);
|
||||
impl_rect2_intersects_poly!(i8);
|
||||
impl_rect2_intersects_poly!(i16);
|
||||
impl_rect2_intersects_poly!(i32);
|
||||
impl_rect2_intersects_poly!(i64);
|
||||
impl_rect2_intersects_poly!(i128);
|
||||
impl_rect2_intersects_poly!(u8);
|
||||
impl_rect2_intersects_poly!(u16);
|
||||
impl_rect2_intersects_poly!(u32);
|
||||
impl_rect2_intersects_poly!(u64);
|
||||
impl_rect2_intersects_poly!(u128);
|
||||
impl_rect2_intersects_poly!(f32);
|
||||
impl_rect2_intersects_poly!(f64);
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Getters, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
pub struct Rect3<T> {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ use specctra::{
|
|||
|
||||
use crate::{
|
||||
board::{Board, LayerDesc, LayerSide, LayerType},
|
||||
layout::primitives::{JointSpec, Polygon, PolygonSpec, Segment, SegmentSpec},
|
||||
layout::primitives::{JointSpec, Poly, PolySpec, Seg, SegSpec},
|
||||
layout::{
|
||||
LayerId,
|
||||
compounds::{ComponentId, NetId, PinId, PinSpec},
|
||||
|
|
@ -225,7 +225,7 @@ impl Board {
|
|||
}
|
||||
Shape::Polygon(polygon) => {
|
||||
let layer = get_layer(&board, &polygon.layer);
|
||||
Self::place_polygon(
|
||||
Self::place_poly(
|
||||
&mut board,
|
||||
place.point_with_rotation(),
|
||||
pin.point_with_rotation(),
|
||||
|
|
@ -306,7 +306,7 @@ impl Board {
|
|||
}
|
||||
Shape::Polygon(polygon) => {
|
||||
let layer = get_layer(&board, &polygon.layer);
|
||||
Self::place_polygon(
|
||||
Self::place_poly(
|
||||
&mut board,
|
||||
PointWithRotation::from_xy(via.x, via.y),
|
||||
PointWithRotation::default(),
|
||||
|
|
@ -383,8 +383,8 @@ impl Board {
|
|||
flip: bool,
|
||||
coordinate_scale: f64,
|
||||
) {
|
||||
board.insert_polygon({
|
||||
let spec = PolygonSpec {
|
||||
board.insert_poly({
|
||||
let spec = PolySpec {
|
||||
vertices: vec![
|
||||
Self::pos(place, pin_pos, x1, y1, flip, coordinate_scale),
|
||||
Self::pos(place, pin_pos, x2, y1, flip, coordinate_scale),
|
||||
|
|
@ -396,9 +396,9 @@ impl Board {
|
|||
component,
|
||||
pin,
|
||||
};
|
||||
let centroid = Vector2::<i64>::polygon_centroid(&spec.vertices);
|
||||
let centroid = Vector2::<i64>::poly_centroid(&spec.vertices);
|
||||
|
||||
Polygon { spec, centroid }
|
||||
Poly { spec, centroid }
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -448,8 +448,8 @@ impl Board {
|
|||
pin,
|
||||
});
|
||||
|
||||
let _ = board.insert_segment_raw(Segment {
|
||||
spec: SegmentSpec {
|
||||
let _ = board.insert_seg_raw(Seg {
|
||||
spec: SegSpec {
|
||||
endjoints: [prev_joint, joint],
|
||||
half_width: Self::scale_size(width / 2.0, coordinate_scale),
|
||||
component,
|
||||
|
|
@ -465,7 +465,7 @@ impl Board {
|
|||
}
|
||||
}
|
||||
|
||||
fn place_polygon(
|
||||
fn place_poly(
|
||||
board: &mut Board,
|
||||
place: PointWithRotation,
|
||||
pin_pos: PointWithRotation,
|
||||
|
|
@ -482,17 +482,17 @@ impl Board {
|
|||
.iter()
|
||||
.map(|coord| Self::pos(place, pin_pos, coord.x, coord.y, flip, coordinate_scale))
|
||||
.collect();
|
||||
board.insert_polygon({
|
||||
let spec = PolygonSpec {
|
||||
board.insert_poly({
|
||||
let spec = PolySpec {
|
||||
vertices,
|
||||
layer,
|
||||
net,
|
||||
component,
|
||||
pin,
|
||||
};
|
||||
let centroid = Vector2::<i64>::polygon_centroid(&spec.vertices);
|
||||
let centroid = Vector2::<i64>::poly_centroid(&spec.vertices);
|
||||
|
||||
Polygon { spec, centroid }
|
||||
Poly { spec, centroid }
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -73,19 +73,19 @@ impl<T: Bounded + Copy> Vector2<T> {
|
|||
macro_rules! impl_vector2_inside_polygon {
|
||||
($type:ty) => {
|
||||
impl Vector2<$type> {
|
||||
// Checks if the point is inside a polygon by casting a ray to the
|
||||
// Checks if the point is inside a poly by casting a ray to the
|
||||
// right. Division is not used to avoid integer truncation errors.
|
||||
pub fn inside_polygon(&self, polygon: &[Vector2<$type>]) -> bool {
|
||||
pub fn inside_polygon(&self, poly: &[Vector2<$type>]) -> bool {
|
||||
let mut inside = false;
|
||||
let n = polygon.len();
|
||||
let n = poly.len();
|
||||
|
||||
// `self` is `v0`.
|
||||
|
||||
// `v1` is the previous vertex.
|
||||
let mut v1 = &polygon[n - 1];
|
||||
let mut v1 = &poly[n - 1];
|
||||
|
||||
// `v2` is the current vertex.
|
||||
for v2 in polygon.iter() {
|
||||
for v2 in poly.iter() {
|
||||
let dx12 = v2.x - v1.x;
|
||||
let dy12 = v2.y - v1.y;
|
||||
|
||||
|
|
@ -147,40 +147,40 @@ impl_vector2_inside_polygon!(f64);
|
|||
macro_rules! impl_vector2_closest_point_on_boundary {
|
||||
($type:ty) => {
|
||||
impl Vector2<$type> {
|
||||
pub fn closest_point_on_segment(
|
||||
pub fn closest_point_on_seg(
|
||||
self,
|
||||
segment_start: Vector2<$type>,
|
||||
segment_end: Vector2<$type>,
|
||||
seg_start: Vector2<$type>,
|
||||
seg_end: Vector2<$type>,
|
||||
) -> Vector2<$type> {
|
||||
let abx = segment_end.x - segment_start.x;
|
||||
let aby = segment_end.y - segment_start.y;
|
||||
let apx = self.x - segment_start.x;
|
||||
let apy = self.y - segment_start.y;
|
||||
let abx = seg_end.x - seg_start.x;
|
||||
let aby = seg_end.y - seg_start.y;
|
||||
let apx = self.x - seg_start.x;
|
||||
let apy = self.y - seg_start.y;
|
||||
let ab_len_sq = abx * abx + aby * aby;
|
||||
|
||||
if ab_len_sq == 0 as $type {
|
||||
return segment_start;
|
||||
return seg_start;
|
||||
}
|
||||
|
||||
let t = (apx * abx + apy * aby).clamp(0 as $type, ab_len_sq);
|
||||
|
||||
Vector2::new(
|
||||
segment_start.x + abx * t / ab_len_sq,
|
||||
segment_start.y + aby * t / ab_len_sq,
|
||||
seg_start.x + abx * t / ab_len_sq,
|
||||
seg_start.y + aby * t / ab_len_sq,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn closest_point_on_polygon_boundary(
|
||||
pub fn closest_point_on_poly_boundary(
|
||||
self,
|
||||
polygon: &[Vector2<$type>],
|
||||
poly: &[Vector2<$type>],
|
||||
) -> Vector2<$type> {
|
||||
let mut closest_point = polygon[0];
|
||||
let mut closest_point = poly[0];
|
||||
let mut best_distance_sq = <$type as Bounded>::max_value();
|
||||
|
||||
for i in 0..polygon.len() {
|
||||
let segment_start = polygon[i];
|
||||
let segment_end = polygon[(i + 1) % polygon.len()];
|
||||
let candidate = self.closest_point_on_segment(segment_start, segment_end);
|
||||
for i in 0..poly.len() {
|
||||
let seg_start = poly[i];
|
||||
let seg_end = poly[(i + 1) % poly.len()];
|
||||
let candidate = self.closest_point_on_seg(seg_start, seg_end);
|
||||
let dx = self.x - candidate.x;
|
||||
let dy = self.y - candidate.y;
|
||||
let distance_sq = dx * dx + dy * dy;
|
||||
|
|
@ -243,35 +243,35 @@ macro_rules! impl_vector2_rotate_around_point {
|
|||
impl_vector2_rotate_around_point!(f32);
|
||||
impl_vector2_rotate_around_point!(f64);
|
||||
|
||||
macro_rules! impl_polygon_centroid {
|
||||
macro_rules! impl_poly_centroid {
|
||||
($type:ty) => {
|
||||
impl Vector2<$type> {
|
||||
pub fn polygon_centroid(polygon: &[Vector2<$type>]) -> Self {
|
||||
pub fn poly_centroid(poly: &[Vector2<$type>]) -> Self {
|
||||
crate::profile_function!();
|
||||
let mut sum = Vector2::new(0 as $type, 0 as $type);
|
||||
|
||||
for vertex in polygon.iter() {
|
||||
for vertex in poly.iter() {
|
||||
sum += *vertex;
|
||||
}
|
||||
|
||||
sum / polygon.len() as $type
|
||||
sum / poly.len() as $type
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
impl_polygon_centroid!(i8);
|
||||
impl_polygon_centroid!(i16);
|
||||
impl_polygon_centroid!(i32);
|
||||
impl_polygon_centroid!(i64);
|
||||
impl_polygon_centroid!(i128);
|
||||
impl_polygon_centroid!(u8);
|
||||
impl_polygon_centroid!(u16);
|
||||
impl_polygon_centroid!(u32);
|
||||
impl_polygon_centroid!(u64);
|
||||
impl_polygon_centroid!(u128);
|
||||
impl_polygon_centroid!(f32);
|
||||
impl_polygon_centroid!(f64);
|
||||
impl_poly_centroid!(i8);
|
||||
impl_poly_centroid!(i16);
|
||||
impl_poly_centroid!(i32);
|
||||
impl_poly_centroid!(i64);
|
||||
impl_poly_centroid!(i128);
|
||||
impl_poly_centroid!(u8);
|
||||
impl_poly_centroid!(u16);
|
||||
impl_poly_centroid!(u32);
|
||||
impl_poly_centroid!(u64);
|
||||
impl_poly_centroid!(u128);
|
||||
impl_poly_centroid!(f32);
|
||||
impl_poly_centroid!(f64);
|
||||
|
||||
#[derive(
|
||||
Add,
|
||||
|
|
|
|||
Loading…
Reference in New Issue