mirror of https://codeberg.org/topola/topola.git
Do some renamings, some changes in `Cargo.toml`
This commit is contained in:
parent
2f52c1e236
commit
a4d13a3435
|
|
@ -9,7 +9,7 @@ resolver = "2"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
derive-getters = "0.5"
|
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"] }
|
serde = { version = "1", features = ["derive", "rc"] }
|
||||||
thiserror = "2.0"
|
thiserror = "2.0"
|
||||||
undoredo = { version = "0.8", features = ["stable-vec"] }
|
undoredo = { version = "0.8", features = ["stable-vec"] }
|
||||||
|
|
|
||||||
|
|
@ -165,16 +165,16 @@ impl Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn segment_endpoints(&self, segment_id: SegmentId) -> [Vector2<i64>; 2] {
|
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[0].index()).unwrap().position,
|
||||||
self.joints.get(&endjoints[1].id()).unwrap().position,
|
self.joints.get(&endjoints[1].index()).unwrap().position,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn segment_contains_point(&self, segment_id: SegmentId, point: Vector2<i64>) -> bool {
|
pub fn segment_contains_point(&self, segment_id: SegmentId, point: Vector2<i64>) -> bool {
|
||||||
let endpoints = self.segment_endpoints(segment_id);
|
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(
|
let vertices = crate::math::inflated_segment(
|
||||||
endpoints[0].x,
|
endpoints[0].x,
|
||||||
endpoints[0].y,
|
endpoints[0].y,
|
||||||
|
|
@ -187,8 +187,8 @@ impl Layout {
|
||||||
|
|
||||||
pub fn segment_bbox(&self, segment_id: SegmentId) -> Rectangle<[i64; 3]> {
|
pub fn segment_bbox(&self, segment_id: SegmentId) -> Rectangle<[i64; 3]> {
|
||||||
let endpoints = self.segment_endpoints(segment_id);
|
let endpoints = self.segment_endpoints(segment_id);
|
||||||
let layer = self.segments.get(&segment_id.id()).unwrap().layer as i64;
|
let layer = self.segments.get(&segment_id.index()).unwrap().layer as i64;
|
||||||
let half_width = self.segments.get(&segment_id.id()).unwrap().half_width 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_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;
|
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)
|
.map(|geom_with_data| geom_with_data.data)
|
||||||
.filter(move |joint_id| {
|
.filter(move |joint_id| {
|
||||||
self.joints
|
self.joints
|
||||||
.get(&joint_id.id())
|
.get(&joint_id.index())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.contains_point(point)
|
.contains_point(point)
|
||||||
})
|
})
|
||||||
|
|
@ -240,22 +240,22 @@ impl Layout {
|
||||||
.map(|geom_with_data| geom_with_data.data)
|
.map(|geom_with_data| geom_with_data.data)
|
||||||
.filter(move |polygon_id| {
|
.filter(move |polygon_id| {
|
||||||
self.polygons
|
self.polygons
|
||||||
.get(&polygon_id.id())
|
.get(&polygon_id.index())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.contains_point(point)
|
.contains_point(point)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn joint(&self, joint_id: JointId) -> &Joint {
|
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 {
|
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 {
|
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 {
|
pub fn pin(&self, pin_id: PinId) -> &Pin {
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ mod layout;
|
||||||
mod math;
|
mod math;
|
||||||
mod navmesher;
|
mod navmesher;
|
||||||
mod primitives;
|
mod primitives;
|
||||||
|
//mod ratsnests;
|
||||||
mod selection;
|
mod selection;
|
||||||
mod specctra;
|
mod specctra;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ impl NavmesherBoard {
|
||||||
pub fn insert_joint(&mut self, joint: Joint) -> JointId {
|
pub fn insert_joint(&mut self, joint: Joint) -> JointId {
|
||||||
let joint_id = self.board.add_joint(joint);
|
let joint_id = self.board.add_joint(joint);
|
||||||
self.joint_multiobstacles.insert(
|
self.joint_multiobstacles.insert(
|
||||||
joint_id.id(),
|
joint_id.index(),
|
||||||
self.navmesher
|
self.navmesher
|
||||||
.insert_multiobstacle(joint.layer, Self::joint_bounding_octagon(joint)),
|
.insert_multiobstacle(joint.layer, Self::joint_bounding_octagon(joint)),
|
||||||
);
|
);
|
||||||
|
|
@ -262,7 +262,7 @@ impl NavmesherBoard {
|
||||||
pub fn insert_segment(&mut self, segment: Segment) -> SegmentId {
|
pub fn insert_segment(&mut self, segment: Segment) -> SegmentId {
|
||||||
let segment_id = self.board.add_segment(segment);
|
let segment_id = self.board.add_segment(segment);
|
||||||
self.segment_multiobstacles.insert(
|
self.segment_multiobstacles.insert(
|
||||||
segment_id.id(),
|
segment_id.index(),
|
||||||
self.navmesher.insert_multiobstacle(
|
self.navmesher.insert_multiobstacle(
|
||||||
segment.layer,
|
segment.layer,
|
||||||
self.segment_bounding_rectangle(segment_id, segment),
|
self.segment_bounding_rectangle(segment_id, segment),
|
||||||
|
|
@ -295,7 +295,7 @@ impl NavmesherBoard {
|
||||||
pub fn insert_polygon(&mut self, polygon: Polygon) -> PolygonId {
|
pub fn insert_polygon(&mut self, polygon: Polygon) -> PolygonId {
|
||||||
let polygon_id = self.board.add_polygon(polygon.clone());
|
let polygon_id = self.board.add_polygon(polygon.clone());
|
||||||
self.polygon_multiobstacles.insert(
|
self.polygon_multiobstacles.insert(
|
||||||
polygon_id.id(),
|
polygon_id.index(),
|
||||||
self.navmesher
|
self.navmesher
|
||||||
.insert_multiobstacle(polygon.layer, polygon.vertices),
|
.insert_multiobstacle(polygon.layer, polygon.vertices),
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,13 @@ use crate::{
|
||||||
layout::{NetId, PinId},
|
layout::{NetId, PinId},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)]
|
||||||
|
pub enum PrimitiveId {
|
||||||
|
Joint(JointId),
|
||||||
|
Segment(SegmentId),
|
||||||
|
Polygon(PolygonId),
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(
|
#[derive(
|
||||||
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
Clone, Constructor, Copy, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize,
|
||||||
)]
|
)]
|
||||||
|
|
@ -19,7 +26,7 @@ pub struct JointId(usize);
|
||||||
impl JointId {
|
impl JointId {
|
||||||
/// Returns the underlying index.
|
/// Returns the underlying index.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id(self) -> usize {
|
pub fn index(self) -> usize {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -63,7 +70,7 @@ pub struct SegmentId(usize);
|
||||||
impl SegmentId {
|
impl SegmentId {
|
||||||
/// Returns the underlying index.
|
/// Returns the underlying index.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id(self) -> usize {
|
pub fn index(self) -> usize {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -85,7 +92,7 @@ pub struct ViaId(usize);
|
||||||
impl ViaId {
|
impl ViaId {
|
||||||
/// Returns the underlying index.
|
/// Returns the underlying index.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id(self) -> usize {
|
pub fn index(self) -> usize {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +120,7 @@ pub struct PolygonId(usize);
|
||||||
impl PolygonId {
|
impl PolygonId {
|
||||||
/// Returns the underlying index.
|
/// Returns the underlying index.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn id(self) -> usize {
|
pub fn index(self) -> usize {
|
||||||
self.0
|
self.0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue