mirror of https://codeberg.org/topola/topola.git
Move nets and pins to separate directory, `compounds`
This commit is contained in:
parent
b05c31f767
commit
bc5e205b90
|
|
@ -7,7 +7,8 @@ use derive_getters::{Dissolve, Getters};
|
|||
use undoredo::{ApplyDelta, Delta, FlushDelta};
|
||||
|
||||
use crate::{
|
||||
layout::{Layout, LayoutHalfDelta, NetId, PinId},
|
||||
compounds::{NetId, PinId},
|
||||
layout::{Layout, LayoutHalfDelta},
|
||||
math::Vector2,
|
||||
primitives::{
|
||||
JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId,
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
// SPDX-FileCopyrightText: 2026 Topola contributors
|
||||
//
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
mod net;
|
||||
mod pin;
|
||||
|
||||
pub use net::NetId;
|
||||
pub use pin::{Pin, PinId};
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
// SPDX-FileCopyrightText: 2026 Topola contributors
|
||||
//
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
use derive_more::Constructor;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(
|
||||
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
||||
)]
|
||||
pub struct NetId(usize);
|
||||
|
||||
impl NetId {
|
||||
#[inline]
|
||||
pub fn index(self) -> usize {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
// SPDX-FileCopyrightText: 2026 Topola contributors
|
||||
//
|
||||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
use derive_more::Constructor;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::primitives::{JointId, PolygonId, SegmentId, ViaId};
|
||||
|
||||
#[derive(
|
||||
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
||||
)]
|
||||
pub struct PinId(usize);
|
||||
|
||||
impl PinId {
|
||||
#[inline]
|
||||
pub fn index(self) -> usize {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Pin {
|
||||
pub(crate) joints: Vec<JointId>,
|
||||
pub(crate) segments: Vec<SegmentId>,
|
||||
pub(crate) vias: Vec<ViaId>,
|
||||
pub(crate) polygons: Vec<PolygonId>,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
joints: Vec::new(),
|
||||
segments: Vec::new(),
|
||||
vias: Vec::new(),
|
||||
polygons: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -3,66 +3,23 @@
|
|||
// SPDX-License-Identifier: MIT OR Apache-2.0
|
||||
|
||||
use derive_getters::Getters;
|
||||
use derive_more::Constructor;
|
||||
use rstar::{
|
||||
AABB, RTree,
|
||||
primitives::{GeomWithData, Rectangle},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use stable_vec::StableVec;
|
||||
use undoredo::aliases::RTreeHalfDelta;
|
||||
use undoredo::{Delta, Recorder};
|
||||
|
||||
use crate::{
|
||||
Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Vector2, Via, ViaId,
|
||||
primitives::{JointSpec, SegmentSpec, ViaSpec},
|
||||
compounds::{Pin, PinId},
|
||||
math::Vector2,
|
||||
primitives::{
|
||||
Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId, SegmentSpec, Via, ViaId,
|
||||
ViaSpec,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(
|
||||
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
||||
)]
|
||||
pub struct PinId(usize);
|
||||
|
||||
impl PinId {
|
||||
/// Returns the underlying index.
|
||||
#[inline]
|
||||
pub fn index(self) -> usize {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct Pin {
|
||||
joints: Vec<JointId>,
|
||||
segments: Vec<SegmentId>,
|
||||
vias: Vec<ViaId>,
|
||||
polygons: Vec<PolygonId>,
|
||||
}
|
||||
|
||||
impl Pin {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
joints: Vec::new(),
|
||||
segments: Vec::new(),
|
||||
vias: Vec::new(),
|
||||
polygons: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(
|
||||
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
||||
)]
|
||||
pub struct NetId(usize);
|
||||
|
||||
impl NetId {
|
||||
/// Returns the underlying index.
|
||||
#[inline]
|
||||
pub fn index(self) -> usize {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Delta, Clone, Debug, Getters)]
|
||||
pub struct Layout {
|
||||
#[undoredo(skip)]
|
||||
|
|
@ -72,8 +29,7 @@ pub struct Layout {
|
|||
#[undoredo(skip)]
|
||||
layer_count: usize,
|
||||
|
||||
#[undoredo(skip)]
|
||||
pins: StableVec<Pin>,
|
||||
pins: Recorder<StableVec<Pin>>,
|
||||
|
||||
joints: Recorder<StableVec<Joint>>,
|
||||
segments: Recorder<StableVec<Segment>>,
|
||||
|
|
@ -105,7 +61,7 @@ impl Layout {
|
|||
place_boundary: boundary,
|
||||
layer_count,
|
||||
|
||||
pins: StableVec::new(),
|
||||
pins: Recorder::new(StableVec::new()),
|
||||
|
||||
joints: Recorder::new(StableVec::new()),
|
||||
segments: Recorder::new(StableVec::new()),
|
||||
|
|
@ -137,7 +93,8 @@ impl Layout {
|
|||
.insert(GeomWithData::new(bbox, joint_id), ());
|
||||
|
||||
if let Some(pin_id) = pin_id {
|
||||
self.pins[pin_id.index()].joints.push(joint_id);
|
||||
self.pins
|
||||
.modify(pin_id.index(), |pin| pin.joints.push(joint_id));
|
||||
}
|
||||
|
||||
joint_id
|
||||
|
|
@ -204,7 +161,8 @@ impl Layout {
|
|||
.insert(GeomWithData::new(bbox, segment_id), ());
|
||||
|
||||
if let Some(pin_id) = pin_id {
|
||||
self.pins[pin_id.index()].segments.push(segment_id);
|
||||
self.pins
|
||||
.modify(pin_id.index(), |pin| pin.segments.push(segment_id));
|
||||
}
|
||||
|
||||
segment_id
|
||||
|
|
@ -274,7 +232,8 @@ impl Layout {
|
|||
self.vias_rtree.insert(GeomWithData::new(bbox, via_id), ());
|
||||
|
||||
if let Some(pin_id) = pin_id {
|
||||
self.pins[pin_id.index()].vias.push(via_id);
|
||||
self.pins
|
||||
.modify(pin_id.index(), |pin| pin.vias.push(via_id));
|
||||
}
|
||||
|
||||
via_id
|
||||
|
|
@ -326,7 +285,8 @@ impl Layout {
|
|||
.insert(GeomWithData::new(bbox, polygon_id), ());
|
||||
|
||||
if let Some(pin_id) = pin_id {
|
||||
self.pins[pin_id.index()].polygons.push(polygon_id);
|
||||
self.pins
|
||||
.modify(pin_id.index(), |pin| pin.polygons.push(polygon_id));
|
||||
}
|
||||
|
||||
polygon_id
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
mod autorouter;
|
||||
mod board;
|
||||
mod compounds;
|
||||
mod drawer;
|
||||
mod layout;
|
||||
mod math;
|
||||
|
|
@ -17,6 +18,7 @@ mod specctra;
|
|||
|
||||
pub use crate::autorouter::Autorouter;
|
||||
pub use crate::board::Board;
|
||||
pub use crate::compounds::{Pin, PinId};
|
||||
pub use crate::layout::Layout;
|
||||
pub use crate::math::Vector2;
|
||||
pub use crate::primitives::{
|
||||
|
|
|
|||
|
|
@ -10,7 +10,9 @@ use stable_vec::StableVec;
|
|||
use undoredo::Recorder;
|
||||
|
||||
use crate::{
|
||||
Board, Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Vector2, primitives::JointSpec,
|
||||
Board,
|
||||
math::Vector2,
|
||||
primitives::{Joint, JointId, JointSpec, Polygon, PolygonId, Segment, SegmentId},
|
||||
};
|
||||
|
||||
#[derive(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use derive_more::Constructor;
|
|||
use rstar::{AABB, primitives::Rectangle};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::layout::{NetId, PinId};
|
||||
use crate::compounds::{NetId, PinId};
|
||||
use crate::math::Vector2;
|
||||
use crate::primitives::{SegmentId, ViaId};
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use derive_more::Constructor;
|
|||
use rstar::{AABB, Envelope, primitives::Rectangle};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::layout::{NetId, PinId};
|
||||
use crate::compounds::{NetId, PinId};
|
||||
use crate::math::Vector2;
|
||||
|
||||
#[derive(
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use derive_more::Constructor;
|
|||
use rstar::primitives::Rectangle;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::layout::{NetId, PinId};
|
||||
use crate::compounds::{NetId, PinId};
|
||||
use crate::math::Vector2;
|
||||
use crate::primitives::JointId;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,10 +6,9 @@ use derive_more::Constructor;
|
|||
use rstar::{AABB, primitives::Rectangle};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::layout::{NetId, PinId};
|
||||
use crate::compounds::{NetId, PinId};
|
||||
use crate::math::Vector2;
|
||||
|
||||
use super::joint::JointId;
|
||||
use crate::primitives::JointId;
|
||||
|
||||
#[derive(
|
||||
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ use serde::{Deserialize, Serialize};
|
|||
use spade::{DelaunayTriangulation, HasPosition, Triangulation, handles::FixedVertexHandle};
|
||||
|
||||
use crate::{
|
||||
Board, JointId, PolygonId, SegmentId, Vector2, layout::NetId, primitives::PrimitiveId,
|
||||
Board,
|
||||
compounds::NetId,
|
||||
math::Vector2,
|
||||
primitives::{JointId, PolygonId, PrimitiveId, SegmentId},
|
||||
};
|
||||
|
||||
#[derive(Clone, Copy, Debug, Deserialize, Eq, Getters, Ord, PartialEq, PartialOrd, Serialize)]
|
||||
|
|
|
|||
|
|
@ -11,10 +11,11 @@ use specctra::{
|
|||
};
|
||||
|
||||
use crate::{
|
||||
Segment, Vector2,
|
||||
board::Board,
|
||||
layout::{NetId, PinId},
|
||||
primitives::{JointSpec, Polygon, SegmentSpec},
|
||||
compounds::NetId,
|
||||
compounds::PinId,
|
||||
math::Vector2,
|
||||
primitives::{JointSpec, Polygon, Segment, SegmentSpec},
|
||||
};
|
||||
|
||||
impl Board {
|
||||
|
|
|
|||
Loading…
Reference in New Issue