Do some renamings, some changes in `Cargo.toml`

This commit is contained in:
Mikolaj Wielgus 2026-03-19 14:27:32 +01:00
parent 2f52c1e236
commit a4d13a3435
5 changed files with 27 additions and 19 deletions

View File

@ -9,7 +9,7 @@ resolver = "2"
[workspace.dependencies]
derive-getters = "0.5"
derive_more = { version = "2.1", features = ["add", "constructor", "from", "into"] }
derive_more = { version = "2.1", features = ["full"] }
serde = { version = "1", features = ["derive", "rc"] }
thiserror = "2.0"
undoredo = { version = "0.8", features = ["stable-vec"] }

View File

@ -165,16 +165,16 @@ impl Layout {
}
pub fn segment_endpoints(&self, segment_id: SegmentId) -> [Vector2<i64>; 2] {
let endjoints = self.segments.get(&segment_id.id()).unwrap().endjoints;
let endjoints = self.segments.get(&segment_id.index()).unwrap().endjoints;
[
self.joints.get(&endjoints[0].id()).unwrap().position,
self.joints.get(&endjoints[1].id()).unwrap().position,
self.joints.get(&endjoints[0].index()).unwrap().position,
self.joints.get(&endjoints[1].index()).unwrap().position,
]
}
pub fn segment_contains_point(&self, segment_id: SegmentId, point: Vector2<i64>) -> bool {
let endpoints = self.segment_endpoints(segment_id);
let segment = self.segments.get(&segment_id.id()).unwrap();
let segment = self.segments.get(&segment_id.index()).unwrap();
let vertices = crate::math::inflated_segment(
endpoints[0].x,
endpoints[0].y,
@ -187,8 +187,8 @@ impl Layout {
pub fn segment_bbox(&self, segment_id: SegmentId) -> Rectangle<[i64; 3]> {
let endpoints = self.segment_endpoints(segment_id);
let layer = self.segments.get(&segment_id.id()).unwrap().layer as i64;
let half_width = self.segments.get(&segment_id.id()).unwrap().half_width as i64;
let layer = self.segments.get(&segment_id.index()).unwrap().layer as i64;
let half_width = self.segments.get(&segment_id.index()).unwrap().half_width as i64;
let min_x = std::cmp::min(endpoints[0].x, endpoints[1].x) - half_width;
let min_y = std::cmp::min(endpoints[0].y, endpoints[1].y) - half_width;
@ -209,7 +209,7 @@ impl Layout {
.map(|geom_with_data| geom_with_data.data)
.filter(move |joint_id| {
self.joints
.get(&joint_id.id())
.get(&joint_id.index())
.unwrap()
.contains_point(point)
})
@ -240,22 +240,22 @@ impl Layout {
.map(|geom_with_data| geom_with_data.data)
.filter(move |polygon_id| {
self.polygons
.get(&polygon_id.id())
.get(&polygon_id.index())
.unwrap()
.contains_point(point)
})
}
pub fn joint(&self, joint_id: JointId) -> &Joint {
self.joints.get(&joint_id.id()).unwrap()
self.joints.get(&joint_id.index()).unwrap()
}
pub fn segment(&self, segment_id: SegmentId) -> &Segment {
self.segments.get(&segment_id.id()).unwrap()
self.segments.get(&segment_id.index()).unwrap()
}
pub fn polygon(&self, polygon_id: PolygonId) -> &Polygon {
self.polygons.get(&polygon_id.id()).unwrap()
self.polygons.get(&polygon_id.index()).unwrap()
}
pub fn pin(&self, pin_id: PinId) -> &Pin {

View File

@ -7,6 +7,7 @@ mod layout;
mod math;
mod navmesher;
mod primitives;
//mod ratsnests;
mod selection;
mod specctra;

View File

@ -234,7 +234,7 @@ impl NavmesherBoard {
pub fn insert_joint(&mut self, joint: Joint) -> JointId {
let joint_id = self.board.add_joint(joint);
self.joint_multiobstacles.insert(
joint_id.id(),
joint_id.index(),
self.navmesher
.insert_multiobstacle(joint.layer, Self::joint_bounding_octagon(joint)),
);
@ -262,7 +262,7 @@ impl NavmesherBoard {
pub fn insert_segment(&mut self, segment: Segment) -> SegmentId {
let segment_id = self.board.add_segment(segment);
self.segment_multiobstacles.insert(
segment_id.id(),
segment_id.index(),
self.navmesher.insert_multiobstacle(
segment.layer,
self.segment_bounding_rectangle(segment_id, segment),
@ -295,7 +295,7 @@ impl NavmesherBoard {
pub fn insert_polygon(&mut self, polygon: Polygon) -> PolygonId {
let polygon_id = self.board.add_polygon(polygon.clone());
self.polygon_multiobstacles.insert(
polygon_id.id(),
polygon_id.index(),
self.navmesher
.insert_multiobstacle(polygon.layer, polygon.vertices),
);

View File

@ -11,6 +11,13 @@ use crate::{
layout::{NetId, PinId},
};
#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
pub enum PrimitiveId {
Joint(JointId),
Segment(SegmentId),
Polygon(PolygonId),
}
#[derive(
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
)]
@ -19,7 +26,7 @@ pub struct JointId(usize);
impl JointId {
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
pub fn index(self) -> usize {
self.0
}
}
@ -63,7 +70,7 @@ pub struct SegmentId(usize);
impl SegmentId {
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
pub fn index(self) -> usize {
self.0
}
}
@ -85,7 +92,7 @@ pub struct ViaId(usize);
impl ViaId {
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
pub fn index(self) -> usize {
self.0
}
}
@ -113,7 +120,7 @@ pub struct PolygonId(usize);
impl PolygonId {
/// Returns the underlying index.
#[inline]
pub fn id(self) -> usize {
pub fn index(self) -> usize {
self.0
}
}