Compare commits

..

No commits in common. "4afd0d7e3d3544e7c02e7e856053ba6a1daa1109" and "d77be1b0b36cab0fae0c965b9fc0c5bba97975c8" have entirely different histories.

7 changed files with 125 additions and 190 deletions

View File

@ -6,9 +6,9 @@ use bimap::BiBTreeMap;
use derive_getters::{Dissolve, Getters};
use undoredo::{ApplyDelta, Delta, FlushDelta};
use crate::{
layout::{Layout, LayoutHalfDelta, NetId, PinId},
primitives::{Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Via, ViaId},
use crate::layout::{
Joint, JointId, Layout, LayoutHalfDelta, NetId, PinId, Polygon, PolygonId, Segment, SegmentId,
Via, ViaId,
};
#[derive(Clone, Debug, Getters)]

View File

@ -5,19 +5,19 @@
use std::collections::BTreeMap;
use derive_getters::{Dissolve, Getters};
use derive_more::Constructor;
use serde::{Deserialize, Serialize};
use stable_vec::StableVec;
use undoredo::{ApplyDelta, Delta, FlushDelta, Recorder};
use crate::{Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Via, ViaId};
#[derive(
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
)]
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct PinId(usize);
impl PinId {
/// Wrap a pin index in a newtype struct.
#[inline]
pub fn new(id: usize) -> Self {
Self(id)
}
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
@ -44,12 +44,16 @@ impl Pin {
}
}
#[derive(
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
)]
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct NetId(usize);
impl NetId {
/// Wrap a joint index in a newtype struct.
#[inline]
pub fn new(id: usize) -> Self {
Self(id)
}
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
@ -57,6 +61,109 @@ impl NetId {
}
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct JointId(usize);
impl JointId {
/// Wrap a joint index in a newtype struct.
#[inline]
pub fn new(id: usize) -> Self {
Self(id)
}
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
self.0
}
}
#[derive(Clone, Copy, Debug)]
pub struct Joint {
pub position: [i64; 2],
pub layer: usize,
pub radius: u64,
pub net: NetId,
pub pin: Option<PinId>,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct SegmentId(usize);
impl SegmentId {
/// Wrap a segment index in a newtype struct.
#[inline]
pub fn new(id: usize) -> Self {
Self(id)
}
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
self.0
}
}
#[derive(Clone, Copy, Debug)]
pub struct Segment {
pub endjoints: [JointId; 2],
pub layer: usize,
pub half_width: u64,
pub net: NetId,
pub pin: Option<PinId>,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct ViaId(usize);
impl ViaId {
/// Wrap a via index in a newtype struct.
#[inline]
pub fn new(id: usize) -> Self {
Self(id)
}
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
self.0
}
}
#[derive(Clone, Copy, Debug)]
pub struct Via {
pub endpoints: [JointId; 2],
pub layer: usize,
pub radius: u64,
pub net: NetId,
pub pin: Option<PinId>,
}
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub struct PolygonId(usize);
impl PolygonId {
/// Wrap a polygon index in a newtype struct.
#[inline]
pub fn new(id: usize) -> Self {
Self(id)
}
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
self.0
}
}
#[derive(Clone, Debug)]
pub struct Polygon {
pub vertices: Vec<[i64; 2]>,
pub layer: usize,
pub net: NetId,
pub pin: Option<PinId>,
}
#[derive(Clone, Debug, Getters)]
pub struct Layout {
boundary: Vec<[i64; 2]>,

View File

@ -6,11 +6,10 @@ mod board;
mod layout;
mod math;
mod navmesher;
mod primitives;
mod selection;
mod specctra;
pub use crate::board::Board;
pub use crate::layout::Layout;
pub use crate::layout::{
Joint, JointId, Layout, Polygon, PolygonId, Segment, SegmentId, Via, ViaId,
};
pub use crate::navmesher::NavmesherBoard;
pub use crate::primitives::{Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Via, ViaId};

View File

@ -7,7 +7,7 @@ use derive_getters::Getters;
use crate::{
Board,
primitives::{Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Via, ViaId},
layout::{Joint, JointId, Polygon, PolygonId, Segment, SegmentId, Via, ViaId},
};
#[derive(Clone, Debug, Getters)]

View File

@ -1,142 +0,0 @@
// SPDX-FileCopyrightText: 2026 Topola contributors
//
// SPDX-License-Identifier: MIT OR Apache-2.0
use derive_more::{Constructor, From};
use serde::{Deserialize, Serialize};
use crate::{
layout::{NetId, PinId},
selection::PinSelector,
};
#[derive(Clone, Copy, Debug, Deserialize, Eq, From, Ord, PartialEq, PartialOrd, Serialize)]
pub enum PrimitiveId {
Joint(JointId),
Segment(SegmentId),
Via(ViaId),
Polygon(PolygonId),
}
#[derive(
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
)]
pub struct JointId(usize);
impl JointId {
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
self.0
}
}
#[derive(Clone, Copy, Debug)]
pub struct Joint {
pub position: [i64; 2],
pub layer: usize,
pub radius: u64,
pub net: NetId,
pub pin: Option<PinId>,
}
impl Joint {
pub fn pin_selector(&self) -> Option<PinSelector> {
Some(PinSelector {
pin: self.pin?,
layer: self.layer,
})
}
}
#[derive(
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
)]
pub struct SegmentId(usize);
impl SegmentId {
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
self.0
}
}
#[derive(Clone, Copy, Debug)]
pub struct Segment {
pub endjoints: [JointId; 2],
pub layer: usize,
pub half_width: u64,
pub net: NetId,
pub pin: Option<PinId>,
}
impl Segment {
pub fn pin_selector(&self) -> Option<PinSelector> {
Some(PinSelector {
pin: self.pin?,
layer: self.layer,
})
}
}
#[derive(
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
)]
pub struct ViaId(usize);
impl ViaId {
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
self.0
}
}
#[derive(Clone, Copy, Debug)]
pub struct Via {
pub endpoints: [JointId; 2],
pub layer: usize, // ??? This should be a range.
pub radius: u64,
pub net: NetId,
pub pin: Option<PinId>,
}
impl Via {
pub fn pin_selector(&self) -> Option<PinSelector> {
Some(PinSelector {
pin: self.pin?,
layer: self.layer,
})
}
}
#[derive(
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
)]
pub struct PolygonId(usize);
impl PolygonId {
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
self.0
}
}
#[derive(Clone, Debug)]
pub struct Polygon {
pub vertices: Vec<[i64; 2]>,
pub layer: usize,
pub net: NetId,
pub pin: Option<PinId>,
}
impl Polygon {
pub fn pin_selector(&self) -> Option<PinSelector> {
Some(PinSelector {
pin: self.pin?,
layer: self.layer,
})
}
}

View File

@ -1,28 +0,0 @@
// SPDX-FileCopyrightText: 2026 Topola contributors
//
// SPDX-License-Identifier: MIT OR Apache-2.0
use std::collections::BTreeSet;
use serde::{Deserialize, Serialize};
use crate::layout::PinId;
#[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub struct PinSelector {
pub pin: PinId,
pub layer: usize,
}
#[derive(Clone, Debug, Deserialize, Eq, PartialEq, Serialize)]
pub struct PinSelection(pub BTreeSet<PinSelector>);
impl PinSelection {
pub fn toggle(&mut self, pin_selector: PinSelector) {
if self.0.contains(&pin_selector) {
self.0.remove(&pin_selector);
} else {
self.0.insert(pin_selector);
}
}
}

View File

@ -13,9 +13,8 @@ use specctra::{
use crate::{
Segment,
board::Board,
layout::{NetId, PinId},
layout::{Joint, NetId, PinId, Polygon},
math::Vector2,
primitives::{Joint, Polygon},
};
impl Board {