mirror of https://codeberg.org/topola/topola.git
Add method to locate all component-component repulsions for given component
This commit is contained in:
parent
b3dc4089a4
commit
6cebbb2816
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
use std::collections::BTreeSet;
|
||||
|
||||
use derive_getters::Getters;
|
||||
use derive_more::Constructor;
|
||||
use rstar::{
|
||||
AABB, RTree,
|
||||
|
|
@ -12,18 +11,28 @@ use rstar::{
|
|||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::board::Board;
|
||||
use crate::primitives::PrimitiveId;
|
||||
|
||||
use super::Layout;
|
||||
use super::compounds::{ComponentId, NetId};
|
||||
use super::primitives::{JointId, PolygonId, SegmentId, ViaId};
|
||||
|
||||
#[derive(
|
||||
Clone, Copy, Constructor, Debug, Deserialize, Eq, Getters, Ord, PartialEq, PartialOrd, Serialize,
|
||||
Clone, Copy, Constructor, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
||||
)]
|
||||
pub struct Infringement<I = PrimitiveId, E = PrimitiveId> {
|
||||
infringer: I,
|
||||
infringee: E,
|
||||
pub struct Infringement<T = PrimitiveId, U = PrimitiveId> {
|
||||
infringer: T,
|
||||
infringee: U,
|
||||
}
|
||||
|
||||
impl<T: Copy, U: Copy> Infringement<T, U> {
|
||||
pub fn infringer(&self) -> T {
|
||||
self.infringer
|
||||
}
|
||||
|
||||
pub fn infringee(&self) -> U {
|
||||
self.infringee
|
||||
}
|
||||
}
|
||||
|
||||
mod sealed {
|
||||
|
|
@ -39,12 +48,12 @@ mod sealed {
|
|||
impl IntoPrimitiveId for PolygonId {}
|
||||
}
|
||||
|
||||
impl<I: sealed::IntoPrimitiveId, E: sealed::IntoPrimitiveId> From<Infringement<I, E>>
|
||||
for Infringement<I, PrimitiveId>
|
||||
impl<T: sealed::IntoPrimitiveId, U: sealed::IntoPrimitiveId> From<Infringement<T, U>>
|
||||
for Infringement<T, PrimitiveId>
|
||||
where
|
||||
E: sealed::IntoPrimitiveId,
|
||||
U: sealed::IntoPrimitiveId,
|
||||
{
|
||||
fn from(from: Infringement<I, E>) -> Self {
|
||||
fn from(from: Infringement<T, U>) -> Self {
|
||||
Infringement {
|
||||
infringer: from.infringer,
|
||||
infringee: from.infringee.into(),
|
||||
|
|
@ -52,10 +61,10 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl<I: sealed::IntoPrimitiveId, E: sealed::IntoPrimitiveId> From<Infringement<I, E>>
|
||||
impl<T: sealed::IntoPrimitiveId, U: sealed::IntoPrimitiveId> From<Infringement<T, U>>
|
||||
for Infringement
|
||||
{
|
||||
fn from(from: Infringement<I, E>) -> Self {
|
||||
fn from(from: Infringement<T, U>) -> Self {
|
||||
Infringement {
|
||||
infringer: from.infringer.into(),
|
||||
infringee: from.infringee.into(),
|
||||
|
|
@ -63,8 +72,8 @@ impl<I: sealed::IntoPrimitiveId, E: sealed::IntoPrimitiveId> From<Infringement<I
|
|||
}
|
||||
}
|
||||
|
||||
impl<I: sealed::IntoPrimitiveId> From<Infringement<I, PrimitiveId>> for Infringement {
|
||||
fn from(from: Infringement<I, PrimitiveId>) -> Self {
|
||||
impl<T: sealed::IntoPrimitiveId> From<Infringement<T, PrimitiveId>> for Infringement {
|
||||
fn from(from: Infringement<T, PrimitiveId>) -> Self {
|
||||
Infringement {
|
||||
infringer: from.infringer.into(),
|
||||
infringee: from.infringee,
|
||||
|
|
@ -72,15 +81,16 @@ impl<I: sealed::IntoPrimitiveId> From<Infringement<I, PrimitiveId>> for Infringe
|
|||
}
|
||||
}
|
||||
|
||||
impl Board {
|
||||
pub fn locate_component_component_infringements(
|
||||
impl Layout {
|
||||
pub fn locate_component_infringements(
|
||||
&self,
|
||||
infringer: ComponentId,
|
||||
) -> impl Iterator<Item = Infringement<ComponentId, ComponentId>> + '_ {
|
||||
let mut infringee_components = BTreeSet::new();
|
||||
|
||||
for infringement in self.locate_component_primitive_infringements(infringer) {
|
||||
let Some(infringee_component) = self.primitive_component(*infringement.infringee()) else {
|
||||
let Some(infringee_component) = self.primitive_component(infringement.infringee())
|
||||
else {
|
||||
continue;
|
||||
};
|
||||
|
||||
|
|
@ -93,14 +103,17 @@ impl Board {
|
|||
|
||||
infringee_components
|
||||
.into_iter()
|
||||
.map(move |infringee| Infringement::new(infringer, infringee))
|
||||
.map(move |infringee| Infringement {
|
||||
infringer,
|
||||
infringee,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn locate_component_primitive_infringements(
|
||||
&self,
|
||||
infringer: ComponentId,
|
||||
) -> impl Iterator<Item = Infringement> + '_ {
|
||||
let component = self.layout().component(infringer);
|
||||
let component = self.component(infringer);
|
||||
|
||||
let joint_infringements = component
|
||||
.joints
|
||||
|
|
@ -151,28 +164,28 @@ impl Board {
|
|||
&self,
|
||||
infringer: JointId,
|
||||
) -> impl Iterator<Item = Infringement<JointId, JointId>> + '_ {
|
||||
self.locate_same_infringements(infringer, self.layout().joints_rtree().as_ref())
|
||||
self.locate_same_infringements(infringer, self.joints_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_joint_segment_infringements(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
) -> impl Iterator<Item = Infringement<JointId, SegmentId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().segments_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.segments_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_joint_via_infringements(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
) -> impl Iterator<Item = Infringement<JointId, ViaId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().vias_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.vias_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_joint_polygon_infringements(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
) -> impl Iterator<Item = Infringement<JointId, PolygonId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().polygons_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.polygons_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_segment_infringements(
|
||||
|
|
@ -199,28 +212,28 @@ impl Board {
|
|||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId, JointId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().joints_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.joints_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_segment_segment_infringements(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId, SegmentId>> + '_ {
|
||||
self.locate_same_infringements(infringer, self.layout().segments_rtree().as_ref())
|
||||
self.locate_same_infringements(infringer, self.segments_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_segment_via_infringements(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId, ViaId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().vias_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.vias_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_segment_polygon_infringements(
|
||||
&self,
|
||||
infringer: SegmentId,
|
||||
) -> impl Iterator<Item = Infringement<SegmentId, PolygonId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().polygons_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.polygons_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_via_infringements(
|
||||
|
|
@ -244,28 +257,28 @@ impl Board {
|
|||
&self,
|
||||
infringer: ViaId,
|
||||
) -> impl Iterator<Item = Infringement<ViaId, JointId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().joints_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.joints_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_via_segment_infringements(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
) -> impl Iterator<Item = Infringement<ViaId, SegmentId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().segments_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.segments_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_via_via_infringements(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
) -> impl Iterator<Item = Infringement<ViaId, ViaId>> + '_ {
|
||||
self.locate_same_infringements(infringer, self.layout().vias_rtree().as_ref())
|
||||
self.locate_same_infringements(infringer, self.vias_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_via_polygon_infringements(
|
||||
&self,
|
||||
infringer: ViaId,
|
||||
) -> impl Iterator<Item = Infringement<ViaId, PolygonId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().polygons_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.polygons_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_polygon_infringements(
|
||||
|
|
@ -292,39 +305,39 @@ impl Board {
|
|||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId, JointId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().joints_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.joints_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_polygon_segment_infringements(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId, SegmentId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().segments_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.segments_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_polygon_via_infringements(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId, ViaId>> + '_ {
|
||||
self.locate_cross_infringements(infringer, self.layout().vias_rtree().as_ref())
|
||||
self.locate_cross_infringements(infringer, self.vias_rtree().as_ref())
|
||||
}
|
||||
|
||||
pub fn locate_polygon_polygon_infringements(
|
||||
&self,
|
||||
infringer: PolygonId,
|
||||
) -> impl Iterator<Item = Infringement<PolygonId, PolygonId>> + '_ {
|
||||
self.locate_same_infringements(infringer, self.layout().polygons_rtree().as_ref())
|
||||
self.locate_same_infringements(infringer, self.polygons_rtree().as_ref())
|
||||
}
|
||||
|
||||
fn locate_cross_infringements<
|
||||
'a,
|
||||
I: Copy + Into<PrimitiveId> + 'a,
|
||||
E: Copy + Into<PrimitiveId>,
|
||||
T: Copy + Into<PrimitiveId> + 'a,
|
||||
U: Copy + Into<PrimitiveId>,
|
||||
>(
|
||||
&'a self,
|
||||
infringer: I,
|
||||
infringee_tree: &'a RTree<GeomWithData<Rectangle<[i64; 3]>, E>>,
|
||||
) -> impl Iterator<Item = Infringement<I, E>> + 'a {
|
||||
infringer: T,
|
||||
infringee_tree: &'a RTree<GeomWithData<Rectangle<[i64; 3]>, U>>,
|
||||
) -> impl Iterator<Item = Infringement<T, U>> + 'a {
|
||||
infringee_tree
|
||||
.locate_in_envelope_intersecting(&self.primitive_bbox_envelope(infringer.into()))
|
||||
.map(|infringee_geom| infringee_geom.data)
|
||||
|
|
@ -340,11 +353,11 @@ impl Board {
|
|||
})
|
||||
}
|
||||
|
||||
fn locate_same_infringements<'a, I: Copy + PartialEq + Into<PrimitiveId> + 'a>(
|
||||
fn locate_same_infringements<'a, T: Copy + PartialEq + Into<PrimitiveId> + 'a>(
|
||||
&'a self,
|
||||
infringer: I,
|
||||
rtree: &'a RTree<GeomWithData<Rectangle<[i64; 3]>, I>>,
|
||||
) -> impl Iterator<Item = Infringement<I, I>> + 'a {
|
||||
infringer: T,
|
||||
rtree: &'a RTree<GeomWithData<Rectangle<[i64; 3]>, T>>,
|
||||
) -> impl Iterator<Item = Infringement<T, T>> + 'a {
|
||||
rtree
|
||||
.locate_in_envelope_intersecting(&self.primitive_bbox_envelope(infringer.into()))
|
||||
.map(|infringee_geom| infringee_geom.data)
|
||||
|
|
@ -363,28 +376,28 @@ impl Board {
|
|||
|
||||
fn primitive_component(&self, primitive: PrimitiveId) -> Option<ComponentId> {
|
||||
match primitive {
|
||||
PrimitiveId::Joint(joint_id) => self.layout().joint(joint_id).spec.component,
|
||||
PrimitiveId::Segment(segment_id) => self.layout().segment(segment_id).spec.component,
|
||||
PrimitiveId::Via(via_id) => self.layout().via(via_id).spec.component,
|
||||
PrimitiveId::Polygon(polygon_id) => self.layout().polygon(polygon_id).component,
|
||||
PrimitiveId::Joint(joint_id) => self.joint(joint_id).spec.component,
|
||||
PrimitiveId::Segment(segment_id) => self.segment(segment_id).spec.component,
|
||||
PrimitiveId::Via(via_id) => self.via(via_id).spec.component,
|
||||
PrimitiveId::Polygon(polygon_id) => self.polygon(polygon_id).component,
|
||||
}
|
||||
}
|
||||
|
||||
fn primitive_bbox_envelope(&self, primitive: PrimitiveId) -> AABB<[i64; 3]> {
|
||||
match primitive {
|
||||
PrimitiveId::Joint(joint_id) => self.layout().joint(joint_id).bbox().aabb(),
|
||||
PrimitiveId::Segment(segment_id) => self.layout().segment(segment_id).bbox().aabb(),
|
||||
PrimitiveId::Via(via_id) => self.layout().via(via_id).bbox().aabb(),
|
||||
PrimitiveId::Polygon(polygon_id) => self.layout().polygon(polygon_id).bbox().aabb(),
|
||||
PrimitiveId::Joint(joint_id) => self.joint(joint_id).bbox().aabb(),
|
||||
PrimitiveId::Segment(segment_id) => self.segment(segment_id).bbox().aabb(),
|
||||
PrimitiveId::Via(via_id) => self.via(via_id).bbox().aabb(),
|
||||
PrimitiveId::Polygon(polygon_id) => self.polygon(polygon_id).bbox().aabb(),
|
||||
}
|
||||
}
|
||||
|
||||
fn primitive_net(&self, primitive: PrimitiveId) -> Option<NetId> {
|
||||
match primitive {
|
||||
PrimitiveId::Joint(joint_id) => self.layout().joint(joint_id).spec.net,
|
||||
PrimitiveId::Segment(segment_id) => self.layout().segment(segment_id).net,
|
||||
PrimitiveId::Via(via_id) => self.layout().via(via_id).net,
|
||||
PrimitiveId::Polygon(polygon_id) => self.layout().polygon(polygon_id).net,
|
||||
PrimitiveId::Joint(joint_id) => self.joint(joint_id).spec.net,
|
||||
PrimitiveId::Segment(segment_id) => self.segment(segment_id).net,
|
||||
PrimitiveId::Via(via_id) => self.via(via_id).net,
|
||||
PrimitiveId::Polygon(polygon_id) => self.polygon(polygon_id).net,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,18 +4,20 @@
|
|||
|
||||
use crate::{
|
||||
Rect2,
|
||||
board::Board,
|
||||
primitives::{JointId, PolygonId, SegmentId, ViaId},
|
||||
layout::{
|
||||
Layout,
|
||||
primitives::{JointId, PolygonId, SegmentId, ViaId},
|
||||
},
|
||||
};
|
||||
|
||||
impl Board {
|
||||
impl Layout {
|
||||
pub fn joint_joint_rect_overlap(
|
||||
&self,
|
||||
infringer: JointId,
|
||||
infringee: JointId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().joint(infringee).bbox().xy();
|
||||
let infringer_bbox = self.joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.joint(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -25,8 +27,8 @@ impl Board {
|
|||
infringer: JointId,
|
||||
infringee: SegmentId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().segment(infringee).bbox().xy();
|
||||
let infringer_bbox = self.joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.segment(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -36,8 +38,8 @@ impl Board {
|
|||
infringer: JointId,
|
||||
infringee: ViaId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().via(infringee).bbox().xy();
|
||||
let infringer_bbox = self.joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.via(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -47,8 +49,8 @@ impl Board {
|
|||
infringer: JointId,
|
||||
infringee: PolygonId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().polygon(infringee).bbox().xy();
|
||||
let infringer_bbox = self.joint(infringer).bbox().xy();
|
||||
let infringee_bbox = self.polygon(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -58,8 +60,8 @@ impl Board {
|
|||
infringer: SegmentId,
|
||||
infringee: JointId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().joint(infringee).bbox().xy();
|
||||
let infringer_bbox = self.segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.joint(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -69,8 +71,8 @@ impl Board {
|
|||
infringer: SegmentId,
|
||||
infringee: SegmentId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().segment(infringee).bbox().xy();
|
||||
let infringer_bbox = self.segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.segment(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -80,8 +82,8 @@ impl Board {
|
|||
infringer: SegmentId,
|
||||
infringee: ViaId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().via(infringee).bbox().xy();
|
||||
let infringer_bbox = self.segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.via(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -91,8 +93,8 @@ impl Board {
|
|||
infringer: SegmentId,
|
||||
infringee: PolygonId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().polygon(infringee).bbox().xy();
|
||||
let infringer_bbox = self.segment(infringer).bbox().xy();
|
||||
let infringee_bbox = self.polygon(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -102,8 +104,8 @@ impl Board {
|
|||
infringer: ViaId,
|
||||
infringee: JointId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().joint(infringee).bbox().xy();
|
||||
let infringer_bbox = self.via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.joint(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -113,8 +115,8 @@ impl Board {
|
|||
infringer: ViaId,
|
||||
infringee: SegmentId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().segment(infringee).bbox().xy();
|
||||
let infringer_bbox = self.via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.segment(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -124,8 +126,8 @@ impl Board {
|
|||
infringer: ViaId,
|
||||
infringee: ViaId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().via(infringee).bbox().xy();
|
||||
let infringer_bbox = self.via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.via(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -135,8 +137,8 @@ impl Board {
|
|||
infringer: ViaId,
|
||||
infringee: PolygonId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().polygon(infringee).bbox().xy();
|
||||
let infringer_bbox = self.via(infringer).bbox().xy();
|
||||
let infringee_bbox = self.polygon(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -146,8 +148,8 @@ impl Board {
|
|||
infringer: PolygonId,
|
||||
infringee: JointId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().joint(infringee).bbox().xy();
|
||||
let infringer_bbox = self.polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.joint(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -157,8 +159,8 @@ impl Board {
|
|||
infringer: PolygonId,
|
||||
infringee: SegmentId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().segment(infringee).bbox().xy();
|
||||
let infringer_bbox = self.polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.segment(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -168,8 +170,8 @@ impl Board {
|
|||
infringer: PolygonId,
|
||||
infringee: ViaId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().via(infringee).bbox().xy();
|
||||
let infringer_bbox = self.polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.via(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
@ -179,8 +181,8 @@ impl Board {
|
|||
infringer: PolygonId,
|
||||
infringee: PolygonId,
|
||||
) -> Option<Rect2<i64>> {
|
||||
let infringer_bbox = self.layout().polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.layout().polygon(infringee).bbox().xy();
|
||||
let infringer_bbox = self.polygon(infringer).bbox().xy();
|
||||
let infringee_bbox = self.polygon(infringee).bbox().xy();
|
||||
|
||||
infringer_bbox.intersection(infringee_bbox)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,14 +3,29 @@
|
|||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
use crate::{
|
||||
Board, Rect2, Vector2,
|
||||
Rect2, Vector2,
|
||||
compass::CompassDirection,
|
||||
layout::compounds::ComponentId,
|
||||
layout::{Layout, compounds::ComponentId},
|
||||
orientation::Orientation,
|
||||
primitives::{JointId, PolygonId, PrimitiveId, SegmentId, ViaId},
|
||||
};
|
||||
|
||||
impl Board {
|
||||
impl Layout {
|
||||
pub fn locate_component_repulsions(
|
||||
&self,
|
||||
infringer: ComponentId,
|
||||
orientation: Orientation,
|
||||
) -> impl Iterator<Item = Vector2<i64>> {
|
||||
self.locate_component_infringements(infringer)
|
||||
.map(move |infringement| {
|
||||
self.component_component_repulsion(
|
||||
infringement.infringer(),
|
||||
infringement.infringee(),
|
||||
orientation,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
pub fn component_component_repulsion(
|
||||
&self,
|
||||
infringer: ComponentId,
|
||||
|
|
@ -20,8 +35,8 @@ impl Board {
|
|||
let mut max_repulsion = Vector2::new(0, 0);
|
||||
let mut max_repulsion_magnitude = 0;
|
||||
|
||||
for infringer_primitive in self.layout().component(infringer).primitives() {
|
||||
for infringee_primitive in self.layout().component(infringee).primitives() {
|
||||
for infringer_primitive in self.component(infringer).primitives() {
|
||||
for infringee_primitive in self.component(infringee).primitives() {
|
||||
let repulsion = self.primitive_primitive_repulsion(
|
||||
infringer_primitive,
|
||||
infringee_primitive,
|
||||
|
|
@ -69,8 +84,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.joint_joint_rect_overlap(infringer, infringee),
|
||||
self.layout().joint(infringer).center(),
|
||||
self.layout().joint(infringee).center(),
|
||||
self.joint(infringer).center(),
|
||||
self.joint(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -83,8 +98,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.joint_segment_rect_overlap(infringer, infringee),
|
||||
self.layout().joint(infringer).center(),
|
||||
self.layout().segment(infringee).center(),
|
||||
self.joint(infringer).center(),
|
||||
self.segment(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -97,8 +112,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.joint_via_rect_overlap(infringer, infringee),
|
||||
self.layout().joint(infringer).center(),
|
||||
self.layout().via(infringee).position,
|
||||
self.joint(infringer).center(),
|
||||
self.via(infringee).position,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -111,8 +126,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.joint_polygon_rect_overlap(infringer, infringee),
|
||||
self.layout().joint(infringer).center(),
|
||||
self.layout().polygon(infringee).center(),
|
||||
self.joint(infringer).center(),
|
||||
self.polygon(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -147,8 +162,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.segment_joint_rect_overlap(infringer, infringee),
|
||||
self.layout().segment(infringer).center(),
|
||||
self.layout().joint(infringee).center(),
|
||||
self.segment(infringer).center(),
|
||||
self.joint(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -161,8 +176,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.segment_segment_rect_overlap(infringer, infringee),
|
||||
self.layout().segment(infringer).center(),
|
||||
self.layout().segment(infringee).center(),
|
||||
self.segment(infringer).center(),
|
||||
self.segment(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -175,8 +190,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.segment_via_rect_overlap(infringer, infringee),
|
||||
self.layout().segment(infringer).center(),
|
||||
self.layout().via(infringee).position,
|
||||
self.segment(infringer).center(),
|
||||
self.via(infringee).position,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -189,8 +204,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.segment_polygon_rect_overlap(infringer, infringee),
|
||||
self.layout().segment(infringer).center(),
|
||||
self.layout().polygon(infringee).center(),
|
||||
self.segment(infringer).center(),
|
||||
self.polygon(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -225,8 +240,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.via_joint_rect_overlap(infringer, infringee),
|
||||
self.layout().via(infringer).position,
|
||||
self.layout().joint(infringee).center(),
|
||||
self.via(infringer).position,
|
||||
self.joint(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -239,8 +254,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.via_segment_rect_overlap(infringer, infringee),
|
||||
self.layout().via(infringer).position,
|
||||
self.layout().segment(infringee).center(),
|
||||
self.via(infringer).position,
|
||||
self.segment(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -253,8 +268,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.via_via_rect_overlap(infringer, infringee),
|
||||
self.layout().via(infringer).position,
|
||||
self.layout().via(infringee).position,
|
||||
self.via(infringer).position,
|
||||
self.via(infringee).position,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -267,8 +282,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.via_polygon_rect_overlap(infringer, infringee),
|
||||
self.layout().via(infringer).position,
|
||||
self.layout().polygon(infringee).center(),
|
||||
self.via(infringer).position,
|
||||
self.polygon(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -303,8 +318,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.polygon_joint_rect_overlap(infringer, infringee),
|
||||
self.layout().polygon(infringer).center(),
|
||||
self.layout().joint(infringee).center(),
|
||||
self.polygon(infringer).center(),
|
||||
self.joint(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -317,8 +332,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.polygon_segment_rect_overlap(infringer, infringee),
|
||||
self.layout().polygon(infringer).center(),
|
||||
self.layout().segment(infringee).center(),
|
||||
self.polygon(infringer).center(),
|
||||
self.segment(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -331,8 +346,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.polygon_via_rect_overlap(infringer, infringee),
|
||||
self.layout().polygon(infringer).center(),
|
||||
self.layout().via(infringee).position,
|
||||
self.polygon(infringer).center(),
|
||||
self.via(infringee).position,
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
@ -345,8 +360,8 @@ impl Board {
|
|||
) -> Vector2<i64> {
|
||||
Self::repulsion_from_rect_overlap(
|
||||
self.polygon_polygon_rect_overlap(infringer, infringee),
|
||||
self.layout().polygon(infringer).center(),
|
||||
self.layout().polygon(infringee).center(),
|
||||
self.polygon(infringer).center(),
|
||||
self.polygon(infringee).center(),
|
||||
orientation,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue