cleanup: get rid of `*Trait` names for traits, use verbs and sentences

This commit is contained in:
Mikolaj Wielgus 2024-07-03 13:40:37 +02:00
parent b1f60847b3
commit 806742736a
47 changed files with 295 additions and 286 deletions

View File

@ -5,7 +5,7 @@ use crate::{
invoker::{GetMaybeNavmesh, GetMaybeTrace},
Autorouter, AutorouterError, AutorouterStatus,
},
board::mesadata::MesadataTrait,
board::mesadata::AccessMesadata,
router::{navmesh::Navmesh, route::Route, trace::Trace, Router, RouterStatus},
};
@ -17,7 +17,7 @@ pub struct Autoroute {
impl Autoroute {
pub fn new(
autorouter: &mut Autorouter<impl MesadataTrait>,
autorouter: &mut Autorouter<impl AccessMesadata>,
ratlines: impl IntoIterator<Item = EdgeIndex<usize>> + 'static,
) -> Result<Self, AutorouterError> {
let mut ratlines_iter = Box::new(ratlines.into_iter());
@ -38,7 +38,7 @@ impl Autoroute {
Ok(this)
}
pub fn step<M: MesadataTrait>(
pub fn step<M: AccessMesadata>(
&mut self,
autorouter: &mut Autorouter<M>,
) -> Result<AutorouterStatus, AutorouterError> {

View File

@ -9,7 +9,7 @@ use crate::{
ratsnest::{Ratsnest, RatvertexIndex},
selection::Selection,
},
board::{mesadata::MesadataTrait, Board},
board::{mesadata::AccessMesadata, Board},
drawing::{dot::FixedDotIndex, Infringement},
layout::via::ViaWeight,
router::{navmesh::NavmeshError, RouterError},
@ -33,12 +33,12 @@ pub enum AutorouterStatus {
Finished,
}
pub struct Autorouter<M: MesadataTrait> {
pub struct Autorouter<M: AccessMesadata> {
pub(super) board: Board<M>,
pub(super) ratsnest: Ratsnest,
}
impl<M: MesadataTrait> Autorouter<M> {
impl<M: AccessMesadata> Autorouter<M> {
pub fn new(board: Board<M>) -> Result<Self, InsertionError> {
let ratsnest = Ratsnest::new(board.layout())?;
Ok(Self { board, ratsnest })

View File

@ -11,7 +11,7 @@ use crate::{
selection::Selection,
Autorouter, AutorouterError, AutorouterStatus,
},
board::mesadata::MesadataTrait,
board::mesadata::AccessMesadata,
layout::via::ViaWeight,
router::{navmesh::Navmesh, trace::Trace},
};
@ -53,7 +53,7 @@ pub enum Execute {
}
impl Execute {
pub fn step<M: MesadataTrait>(
pub fn step<M: AccessMesadata>(
&mut self,
invoker: &mut Invoker<M>,
) -> Result<InvokerStatus, InvokerError> {
@ -73,7 +73,7 @@ impl Execute {
}
}
fn step_catch_err<M: MesadataTrait>(
fn step_catch_err<M: AccessMesadata>(
&mut self,
invoker: &mut Invoker<M>,
) -> Result<InvokerStatus, InvokerError> {
@ -103,7 +103,7 @@ impl ExecuteWithStatus {
}
}
pub fn step<M: MesadataTrait>(
pub fn step<M: AccessMesadata>(
&mut self,
invoker: &mut Invoker<M>,
) -> Result<InvokerStatus, InvokerError> {
@ -129,13 +129,13 @@ impl GetMaybeTrace for ExecuteWithStatus {
}
}
pub struct Invoker<M: MesadataTrait> {
pub struct Invoker<M: AccessMesadata> {
autorouter: Autorouter<M>,
history: History,
ongoing_command: Option<Command>,
}
impl<M: MesadataTrait> Invoker<M> {
impl<M: AccessMesadata> Invoker<M> {
pub fn new(autorouter: Autorouter<M>) -> Self {
Self::new_with_history(autorouter, History::new())
}

View File

@ -3,7 +3,7 @@ use crate::{
invoker::{GetMaybeNavmesh, GetMaybeTrace},
Autorouter, AutorouterError,
},
board::mesadata::MesadataTrait,
board::mesadata::AccessMesadata,
layout::via::ViaWeight,
router::{navmesh::Navmesh, trace::Trace},
};
@ -20,7 +20,7 @@ impl PlaceVia {
pub fn doit(
&mut self,
autorouter: &mut Autorouter<impl MesadataTrait>,
autorouter: &mut Autorouter<impl AccessMesadata>,
) -> Result<(), AutorouterError> {
autorouter.place_via(self.weight)
}

View File

@ -16,9 +16,9 @@ use crate::{
dot::FixedDotIndex,
graph::{GetMaybeNet, MakePrimitive, PrimitiveIndex},
primitive::MakePrimitiveShape,
rules::RulesTrait,
rules::AccessRules,
},
geometry::{compound::CompoundManagerTrait, shape::ShapeTrait},
geometry::{compound::ManageCompounds, shape::AccessShape},
graph::{GenericIndex, GetPetgraphIndex},
layout::{
zone::{MakePolyShape, ZoneWeight},
@ -72,7 +72,7 @@ pub struct Ratsnest {
}
impl Ratsnest {
pub fn new(layout: &Layout<impl RulesTrait>) -> Result<Self, InsertionError> {
pub fn new(layout: &Layout<impl AccessRules>) -> Result<Self, InsertionError> {
let mut unionfind = UnionFind::new(layout.drawing().geometry().graph().node_bound());
for edge in layout.drawing().geometry().graph().edge_references() {

View File

@ -3,9 +3,9 @@ use std::collections::HashSet;
use serde::{Deserialize, Serialize};
use crate::{
board::{mesadata::MesadataTrait, Board},
board::{mesadata::AccessMesadata, Board},
drawing::graph::{GetLayer, MakePrimitive},
geometry::compound::CompoundManagerTrait,
geometry::compound::ManageCompounds,
graph::{GenericIndex, GetPetgraphIndex},
layout::{zone::ZoneWeight, CompoundWeight, NodeIndex},
};
@ -28,7 +28,7 @@ impl Selection {
}
}
pub fn toggle_at_node(&mut self, board: &Board<impl MesadataTrait>, node: NodeIndex) {
pub fn toggle_at_node(&mut self, board: &Board<impl AccessMesadata>, node: NodeIndex) {
let Some(selector) = self.node_selector(board, node) else {
return;
};
@ -40,15 +40,15 @@ impl Selection {
}
}
fn select(&mut self, board: &Board<impl MesadataTrait>, selector: Selector) {
fn select(&mut self, board: &Board<impl AccessMesadata>, selector: Selector) {
self.selectors.insert(selector);
}
fn deselect(&mut self, board: &Board<impl MesadataTrait>, selector: &Selector) {
fn deselect(&mut self, board: &Board<impl AccessMesadata>, selector: &Selector) {
self.selectors.remove(selector);
}
pub fn contains_node(&self, board: &Board<impl MesadataTrait>, node: NodeIndex) -> bool {
pub fn contains_node(&self, board: &Board<impl AccessMesadata>, node: NodeIndex) -> bool {
let Some(selector) = self.node_selector(board, node) else {
return false;
};
@ -58,7 +58,7 @@ impl Selection {
fn node_selector(
&self,
board: &Board<impl MesadataTrait>,
board: &Board<impl AccessMesadata>,
node: NodeIndex,
) -> Option<Selector> {
let layer = match node {

View File

@ -20,13 +20,13 @@ use topola::{
dot::FixedDotIndex,
graph::{MakePrimitive, PrimitiveIndex},
primitive::MakePrimitiveShape,
rules::RulesTrait,
rules::AccessRules,
Drawing, Infringement, LayoutException,
},
geometry::{
compound::CompoundManagerTrait,
primitive::{BendShape, DotShape, PrimitiveShape, PrimitiveShapeTrait, SegShape},
shape::ShapeTrait,
compound::ManageCompounds,
primitive::{AccessPrimitiveShape, BendShape, DotShape, PrimitiveShape, SegShape},
shape::AccessShape,
GenericNode,
},
layout::{via::ViaWeight, zone::MakePolyShape, Layout},

View File

@ -1,4 +1,4 @@
use topola::board::{mesadata::MesadataTrait, Board};
use topola::board::{mesadata::AccessMesadata, Board};
pub struct Layers {
// TODO:
@ -10,7 +10,7 @@ pub struct Layers {
}
impl Layers {
pub fn new(board: &Board<impl MesadataTrait>) -> Self {
pub fn new(board: &Board<impl AccessMesadata>) -> Self {
let layer_count = board.layout().drawing().layer_count();
let visible = std::iter::repeat(true)
.take(layer_count)
@ -65,7 +65,7 @@ impl Layers {
}
}
pub fn update(&mut self, ctx: &egui::Context, board: &Board<impl MesadataTrait>) {
pub fn update(&mut self, ctx: &egui::Context, board: &Board<impl AccessMesadata>) {
egui::SidePanel::right("right_side_panel").show(ctx, |ui| {
ui.label("Layers");

View File

@ -6,14 +6,14 @@ use spade::InsertionError;
use topola::{
autorouter::{ratsnest::Ratsnest, selection::Selection},
board::{mesadata::MesadataTrait, Board},
board::{mesadata::AccessMesadata, Board},
drawing::{
graph::{GetLayer, MakePrimitive},
primitive::MakePrimitiveShape,
},
geometry::{
compound::CompoundManagerTrait,
shape::{Shape, ShapeTrait},
compound::ManageCompounds,
shape::{AccessShape, Shape},
},
graph::{GenericIndex, GetPetgraphIndex},
layout::{
@ -30,7 +30,7 @@ pub struct Overlay {
}
impl Overlay {
pub fn new(board: &Board<impl MesadataTrait>) -> Result<Self, InsertionError> {
pub fn new(board: &Board<impl AccessMesadata>) -> Result<Self, InsertionError> {
Ok(Self {
ratsnest: Ratsnest::new(board.layout())?,
selection: Selection::new(),
@ -38,7 +38,7 @@ impl Overlay {
})
}
pub fn click(&mut self, board: &Board<impl MesadataTrait>, at: Point) {
pub fn click(&mut self, board: &Board<impl AccessMesadata>, at: Point) {
let geoms: Vec<_> = board
.layout()
.drawing()
@ -60,7 +60,12 @@ impl Overlay {
}
}
fn contains_point(&self, board: &Board<impl MesadataTrait>, node: NodeIndex, p: Point) -> bool {
fn contains_point(
&self,
board: &Board<impl AccessMesadata>,
node: NodeIndex,
p: Point,
) -> bool {
let shape: Shape = match node {
NodeIndex::Primitive(primitive) => {
primitive.primitive(board.layout().drawing()).shape().into()

View File

@ -1,6 +1,6 @@
use geo::{CoordsIter, Point, Polygon};
use topola::{
geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait},
geometry::primitive::{AccessPrimitiveShape, PrimitiveShape},
math::{self, Circle},
};
@ -54,7 +54,7 @@ impl<'a> Painter<'a> {
self.ui.painter().add(epaint_shape);
let envelope = PrimitiveShapeTrait::envelope(shape, 0.0);
let envelope = AccessPrimitiveShape::envelope(shape, 0.0);
let rect = egui::epaint::Rect {
min: [envelope.lower()[0] as f32, -envelope.upper()[1] as f32].into(),
max: [envelope.upper()[0] as f32, -envelope.lower()[1] as f32].into(),

View File

@ -5,12 +5,12 @@ use petgraph::{
};
use topola::{
autorouter::invoker::{Command, ExecuteWithStatus, GetMaybeNavmesh, GetMaybeTrace, Invoker},
board::mesadata::MesadataTrait,
board::mesadata::AccessMesadata,
drawing::{
graph::{MakePrimitive, PrimitiveIndex},
primitive::MakePrimitiveShape,
},
geometry::{shape::ShapeTrait, GenericNode},
geometry::{shape::AccessShape, GenericNode},
layout::{via::ViaWeight, zone::MakePolyShape},
math::Circle,
specctra::mesadata::SpecctraMesadata,

View File

@ -18,11 +18,11 @@ use topola::autorouter::{Autorouter, AutorouterStatus};
use topola::drawing::dot::FixedDotWeight;
use topola::drawing::graph::{MakePrimitive, PrimitiveIndex};
use topola::drawing::primitive::MakePrimitiveShape;
use topola::drawing::rules::{Conditions, RulesTrait};
use topola::drawing::rules::{AccessRules, Conditions};
use topola::drawing::seg::FixedSegWeight;
use topola::drawing::{Infringement, LayoutException};
use topola::geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait};
use topola::geometry::shape::ShapeTrait;
use topola::geometry::primitive::{AccessPrimitiveShape, PrimitiveShape};
use topola::geometry::shape::AccessShape;
use topola::layout::zone::MakePolyShape;
use topola::layout::Layout;
use topola::router::draw::DrawException;
@ -56,7 +56,7 @@ struct SimpleRules {
net_clearances: HashMap<(usize, usize), f64>,
}
impl RulesTrait for SimpleRules {
impl AccessRules for SimpleRules {
fn clearance(&self, conditions1: &Conditions, conditions2: &Conditions) -> f64 {
if let (Some(net1), Some(net2)) = (conditions1.maybe_net, conditions2.maybe_net) {
*self.net_clearances.get(&(net1, net2)).unwrap_or(&10.0)
@ -81,7 +81,7 @@ impl RulesTrait for SimpleRules {
}
// Clunky enum to work around borrow checker.
enum RouterOrLayout<'a, R: RulesTrait> {
enum RouterOrLayout<'a, R: AccessRules> {
Router(&'a mut Route<'a, R>),
Layout(&'a Layout<R>),
}
@ -222,7 +222,7 @@ fn render_times(
renderer: &mut Renderer<GLDevice>,
font_context: &CanvasFontContext,
view: &mut View,
mut router_or_layout: RouterOrLayout<impl RulesTrait>,
mut router_or_layout: RouterOrLayout<impl AccessRules>,
_unused: Option<()>,
mut maybe_navmesh: Option<Navmesh>,
path: &[NodeIndex<usize>],

View File

@ -2,7 +2,7 @@ use geo::{CoordsIter, Point, Polygon};
use pathfinder_canvas::{
vec2f, ArcDirection, Canvas, CanvasRenderingContext2D, ColorU, FillRule, Path2D, RectF,
};
use topola::geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait};
use topola::geometry::primitive::{AccessPrimitiveShape, PrimitiveShape};
pub struct Painter<'a> {
canvas: &'a mut CanvasRenderingContext2D,
@ -56,7 +56,7 @@ impl<'a> Painter<'a> {
}
}
let envelope = PrimitiveShapeTrait::envelope(shape, 0.0);
let envelope = AccessPrimitiveShape::envelope(shape, 0.0);
// XXX: points represented as arrays can't be conveniently converted to vector types
let topleft = vec2f(envelope.lower()[0] as f32, -envelope.upper()[1] as f32);
let bottomright = vec2f(envelope.upper()[0] as f32, -envelope.lower()[1] as f32);

View File

@ -1,14 +1,14 @@
use std::collections::HashMap;
use crate::{
board::mesadata::MesadataTrait,
board::mesadata::AccessMesadata,
drawing::{
band::BandFirstSegIndex,
dot::{FixedDotIndex, FixedDotWeight},
graph::{GetLayer, GetMaybeNet},
seg::{FixedSegIndex, FixedSegWeight},
},
geometry::{shape::ShapeTrait, GenericNode},
geometry::{shape::AccessShape, GenericNode},
graph::GenericIndex,
layout::{
zone::{GetMaybeApex, MakePolyShape, ZoneWeight},
@ -19,13 +19,13 @@ use crate::{
};
#[derive(Debug)]
pub struct Board<M: MesadataTrait> {
pub struct Board<M: AccessMesadata> {
layout: Layout<M>,
node_to_pinname: HashMap<NodeIndex, String>,
pinname_pair_to_band: HashMap<(String, String), BandFirstSegIndex>,
}
impl<M: MesadataTrait> Board<M> {
impl<M: AccessMesadata> Board<M> {
pub fn new(layout: Layout<M>) -> Self {
Self {
layout,

View File

@ -1,6 +1,6 @@
use crate::drawing::rules::RulesTrait;
use crate::drawing::rules::AccessRules;
pub trait MesadataTrait: RulesTrait {
pub trait AccessMesadata: AccessRules {
fn bename_layer(&mut self, layer: usize, layername: String);
fn layer_layername(&self, layer: usize) -> Option<&str>;
fn layername_layer(&self, layername: &str) -> Option<usize>;

View File

@ -4,10 +4,10 @@ use crate::{
drawing::{
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight, Retag},
primitive::{GenericPrimitive, Primitive},
rules::RulesTrait,
rules::AccessRules,
Drawing,
},
geometry::{BendWeightTrait, GetOffset, GetWidth, SetOffset},
geometry::{AccessBendWeight, GetOffset, GetWidth, SetOffset},
graph::{GenericIndex, GetPetgraphIndex},
};
@ -69,7 +69,7 @@ impl TryFrom<PrimitiveWeight> for BendWeight {
}
}
impl BendWeightTrait<PrimitiveWeight> for BendWeight {}
impl AccessBendWeight<PrimitiveWeight> for BendWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedBendWeight {
@ -80,7 +80,7 @@ pub struct FixedBendWeight {
}
impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex);
impl BendWeightTrait<PrimitiveWeight> for FixedBendWeight {}
impl AccessBendWeight<PrimitiveWeight> for FixedBendWeight {}
impl GetOffset for FixedBendWeight {
fn offset(&self) -> f64 {
@ -127,4 +127,4 @@ impl GetWidth for LooseBendWeight {
}
impl_loose_weight!(LooseBendWeight, LooseBend, LooseBendIndex);
impl BendWeightTrait<PrimitiveWeight> for LooseBendWeight {}
impl AccessBendWeight<PrimitiveWeight> for LooseBendWeight {}

View File

@ -7,7 +7,7 @@ use crate::drawing::{
Drawing,
};
use super::rules::RulesTrait;
use super::rules::AccessRules;
#[derive(Debug, Clone, Copy)]
pub struct Cane {
@ -17,7 +17,7 @@ pub struct Cane {
}
impl Cane {
pub fn from_dot(dot: LooseDotIndex, drawing: &Drawing<impl Copy, impl RulesTrait>) -> Self {
pub fn from_dot(dot: LooseDotIndex, drawing: &Drawing<impl Copy, impl AccessRules>) -> Self {
let bend = LooseDot::new(dot, drawing).bend();
let dot = LooseBend::new(bend, drawing).other_joint(dot);
let seg = LooseDot::new(dot, drawing).seg().unwrap();

View File

@ -2,17 +2,17 @@ use crate::drawing::{
bend::LooseBendIndex,
graph::PrimitiveIndex,
primitive::{GetInnerOuter, GetJoints},
rules::RulesTrait,
rules::AccessRules,
wraparoundable::{GetWraparound, WraparoundableIndex},
Drawing,
};
#[derive(Debug)]
pub struct Collect<'a, CW: Copy, R: RulesTrait> {
pub struct Collect<'a, CW: Copy, R: AccessRules> {
drawing: &'a Drawing<CW, R>,
}
impl<'a, CW: Copy, R: RulesTrait> Collect<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> Collect<'a, CW, R> {
pub fn new(drawing: &'a Drawing<CW, R>) -> Self {
Self { drawing }
}

View File

@ -7,10 +7,10 @@ use crate::{
drawing::{
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight, Retag},
primitive::{GenericPrimitive, Primitive},
rules::RulesTrait,
rules::AccessRules,
Drawing,
},
geometry::{DotWeightTrait, GetPos, GetWidth, SetPos},
geometry::{AccessDotWeight, GetPos, GetWidth, SetPos},
graph::{GenericIndex, GetPetgraphIndex},
math::Circle,
};
@ -71,7 +71,7 @@ impl TryFrom<PrimitiveWeight> for DotWeight {
}
}
impl DotWeightTrait<PrimitiveWeight> for DotWeight {}
impl AccessDotWeight<PrimitiveWeight> for DotWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedDotWeight {
@ -81,7 +81,7 @@ pub struct FixedDotWeight {
}
impl_fixed_weight!(FixedDotWeight, FixedDot, FixedDotIndex);
impl DotWeightTrait<PrimitiveWeight> for FixedDotWeight {}
impl AccessDotWeight<PrimitiveWeight> for FixedDotWeight {}
impl GetPos for FixedDotWeight {
fn pos(&self) -> Point {
@ -109,7 +109,7 @@ pub struct LooseDotWeight {
}
impl_loose_weight!(LooseDotWeight, LooseDot, LooseDotIndex);
impl DotWeightTrait<PrimitiveWeight> for LooseDotWeight {}
impl AccessDotWeight<PrimitiveWeight> for LooseDotWeight {}
impl GetPos for LooseDotWeight {
fn pos(&self) -> Point {

View File

@ -18,7 +18,7 @@ use crate::drawing::{
GenericPrimitive, GetCore, GetInnerOuter, GetJoints, GetLimbs, GetOtherJoint,
MakePrimitiveShape,
},
rules::{GetConditions, RulesTrait},
rules::{AccessRules, GetConditions},
seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SegWeight,
SeqLooseSegIndex, SeqLooseSegWeight,
@ -26,11 +26,11 @@ use crate::drawing::{
wraparoundable::{GetWraparound, Wraparoundable, WraparoundableIndex},
};
use crate::geometry::{
compound::CompoundManagerTrait,
primitive::{PrimitiveShape, PrimitiveShapeTrait},
compound::ManageCompounds,
primitive::{AccessPrimitiveShape, PrimitiveShape},
with_rtree::{BboxedIndex, GeometryWithRtree},
BendWeightTrait, DotWeightTrait, GenericNode, Geometry, GeometryLabel, GetOffset, GetPos,
GetWidth, SegWeightTrait,
AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel,
GetOffset, GetPos, GetWidth,
};
use crate::graph::{GenericIndex, GetPetgraphIndex};
use crate::math::NoTangents;
@ -64,7 +64,7 @@ pub struct Collision(pub PrimitiveShape, pub PrimitiveIndex);
pub struct AlreadyConnected(pub usize, pub PrimitiveIndex);
#[derive(Debug)]
pub struct Drawing<CW: Copy, R: RulesTrait> {
pub struct Drawing<CW: Copy, R: AccessRules> {
geometry_with_rtree: GeometryWithRtree<
PrimitiveWeight,
DotWeight,
@ -80,7 +80,7 @@ pub struct Drawing<CW: Copy, R: RulesTrait> {
}
#[debug_invariant(self.test_if_looses_dont_infringe_each_other())]
impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
impl<CW: Copy, R: AccessRules> Drawing<CW, R> {
pub fn new(rules: R, layer_count: usize) -> Self {
Self {
geometry_with_rtree: GeometryWithRtree::new(layer_count),
@ -172,7 +172,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
#[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count() + 1))]
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
fn add_dot_with_infringables<W: DotWeightTrait<PrimitiveWeight> + GetLayer>(
fn add_dot_with_infringables<W: AccessDotWeight<PrimitiveWeight> + GetLayer>(
&mut self,
weight: W,
infringables: Option<&[PrimitiveIndex]>,
@ -241,7 +241,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
#[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().edge_count() >= old(self.geometry_with_rtree.graph().edge_count() + 2))]
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count()))]
fn add_seg_with_infringables<W: SegWeightTrait<PrimitiveWeight> + GetLayer>(
fn add_seg_with_infringables<W: AccessSegWeight<PrimitiveWeight> + GetLayer>(
&mut self,
from: DotIndex,
to: DotIndex,
@ -305,7 +305,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count()))]
#[debug_ensures(ret.is_ok() -> self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count() + 3))]
#[debug_ensures(ret.is_err() -> self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count()))]
fn add_core_bend_with_infringables<W: BendWeightTrait<PrimitiveWeight> + GetLayer>(
fn add_core_bend_with_infringables<W: AccessBendWeight<PrimitiveWeight> + GetLayer>(
&mut self,
from: DotIndex,
to: DotIndex,
@ -719,10 +719,10 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
}
}
impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
impl<CW: Copy, R: AccessRules> Drawing<CW, R> {
#[debug_ensures(self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count() + 1))]
#[debug_ensures(self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count()))]
fn add_dot_infringably<W: DotWeightTrait<PrimitiveWeight> + GetLayer>(
fn add_dot_infringably<W: AccessDotWeight<PrimitiveWeight> + GetLayer>(
&mut self,
weight: W,
) -> GenericIndex<W>
@ -734,7 +734,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
#[debug_ensures(self.geometry_with_rtree.graph().node_count() == old(self.geometry_with_rtree.graph().node_count() + 1))]
#[debug_ensures(self.geometry_with_rtree.graph().edge_count() == old(self.geometry_with_rtree.graph().edge_count() + 2))]
fn add_seg_infringably<W: SegWeightTrait<PrimitiveWeight> + GetLayer>(
fn add_seg_infringably<W: AccessSegWeight<PrimitiveWeight> + GetLayer>(
&mut self,
from: DotIndex,
to: DotIndex,
@ -967,7 +967,7 @@ impl<CW: Copy, R: RulesTrait> Drawing<CW, R> {
}
}
impl<CW: Copy, R: RulesTrait> CompoundManagerTrait<CW, GenericIndex<CW>> for Drawing<CW, R> {
impl<CW: Copy, R: AccessRules> ManageCompounds<CW, GenericIndex<CW>> for Drawing<CW, R> {
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> {
self.geometry_with_rtree.add_compound(weight)
}

View File

@ -8,7 +8,7 @@ use super::{
bend::{FixedBendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
dot::{FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
primitive::Primitive,
rules::RulesTrait,
rules::AccessRules,
seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
SeqLooseSegWeight,
@ -32,7 +32,7 @@ pub trait GetMaybeNet {
#[enum_dispatch]
pub trait MakePrimitive {
fn primitive<'a, CW: Copy, R: RulesTrait>(
fn primitive<'a, CW: Copy, R: AccessRules>(
&self,
drawing: &'a Drawing<CW, R>,
) -> Primitive<'a, CW, R>;
@ -61,7 +61,7 @@ macro_rules! impl_weight {
pub type $index_struct = GenericIndex<$weight_struct>;
impl MakePrimitive for $index_struct {
fn primitive<'a, CW: Copy, R: RulesTrait>(
fn primitive<'a, CW: Copy, R: AccessRules>(
&self,
drawing: &'a Drawing<CW, R>,
) -> Primitive<'a, CW, R> {

View File

@ -2,8 +2,8 @@ use geo::Line;
use crate::{
geometry::{
primitive::{PrimitiveShape, PrimitiveShapeTrait},
shape::ShapeTrait,
primitive::{AccessPrimitiveShape, PrimitiveShape},
shape::AccessShape,
},
math::{self, Circle, NoTangents},
};
@ -12,17 +12,17 @@ use super::{
bend::BendIndex,
dot::{DotIndex, FixedDotIndex, LooseDotIndex},
graph::{MakePrimitive, PrimitiveIndex},
head::{BareHead, CaneHead, Head, HeadTrait},
head::{BareHead, CaneHead, GetFace, Head},
primitive::{GetCore, GetInnerOuter, GetJoints, GetOtherJoint, GetWeight, MakePrimitiveShape},
rules::{Conditions, GetConditions, RulesTrait},
rules::{AccessRules, Conditions, GetConditions},
Drawing,
};
pub struct Guide<'a, CW: Copy, R: RulesTrait> {
pub struct Guide<'a, CW: Copy, R: AccessRules> {
drawing: &'a Drawing<CW, R>,
}
impl<'a, CW: Copy, R: RulesTrait> Guide<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> Guide<'a, CW, R> {
pub fn new(drawing: &'a Drawing<CW, R>) -> Self {
Self { drawing }
}

View File

@ -6,16 +6,16 @@ use super::{
cane::Cane,
dot::{DotIndex, FixedDotIndex, LooseDotIndex},
primitive::MakePrimitiveShape,
rules::RulesTrait,
rules::AccessRules,
Drawing,
};
#[enum_dispatch]
pub trait HeadTrait {
pub trait GetFace {
fn face(&self) -> DotIndex;
}
#[enum_dispatch(HeadTrait)]
#[enum_dispatch(GetFace)]
#[derive(Debug, Clone, Copy)]
pub enum Head {
Bare(BareHead),
@ -23,7 +23,7 @@ pub enum Head {
}
impl Head {
pub fn ref_<'a, CW: Copy, R: RulesTrait>(
pub fn ref_<'a, CW: Copy, R: AccessRules>(
&self,
drawing: &'a Drawing<CW, R>,
) -> HeadRef<'a, CW, R> {
@ -36,7 +36,7 @@ pub struct BareHead {
pub face: FixedDotIndex,
}
impl HeadTrait for BareHead {
impl GetFace for BareHead {
fn face(&self) -> DotIndex {
self.face.into()
}
@ -48,30 +48,30 @@ pub struct CaneHead {
pub cane: Cane,
}
impl HeadTrait for CaneHead {
impl GetFace for CaneHead {
fn face(&self) -> DotIndex {
self.face.into()
}
}
pub struct HeadRef<'a, CW: Copy, R: RulesTrait> {
pub struct HeadRef<'a, CW: Copy, R: AccessRules> {
head: Head,
drawing: &'a Drawing<CW, R>,
}
impl<'a, CW: Copy, R: RulesTrait> HeadRef<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> HeadRef<'a, CW, R> {
pub fn new(head: Head, drawing: &'a Drawing<CW, R>) -> Self {
Self { drawing, head }
}
}
impl<'a, CW: Copy, R: RulesTrait> HeadTrait for HeadRef<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetFace for HeadRef<'a, CW, R> {
fn face(&self) -> DotIndex {
self.head.face()
}
}
impl<'a, CW: Copy, R: RulesTrait> MeasureLength for HeadRef<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> MeasureLength for HeadRef<'a, CW, R> {
fn length(&self) -> f64 {
match self.head {
Head::Bare(..) => 0.0,

View File

@ -13,7 +13,7 @@ use crate::{
graph::GetPetgraphIndex,
};
use super::rules::RulesTrait;
use super::rules::AccessRules;
#[enum_dispatch]
pub trait GetNextLoose {
@ -41,14 +41,14 @@ impl From<LooseIndex> for PrimitiveIndex {
}
#[enum_dispatch(GetNextLoose, GetDrawing, GetPetgraphIndex)]
pub enum Loose<'a, CW: Copy, R: RulesTrait> {
pub enum Loose<'a, CW: Copy, R: AccessRules> {
Dot(LooseDot<'a, CW, R>),
LoneSeg(LoneLooseSeg<'a, CW, R>),
SeqSeg(SeqLooseSeg<'a, CW, R>),
Bend(LooseBend<'a, CW, R>),
}
impl<'a, CW: Copy, R: RulesTrait> Loose<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> Loose<'a, CW, R> {
pub fn new(index: LooseIndex, drawing: &'a Drawing<CW, R>) -> Self {
match index {
LooseIndex::Dot(dot) => drawing.primitive(dot).into(),
@ -59,7 +59,7 @@ impl<'a, CW: Copy, R: RulesTrait> Loose<'a, CW, R> {
}
}
impl<'a, CW: Copy, R: RulesTrait> GetNextLoose for LooseDot<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetNextLoose for LooseDot<'a, CW, R> {
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
let bend = self.bend();
let Some(prev) = maybe_prev else {
@ -74,13 +74,13 @@ impl<'a, CW: Copy, R: RulesTrait> GetNextLoose for LooseDot<'a, CW, R> {
}
}
impl<'a, CW: Copy, R: RulesTrait> GetNextLoose for LoneLooseSeg<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetNextLoose for LoneLooseSeg<'a, CW, R> {
fn next_loose(&self, _maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
None
}
}
impl<'a, CW: Copy, R: RulesTrait> GetNextLoose for SeqLooseSeg<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetNextLoose for SeqLooseSeg<'a, CW, R> {
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
let ends = self.joints();
let Some(prev) = maybe_prev else {
@ -98,7 +98,7 @@ impl<'a, CW: Copy, R: RulesTrait> GetNextLoose for SeqLooseSeg<'a, CW, R> {
}
}
impl<'a, CW: Copy, R: RulesTrait> GetNextLoose for LooseBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetNextLoose for LooseBend<'a, CW, R> {
fn next_loose(&self, maybe_prev: Option<LooseIndex>) -> Option<LooseIndex> {
let ends = self.joints();
let Some(prev) = maybe_prev else {

View File

@ -2,7 +2,7 @@ use enum_dispatch::enum_dispatch;
use petgraph::stable_graph::NodeIndex;
use crate::geometry::{
primitive::{PrimitiveShape, PrimitiveShapeTrait},
primitive::{AccessPrimitiveShape, PrimitiveShape},
GetOffset, GetWidth,
};
use crate::{
@ -10,7 +10,7 @@ use crate::{
bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight, Retag},
rules::{Conditions, GetConditions, RulesTrait},
rules::{AccessRules, Conditions, GetConditions},
seg::{FixedSegWeight, LoneLooseSegWeight, SegIndex, SeqLooseSegIndex, SeqLooseSegWeight},
Drawing,
},
@ -19,7 +19,7 @@ use crate::{
};
#[enum_dispatch]
pub trait GetDrawing<'a, R: RulesTrait> {
pub trait GetDrawing<'a, R: AccessRules> {
fn drawing(&self) -> &Drawing<impl Copy, R>;
}
@ -72,7 +72,7 @@ pub trait GetJoints<F, T> {
fn joints(&self) -> (F, T);
}
pub trait GetFirstRail<'a, R: RulesTrait>: GetDrawing<'a, R> + GetPetgraphIndex {
pub trait GetFirstRail<'a, R: AccessRules>: GetDrawing<'a, R> + GetPetgraphIndex {
fn first_rail(&self) -> Option<LooseBendIndex> {
self.drawing()
.geometry()
@ -85,7 +85,7 @@ pub trait GetBendIndex {
fn bend_index(&self) -> BendIndex;
}
pub trait GetCore<'a, R: RulesTrait>: GetDrawing<'a, R> + GetBendIndex {
pub trait GetCore<'a, R: AccessRules>: GetDrawing<'a, R> + GetBendIndex {
fn core(&self) -> FixedDotIndex {
FixedDotIndex::new(
self.drawing()
@ -96,7 +96,7 @@ pub trait GetCore<'a, R: RulesTrait>: GetDrawing<'a, R> + GetBendIndex {
}
}
pub trait GetInnerOuter<'a, R: RulesTrait>: GetDrawing<'a, R> + GetBendIndex {
pub trait GetInnerOuter<'a, R: AccessRules>: GetDrawing<'a, R> + GetBendIndex {
fn inner(&self) -> Option<LooseBendIndex> {
self.drawing()
.geometry()
@ -114,7 +114,7 @@ pub trait GetInnerOuter<'a, R: RulesTrait>: GetDrawing<'a, R> + GetBendIndex {
macro_rules! impl_primitive {
($primitive_struct:ident, $weight_struct:ident) => {
impl<'a, CW: Copy, R: RulesTrait> GetWeight<$weight_struct>
impl<'a, CW: Copy, R: AccessRules> GetWeight<$weight_struct>
for $primitive_struct<'a, CW, R>
{
fn weight(&self) -> $weight_struct {
@ -126,13 +126,13 @@ macro_rules! impl_primitive {
}
}
impl<'a, CW: Copy, R: RulesTrait> GetLayer for $primitive_struct<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetLayer for $primitive_struct<'a, CW, R> {
fn layer(&self) -> usize {
self.weight().layer()
}
}
impl<'a, CW: Copy, R: RulesTrait> GetMaybeNet for $primitive_struct<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetMaybeNet for $primitive_struct<'a, CW, R> {
fn maybe_net(&self) -> Option<usize> {
self.weight().maybe_net()
}
@ -161,7 +161,7 @@ macro_rules! impl_loose_primitive {
GetLimbs,
GetConditions
)]
pub enum Primitive<'a, CW: Copy, R: RulesTrait> {
pub enum Primitive<'a, CW: Copy, R: AccessRules> {
FixedDot(FixedDot<'a, CW, R>),
LooseDot(LooseDot<'a, CW, R>),
FixedSeg(FixedSeg<'a, CW, R>),
@ -172,12 +172,12 @@ pub enum Primitive<'a, CW: Copy, R: RulesTrait> {
}
#[derive(Debug)]
pub struct GenericPrimitive<'a, W, CW: Copy, R: RulesTrait> {
pub struct GenericPrimitive<'a, W, CW: Copy, R: AccessRules> {
pub index: GenericIndex<W>,
drawing: &'a Drawing<CW, R>,
}
impl<'a, W, CW: Copy, R: RulesTrait> GenericPrimitive<'a, W, CW, R> {
impl<'a, W, CW: Copy, R: AccessRules> GenericPrimitive<'a, W, CW, R> {
pub fn new(index: GenericIndex<W>, drawing: &'a Drawing<CW, R>) -> Self {
Self { index, drawing }
}
@ -201,7 +201,7 @@ impl<'a, W, CW: Copy, R: RulesTrait> GenericPrimitive<'a, W, CW, R> {
}
}
impl<'a, W, CW: Copy, R: RulesTrait> GetInterior<PrimitiveIndex>
impl<'a, W, CW: Copy, R: AccessRules> GetInterior<PrimitiveIndex>
for GenericPrimitive<'a, W, CW, R>
{
fn interior(&self) -> Vec<PrimitiveIndex> {
@ -209,19 +209,19 @@ impl<'a, W, CW: Copy, R: RulesTrait> GetInterior<PrimitiveIndex>
}
}
impl<'a, W, CW: Copy, R: RulesTrait> GetDrawing<'a, R> for GenericPrimitive<'a, W, CW, R> {
impl<'a, W, CW: Copy, R: AccessRules> GetDrawing<'a, R> for GenericPrimitive<'a, W, CW, R> {
fn drawing(&self) -> &Drawing<impl Copy, R> {
self.drawing
}
}
impl<'a, W, CW: Copy, R: RulesTrait> GetPetgraphIndex for GenericPrimitive<'a, W, CW, R> {
impl<'a, W, CW: Copy, R: AccessRules> GetPetgraphIndex for GenericPrimitive<'a, W, CW, R> {
fn petgraph_index(&self) -> NodeIndex<usize> {
self.index.petgraph_index()
}
}
impl<'a, W: GetWidth, CW: Copy, R: RulesTrait> GetWidth for GenericPrimitive<'a, W, CW, R>
impl<'a, W: GetWidth, CW: Copy, R: AccessRules> GetWidth for GenericPrimitive<'a, W, CW, R>
where
GenericPrimitive<'a, W, CW, R>: GetWeight<W>,
{
@ -230,7 +230,7 @@ where
}
}
impl<'a, W, CW: Copy, R: RulesTrait> GetConditions for GenericPrimitive<'a, W, CW, R>
impl<'a, W, CW: Copy, R: AccessRules> GetConditions for GenericPrimitive<'a, W, CW, R>
where
GenericPrimitive<'a, W, CW, R>: GetMaybeNet,
{
@ -246,13 +246,13 @@ where
pub type FixedDot<'a, CW, R> = GenericPrimitive<'a, FixedDotWeight, CW, R>;
impl_fixed_primitive!(FixedDot, FixedDotWeight);
impl<'a, CW: Copy, R: RulesTrait> MakePrimitiveShape for FixedDot<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> MakePrimitiveShape for FixedDot<'a, CW, R> {
fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().dot_shape(self.index.into())
}
}
impl<'a, CW: Copy, R: RulesTrait> GetLimbs for FixedDot<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetLimbs for FixedDot<'a, CW, R> {
fn segs(&self) -> Vec<SegIndex> {
self.drawing
.geometry()
@ -268,12 +268,12 @@ impl<'a, CW: Copy, R: RulesTrait> GetLimbs for FixedDot<'a, CW, R> {
}
}
impl<'a, CW: Copy, R: RulesTrait> GetFirstRail<'a, R> for FixedDot<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetFirstRail<'a, R> for FixedDot<'a, CW, R> {}
pub type LooseDot<'a, CW, R> = GenericPrimitive<'a, LooseDotWeight, CW, R>;
impl_loose_primitive!(LooseDot, LooseDotWeight);
impl<'a, CW: Copy, R: RulesTrait> LooseDot<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> LooseDot<'a, CW, R> {
pub fn seg(&self) -> Option<SeqLooseSegIndex> {
self.drawing
.geometry()
@ -292,13 +292,13 @@ impl<'a, CW: Copy, R: RulesTrait> LooseDot<'a, CW, R> {
}
}
impl<'a, CW: Copy, R: RulesTrait> MakePrimitiveShape for LooseDot<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> MakePrimitiveShape for LooseDot<'a, CW, R> {
fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().dot_shape(self.index.into())
}
}
impl<'a, CW: Copy, R: RulesTrait> GetLimbs for LooseDot<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetLimbs for LooseDot<'a, CW, R> {
fn segs(&self) -> Vec<SegIndex> {
if let Some(seg) = self.seg() {
vec![seg.into()]
@ -315,15 +315,15 @@ impl<'a, CW: Copy, R: RulesTrait> GetLimbs for LooseDot<'a, CW, R> {
pub type FixedSeg<'a, CW, R> = GenericPrimitive<'a, FixedSegWeight, CW, R>;
impl_fixed_primitive!(FixedSeg, FixedSegWeight);
impl<'a, CW: Copy, R: RulesTrait> MakePrimitiveShape for FixedSeg<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> MakePrimitiveShape for FixedSeg<'a, CW, R> {
fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into())
}
}
impl<'a, CW: Copy, R: RulesTrait> GetLimbs for FixedSeg<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetLimbs for FixedSeg<'a, CW, R> {}
impl<'a, CW: Copy, R: RulesTrait> GetJoints<FixedDotIndex, FixedDotIndex> for FixedSeg<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetJoints<FixedDotIndex, FixedDotIndex> for FixedSeg<'a, CW, R> {
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
let (from, to) = self.drawing.geometry().seg_joints(self.index.into());
(
@ -333,7 +333,7 @@ impl<'a, CW: Copy, R: RulesTrait> GetJoints<FixedDotIndex, FixedDotIndex> for Fi
}
}
impl<'a, CW: Copy, R: RulesTrait> GetOtherJoint<FixedDotIndex, FixedDotIndex>
impl<'a, CW: Copy, R: AccessRules> GetOtherJoint<FixedDotIndex, FixedDotIndex>
for FixedSeg<'a, CW, R>
{
}
@ -341,15 +341,15 @@ impl<'a, CW: Copy, R: RulesTrait> GetOtherJoint<FixedDotIndex, FixedDotIndex>
pub type LoneLooseSeg<'a, CW, R> = GenericPrimitive<'a, LoneLooseSegWeight, CW, R>;
impl_loose_primitive!(LoneLooseSeg, LoneLooseSegWeight);
impl<'a, CW: Copy, R: RulesTrait> MakePrimitiveShape for LoneLooseSeg<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> MakePrimitiveShape for LoneLooseSeg<'a, CW, R> {
fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into())
}
}
impl<'a, CW: Copy, R: RulesTrait> GetLimbs for LoneLooseSeg<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetLimbs for LoneLooseSeg<'a, CW, R> {}
impl<'a, CW: Copy, R: RulesTrait> GetJoints<FixedDotIndex, FixedDotIndex>
impl<'a, CW: Copy, R: AccessRules> GetJoints<FixedDotIndex, FixedDotIndex>
for LoneLooseSeg<'a, CW, R>
{
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
@ -361,7 +361,7 @@ impl<'a, CW: Copy, R: RulesTrait> GetJoints<FixedDotIndex, FixedDotIndex>
}
}
impl<'a, CW: Copy, R: RulesTrait> GetOtherJoint<FixedDotIndex, FixedDotIndex>
impl<'a, CW: Copy, R: AccessRules> GetOtherJoint<FixedDotIndex, FixedDotIndex>
for LoneLooseSeg<'a, CW, R>
{
}
@ -369,15 +369,15 @@ impl<'a, CW: Copy, R: RulesTrait> GetOtherJoint<FixedDotIndex, FixedDotIndex>
pub type SeqLooseSeg<'a, CW, R> = GenericPrimitive<'a, SeqLooseSegWeight, CW, R>;
impl_loose_primitive!(SeqLooseSeg, SeqLooseSegWeight);
impl<'a, CW: Copy, R: RulesTrait> MakePrimitiveShape for SeqLooseSeg<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> MakePrimitiveShape for SeqLooseSeg<'a, CW, R> {
fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into())
}
}
impl<'a, CW: Copy, R: RulesTrait> GetLimbs for SeqLooseSeg<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetLimbs for SeqLooseSeg<'a, CW, R> {}
impl<'a, CW: Copy, R: RulesTrait> GetJoints<DotIndex, LooseDotIndex> for SeqLooseSeg<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetJoints<DotIndex, LooseDotIndex> for SeqLooseSeg<'a, CW, R> {
fn joints(&self) -> (DotIndex, LooseDotIndex) {
let joints = self.drawing.geometry().seg_joints(self.index.into());
if let DotWeight::Fixed(..) = self.drawing.geometry().dot_weight(joints.0) {
@ -399,7 +399,7 @@ impl<'a, CW: Copy, R: RulesTrait> GetJoints<DotIndex, LooseDotIndex> for SeqLoos
}
}
impl<'a, CW: Copy, R: RulesTrait> GetOtherJoint<DotIndex, LooseDotIndex>
impl<'a, CW: Copy, R: AccessRules> GetOtherJoint<DotIndex, LooseDotIndex>
for SeqLooseSeg<'a, CW, R>
{
}
@ -407,21 +407,23 @@ impl<'a, CW: Copy, R: RulesTrait> GetOtherJoint<DotIndex, LooseDotIndex>
pub type FixedBend<'a, CW, R> = GenericPrimitive<'a, FixedBendWeight, CW, R>;
impl_fixed_primitive!(FixedBend, FixedBendWeight);
impl<'a, CW: Copy, R: RulesTrait> GetBendIndex for FixedBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetBendIndex for FixedBend<'a, CW, R> {
fn bend_index(&self) -> BendIndex {
self.index.into()
}
}
impl<'a, CW: Copy, R: RulesTrait> MakePrimitiveShape for FixedBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> MakePrimitiveShape for FixedBend<'a, CW, R> {
fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().bend_shape(self.index.into())
}
}
impl<'a, CW: Copy, R: RulesTrait> GetLimbs for FixedBend<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetLimbs for FixedBend<'a, CW, R> {}
impl<'a, CW: Copy, R: RulesTrait> GetJoints<FixedDotIndex, FixedDotIndex> for FixedBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetJoints<FixedDotIndex, FixedDotIndex>
for FixedBend<'a, CW, R>
{
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
let (from, to) = self.drawing.geometry().bend_joints(self.index.into());
(
@ -431,44 +433,46 @@ impl<'a, CW: Copy, R: RulesTrait> GetJoints<FixedDotIndex, FixedDotIndex> for Fi
}
}
impl<'a, CW: Copy, R: RulesTrait> GetOtherJoint<FixedDotIndex, FixedDotIndex>
impl<'a, CW: Copy, R: AccessRules> GetOtherJoint<FixedDotIndex, FixedDotIndex>
for FixedBend<'a, CW, R>
{
}
impl<'a, CW: Copy, R: RulesTrait> GetFirstRail<'a, R> for FixedBend<'a, CW, R> {}
impl<'a, CW: Copy, R: RulesTrait> GetCore<'a, R> for FixedBend<'a, CW, R> {} // TODO: Fixed bends don't have cores actually.
impl<'a, CW: Copy, R: AccessRules> GetFirstRail<'a, R> for FixedBend<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetCore<'a, R> for FixedBend<'a, CW, R> {} // TODO: Fixed bends don't have cores actually.
//impl<'a, R: QueryRules> GetInnerOuter for FixedBend<'a, CW, R> {}
pub type LooseBend<'a, CW, R> = GenericPrimitive<'a, LooseBendWeight, CW, R>;
impl_loose_primitive!(LooseBend, LooseBendWeight);
impl<'a, CW: Copy, R: RulesTrait> GetBendIndex for LooseBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetBendIndex for LooseBend<'a, CW, R> {
fn bend_index(&self) -> BendIndex {
self.index.into()
}
}
impl<'a, CW: Copy, R: RulesTrait> From<LooseBend<'a, CW, R>> for BendIndex {
impl<'a, CW: Copy, R: AccessRules> From<LooseBend<'a, CW, R>> for BendIndex {
fn from(bend: LooseBend<'a, CW, R>) -> BendIndex {
bend.index.into()
}
}
impl<'a, CW: Copy, R: RulesTrait> MakePrimitiveShape for LooseBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> MakePrimitiveShape for LooseBend<'a, CW, R> {
fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().bend_shape(self.index.into())
}
}
impl<'a, CW: Copy, R: RulesTrait> GetLimbs for LooseBend<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetLimbs for LooseBend<'a, CW, R> {}
impl<'a, CW: Copy, R: RulesTrait> GetOffset for LooseBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetOffset for LooseBend<'a, CW, R> {
fn offset(&self) -> f64 {
self.weight().offset
}
}
impl<'a, CW: Copy, R: RulesTrait> GetJoints<LooseDotIndex, LooseDotIndex> for LooseBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetJoints<LooseDotIndex, LooseDotIndex>
for LooseBend<'a, CW, R>
{
fn joints(&self) -> (LooseDotIndex, LooseDotIndex) {
let (from, to) = self.drawing.geometry().bend_joints(self.index.into());
(
@ -478,9 +482,9 @@ impl<'a, CW: Copy, R: RulesTrait> GetJoints<LooseDotIndex, LooseDotIndex> for Lo
}
}
impl<'a, CW: Copy, R: RulesTrait> GetOtherJoint<LooseDotIndex, LooseDotIndex>
impl<'a, CW: Copy, R: AccessRules> GetOtherJoint<LooseDotIndex, LooseDotIndex>
for LooseBend<'a, CW, R>
{
}
impl<'a, CW: Copy, R: RulesTrait> GetCore<'a, R> for LooseBend<'a, CW, R> {}
impl<'a, CW: Copy, R: RulesTrait> GetInnerOuter<'a, R> for LooseBend<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetCore<'a, R> for LooseBend<'a, CW, R> {}
impl<'a, CW: Copy, R: AccessRules> GetInnerOuter<'a, R> for LooseBend<'a, CW, R> {}

View File

@ -14,7 +14,7 @@ pub struct Conditions {
pub maybe_layer: Option<String>,
}
pub trait RulesTrait {
pub trait AccessRules {
fn clearance(&self, conditions1: &Conditions, conditions2: &Conditions) -> f64;
fn largest_clearance(&self, net: Option<usize>) -> f64;
}

View File

@ -4,10 +4,10 @@ use crate::{
drawing::{
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight, Retag},
primitive::{GenericPrimitive, Primitive},
rules::RulesTrait,
rules::AccessRules,
Drawing,
},
geometry::{GetWidth, SegWeightTrait},
geometry::{AccessSegWeight, GetWidth},
graph::{GenericIndex, GetPetgraphIndex},
};
@ -75,7 +75,7 @@ impl TryFrom<PrimitiveWeight> for SegWeight {
}
}
impl SegWeightTrait<PrimitiveWeight> for SegWeight {}
impl AccessSegWeight<PrimitiveWeight> for SegWeight {}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedSegWeight {
@ -85,7 +85,7 @@ pub struct FixedSegWeight {
}
impl_fixed_weight!(FixedSegWeight, FixedSeg, FixedSegIndex);
impl SegWeightTrait<PrimitiveWeight> for FixedSegWeight {}
impl AccessSegWeight<PrimitiveWeight> for FixedSegWeight {}
impl GetWidth for FixedSegWeight {
fn width(&self) -> f64 {
@ -101,7 +101,7 @@ pub struct LoneLooseSegWeight {
}
impl_loose_weight!(LoneLooseSegWeight, LoneLooseSeg, LoneLooseSegIndex);
impl SegWeightTrait<PrimitiveWeight> for LoneLooseSegWeight {}
impl AccessSegWeight<PrimitiveWeight> for LoneLooseSegWeight {}
impl GetWidth for LoneLooseSegWeight {
fn width(&self) -> f64 {
@ -117,7 +117,7 @@ pub struct SeqLooseSegWeight {
}
impl_loose_weight!(SeqLooseSegWeight, SeqLooseSeg, SeqLooseSegIndex);
impl SegWeightTrait<PrimitiveWeight> for SeqLooseSegWeight {}
impl AccessSegWeight<PrimitiveWeight> for SeqLooseSegWeight {}
impl GetWidth for SeqLooseSegWeight {
fn width(&self) -> f64 {

View File

@ -7,7 +7,7 @@ use crate::{
dot::FixedDotIndex,
graph::{MakePrimitive, PrimitiveIndex},
primitive::{FixedBend, FixedDot, GetFirstRail, GetInnerOuter, LooseBend, Primitive},
rules::RulesTrait,
rules::AccessRules,
Drawing,
},
graph::GetPetgraphIndex,
@ -46,13 +46,13 @@ impl From<BendIndex> for WraparoundableIndex {
}
#[enum_dispatch(GetWraparound, GetDrawing, GetPetgraphIndex)]
pub enum Wraparoundable<'a, CW: Copy, R: RulesTrait> {
pub enum Wraparoundable<'a, CW: Copy, R: AccessRules> {
FixedDot(FixedDot<'a, CW, R>),
FixedBend(FixedBend<'a, CW, R>),
LooseBend(LooseBend<'a, CW, R>),
}
impl<'a, CW: Copy, R: RulesTrait> Wraparoundable<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> Wraparoundable<'a, CW, R> {
pub fn new(index: WraparoundableIndex, drawing: &'a Drawing<CW, R>) -> Self {
match index {
WraparoundableIndex::FixedDot(dot) => drawing.primitive(dot).into(),
@ -62,19 +62,19 @@ impl<'a, CW: Copy, R: RulesTrait> Wraparoundable<'a, CW, R> {
}
}
impl<'a, CW: Copy, R: RulesTrait> GetWraparound for FixedDot<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetWraparound for FixedDot<'a, CW, R> {
fn wraparound(&self) -> Option<LooseBendIndex> {
self.first_rail()
}
}
impl<'a, CW: Copy, R: RulesTrait> GetWraparound for LooseBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetWraparound for LooseBend<'a, CW, R> {
fn wraparound(&self) -> Option<LooseBendIndex> {
self.outer()
}
}
impl<'a, CW: Copy, R: RulesTrait> GetWraparound for FixedBend<'a, CW, R> {
impl<'a, CW: Copy, R: AccessRules> GetWraparound for FixedBend<'a, CW, R> {
fn wraparound(&self) -> Option<LooseBendIndex> {
self.first_rail()
}

View File

@ -1,6 +1,6 @@
use crate::graph::{GenericIndex, GetPetgraphIndex};
pub trait CompoundManagerTrait<CW: Copy, GI: GetPetgraphIndex + Copy> {
pub trait ManageCompounds<CW: Copy, GI: GetPetgraphIndex + Copy> {
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW>;
fn remove_compound(&mut self, compound: GenericIndex<CW>);
fn add_to_compound<W>(&mut self, node: GenericIndex<W>, compound: GenericIndex<CW>);

View File

@ -14,11 +14,11 @@ use crate::{
dot::DotWeight,
graph::{PrimitiveWeight, Retag},
primitive::Primitive,
rules::RulesTrait,
rules::AccessRules,
seg::SegWeight,
},
geometry::{
compound::CompoundManagerTrait,
compound::ManageCompounds,
primitive::{BendShape, DotShape, PrimitiveShape, SegShape},
},
graph::{GenericIndex, GetPetgraphIndex},
@ -64,16 +64,16 @@ pub enum GenericNode<P, C> {
Compound(C),
}
pub trait DotWeightTrait<CW>: GetPos + SetPos + GetWidth + Into<CW> + Copy {}
pub trait SegWeightTrait<CW>: GetWidth + Into<CW> + Copy {}
pub trait BendWeightTrait<CW>: GetOffset + SetOffset + GetWidth + Into<CW> + Copy {}
pub trait AccessDotWeight<CW>: GetPos + SetPos + GetWidth + Into<CW> + Copy {}
pub trait AccessSegWeight<CW>: GetWidth + Into<CW> + Copy {}
pub trait AccessBendWeight<CW>: GetOffset + SetOffset + GetWidth + Into<CW> + Copy {}
#[derive(Debug)]
pub struct Geometry<
PW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW>,
SW: SegWeightTrait<PW>,
BW: BendWeightTrait<PW>,
DW: AccessDotWeight<PW>,
SW: AccessSegWeight<PW>,
BW: AccessBendWeight<PW>,
CW: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy,
@ -94,9 +94,9 @@ pub struct Geometry<
impl<
PW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW>,
SW: SegWeightTrait<PW>,
BW: BendWeightTrait<PW>,
DW: AccessDotWeight<PW>,
SW: AccessSegWeight<PW>,
BW: AccessBendWeight<PW>,
CW: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy,
@ -119,11 +119,11 @@ impl<
}
}
pub fn add_dot<W: DotWeightTrait<PW>>(&mut self, weight: W) -> GenericIndex<W> {
pub fn add_dot<W: AccessDotWeight<PW>>(&mut self, weight: W) -> GenericIndex<W> {
GenericIndex::<W>::new(self.graph.add_node(GenericNode::Primitive(weight.into())))
}
pub fn add_seg<W: SegWeightTrait<PW>>(
pub fn add_seg<W: AccessSegWeight<PW>>(
&mut self,
from: DI,
to: DI,
@ -146,7 +146,7 @@ impl<
seg
}
pub fn add_bend<W: BendWeightTrait<PW>>(
pub fn add_bend<W: AccessBendWeight<PW>>(
&mut self,
from: DI,
to: DI,
@ -500,15 +500,15 @@ impl<
impl<
PW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW>,
SW: SegWeightTrait<PW>,
BW: BendWeightTrait<PW>,
DW: AccessDotWeight<PW>,
SW: AccessSegWeight<PW>,
BW: AccessBendWeight<PW>,
CW: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy,
SI: GetPetgraphIndex + Into<PI> + Copy,
BI: GetPetgraphIndex + Into<PI> + Copy,
> CompoundManagerTrait<CW, GenericIndex<CW>> for Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI>
> ManageCompounds<CW, GenericIndex<CW>> for Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI>
{
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> {
GenericIndex::<CW>::new(self.graph.add_node(GenericNode::Compound(weight)))

View File

@ -1,6 +1,6 @@
use geo::{Centroid, Contains, EuclideanLength, Point, Polygon};
use crate::geometry::shape::{MeasureLength, ShapeTrait};
use crate::geometry::shape::{AccessShape, MeasureLength};
#[derive(Debug, Clone, PartialEq)]
pub struct PolyShape {
@ -19,7 +19,7 @@ impl MeasureLength for PolyShape {
}
}
impl ShapeTrait for PolyShape {
impl AccessShape for PolyShape {
fn center(&self) -> Point {
self.polygon.centroid().unwrap()
}

View File

@ -3,12 +3,12 @@ use geo::{point, polygon, Contains, EuclideanDistance, Intersects, Point, Polygo
use rstar::{RTreeObject, AABB};
use crate::{
geometry::shape::{MeasureLength, ShapeTrait},
geometry::shape::{AccessShape, MeasureLength},
math::{self, Circle},
};
#[enum_dispatch]
pub trait PrimitiveShapeTrait: ShapeTrait {
pub trait AccessPrimitiveShape: AccessShape {
fn priority(&self) -> usize;
fn inflate(&self, margin: f64) -> PrimitiveShape;
fn intersects(&self, other: &PrimitiveShape) -> bool;
@ -36,7 +36,7 @@ pub trait PrimitiveShapeTrait: ShapeTrait {
}
}
#[enum_dispatch(MeasureLength, ShapeTrait, PrimitiveShapeTrait)]
#[enum_dispatch(MeasureLength, AccessShape, AccessPrimitiveShape)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum PrimitiveShape {
// Intentionally in different order to reorder `self.intersects(...)` properly.
@ -56,7 +56,7 @@ impl MeasureLength for DotShape {
}
}
impl ShapeTrait for DotShape {
impl AccessShape for DotShape {
fn center(&self) -> Point {
self.circle.pos
}
@ -66,7 +66,7 @@ impl ShapeTrait for DotShape {
}
}
impl PrimitiveShapeTrait for DotShape {
impl AccessPrimitiveShape for DotShape {
fn priority(&self) -> usize {
3
}
@ -159,7 +159,7 @@ impl MeasureLength for SegShape {
}
}
impl ShapeTrait for SegShape {
impl AccessShape for SegShape {
fn center(&self) -> Point {
(self.from + self.to) / 2.0
}
@ -169,7 +169,7 @@ impl ShapeTrait for SegShape {
}
}
impl PrimitiveShapeTrait for SegShape {
impl AccessPrimitiveShape for SegShape {
fn priority(&self) -> usize {
2
}
@ -286,7 +286,7 @@ impl MeasureLength for BendShape {
}
}
impl ShapeTrait for BendShape {
impl AccessShape for BendShape {
fn center(&self) -> Point {
let sum = (self.from - self.inner_circle.pos) + (self.to - self.inner_circle.pos);
self.inner_circle.pos
@ -299,7 +299,7 @@ impl ShapeTrait for BendShape {
}
}
impl PrimitiveShapeTrait for BendShape {
impl AccessPrimitiveShape for BendShape {
fn priority(&self) -> usize {
1
}
@ -375,6 +375,6 @@ impl PrimitiveShapeTrait for BendShape {
impl RTreeObject for PrimitiveShape {
type Envelope = AABB<[f64; 2]>;
fn envelope(&self) -> Self::Envelope {
PrimitiveShapeTrait::envelope(self, 0.0)
AccessPrimitiveShape::envelope(self, 0.0)
}
}

View File

@ -12,12 +12,12 @@ pub trait MeasureLength {
}
#[enum_dispatch]
pub trait ShapeTrait: MeasureLength {
pub trait AccessShape: MeasureLength {
fn center(&self) -> Point;
fn contains_point(&self, p: Point) -> bool;
}
#[enum_dispatch(MeasureLength, ShapeTrait)]
#[enum_dispatch(MeasureLength, AccessShape)]
#[derive(Debug, Clone, PartialEq)]
pub enum Shape {
Dot(DotShape),

View File

@ -8,10 +8,10 @@ use rstar::{primitives::GeomWithData, Envelope, RTree, RTreeObject, AABB};
use crate::{
drawing::graph::{GetLayer, Retag},
geometry::{
compound::CompoundManagerTrait,
primitive::{PrimitiveShape, PrimitiveShapeTrait},
BendWeightTrait, DotWeightTrait, GenericNode, Geometry, GeometryLabel, GetWidth,
SegWeightTrait,
compound::ManageCompounds,
primitive::{AccessPrimitiveShape, PrimitiveShape},
AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel,
GetWidth,
},
graph::{GenericIndex, GetPetgraphIndex},
};
@ -39,9 +39,9 @@ pub type BboxedIndex<I> = GeomWithData<Bbox, I>;
#[derive(Debug)]
pub struct GeometryWithRtree<
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW> + GetLayer,
SW: SegWeightTrait<PW> + GetLayer,
BW: BendWeightTrait<PW> + GetLayer,
DW: AccessDotWeight<PW> + GetLayer,
SW: AccessSegWeight<PW> + GetLayer,
BW: AccessBendWeight<PW> + GetLayer,
CW: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy,
@ -65,9 +65,9 @@ pub struct GeometryWithRtree<
#[debug_invariant(self.geometry.graph().node_count() == self.rtree.size())]
impl<
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW> + GetLayer,
SW: SegWeightTrait<PW> + GetLayer,
BW: BendWeightTrait<PW> + GetLayer,
DW: AccessDotWeight<PW> + GetLayer,
SW: AccessSegWeight<PW> + GetLayer,
BW: AccessBendWeight<PW> + GetLayer,
CW: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy,
@ -91,7 +91,7 @@ impl<
}
}
pub fn add_dot<W: DotWeightTrait<PW> + GetLayer>(&mut self, weight: W) -> GenericIndex<W>
pub fn add_dot<W: AccessDotWeight<PW> + GetLayer>(&mut self, weight: W) -> GenericIndex<W>
where
GenericIndex<W>: Into<PI>,
{
@ -107,7 +107,7 @@ impl<
dot
}
pub fn add_seg<W: SegWeightTrait<PW> + GetLayer>(
pub fn add_seg<W: AccessSegWeight<PW> + GetLayer>(
&mut self,
from: DI,
to: DI,
@ -128,7 +128,7 @@ impl<
seg
}
pub fn add_bend<W: BendWeightTrait<PW> + GetLayer>(
pub fn add_bend<W: AccessBendWeight<PW> + GetLayer>(
&mut self,
from: DI,
to: DI,
@ -255,9 +255,9 @@ impl<
impl<
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW> + GetLayer,
SW: SegWeightTrait<PW> + GetLayer,
BW: BendWeightTrait<PW> + GetLayer,
DW: AccessDotWeight<PW> + GetLayer,
SW: AccessSegWeight<PW> + GetLayer,
BW: AccessBendWeight<PW> + GetLayer,
CW: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy,
@ -386,15 +386,15 @@ impl<
impl<
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
DW: DotWeightTrait<PW> + GetLayer,
SW: SegWeightTrait<PW> + GetLayer,
BW: BendWeightTrait<PW> + GetLayer,
DW: AccessDotWeight<PW> + GetLayer,
SW: AccessSegWeight<PW> + GetLayer,
BW: AccessBendWeight<PW> + GetLayer,
CW: Copy,
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + PartialEq + Copy,
DI: GetPetgraphIndex + Into<PI> + Copy,
SI: GetPetgraphIndex + Into<PI> + Copy,
BI: GetPetgraphIndex + Into<PI> + Copy,
> CompoundManagerTrait<CW, GenericIndex<CW>>
> ManageCompounds<CW, GenericIndex<CW>>
for GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>
{
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> {

View File

@ -11,7 +11,7 @@ use crate::{
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
graph::{GetMaybeNet, PrimitiveIndex},
primitive::{GetJoints, GetOtherJoint},
rules::RulesTrait,
rules::AccessRules,
seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
SeqLooseSegWeight,
@ -20,7 +20,7 @@ use crate::{
Drawing, Infringement, LayoutException,
},
geometry::{
compound::CompoundManagerTrait, primitive::PrimitiveShapeTrait, shape::MeasureLength,
compound::ManageCompounds, primitive::AccessPrimitiveShape, shape::MeasureLength,
GenericNode,
},
graph::{GenericIndex, GetPetgraphIndex},
@ -40,11 +40,11 @@ pub enum CompoundWeight {
pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<CompoundWeight>>;
#[derive(Debug)]
pub struct Layout<R: RulesTrait> {
pub struct Layout<R: AccessRules> {
drawing: Drawing<CompoundWeight, R>,
}
impl<R: RulesTrait> Layout<R> {
impl<R: AccessRules> Layout<R> {
pub fn new(drawing: Drawing<CompoundWeight, R>) -> Self {
Self { drawing }
}

View File

@ -1,9 +1,9 @@
use serde::{Deserialize, Serialize};
use crate::{
drawing::{graph::GetMaybeNet, primitive::MakePrimitiveShape, rules::RulesTrait},
drawing::{graph::GetMaybeNet, primitive::MakePrimitiveShape, rules::AccessRules},
geometry::{
compound::CompoundManagerTrait,
compound::ManageCompounds,
primitive::{DotShape, PrimitiveShape},
},
graph::{GenericIndex, GetPetgraphIndex},
@ -12,18 +12,18 @@ use crate::{
};
#[derive(Debug)]
pub struct Via<'a, R: RulesTrait> {
pub struct Via<'a, R: AccessRules> {
pub index: GenericIndex<ViaWeight>,
layout: &'a Layout<R>,
}
impl<'a, R: RulesTrait> Via<'a, R> {
impl<'a, R: AccessRules> Via<'a, R> {
pub fn new(index: GenericIndex<ViaWeight>, layout: &'a Layout<R>) -> Self {
Self { index, layout }
}
}
impl<'a, R: RulesTrait> GetMaybeNet for Via<'a, R> {
impl<'a, R: AccessRules> GetMaybeNet for Via<'a, R> {
fn maybe_net(&self) -> Option<usize> {
self.layout
.drawing()
@ -32,7 +32,7 @@ impl<'a, R: RulesTrait> GetMaybeNet for Via<'a, R> {
}
}
impl<'a, R: RulesTrait> MakePrimitiveShape for Via<'a, R> {
impl<'a, R: AccessRules> MakePrimitiveShape for Via<'a, R> {
fn shape(&self) -> PrimitiveShape {
if let CompoundWeight::Via(weight) =
self.layout.drawing().compound_weight(self.index.into())

View File

@ -7,10 +7,10 @@ use crate::{
dot::FixedDotIndex,
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex},
primitive::GetLimbs,
rules::RulesTrait,
rules::AccessRules,
seg::SegIndex,
},
geometry::{compound::CompoundManagerTrait, poly::PolyShape, GetPos},
geometry::{compound::ManageCompounds, poly::PolyShape, GetPos},
graph::{GenericIndex, GetPetgraphIndex},
layout::{CompoundWeight, Layout},
};
@ -26,12 +26,12 @@ pub trait GetMaybeApex {
}
#[derive(Debug)]
pub struct Zone<'a, R: RulesTrait> {
pub struct Zone<'a, R: AccessRules> {
pub index: GenericIndex<ZoneWeight>,
layout: &'a Layout<R>,
}
impl<'a, R: RulesTrait> Zone<'a, R> {
impl<'a, R: AccessRules> Zone<'a, R> {
pub fn new(index: GenericIndex<ZoneWeight>, layout: &'a Layout<R>) -> Self {
Self { index, layout }
}
@ -48,7 +48,7 @@ impl<'a, R: RulesTrait> Zone<'a, R> {
}
}
impl<'a, R: RulesTrait> GetLayer for Zone<'a, R> {
impl<'a, R: AccessRules> GetLayer for Zone<'a, R> {
fn layer(&self) -> usize {
if let CompoundWeight::Zone(weight) =
self.layout.drawing().compound_weight(self.index.into())
@ -60,7 +60,7 @@ impl<'a, R: RulesTrait> GetLayer for Zone<'a, R> {
}
}
impl<'a, R: RulesTrait> GetMaybeNet for Zone<'a, R> {
impl<'a, R: AccessRules> GetMaybeNet for Zone<'a, R> {
fn maybe_net(&self) -> Option<usize> {
self.layout
.drawing()
@ -69,7 +69,7 @@ impl<'a, R: RulesTrait> GetMaybeNet for Zone<'a, R> {
}
}
impl<'a, R: RulesTrait> MakePolyShape for Zone<'a, R> {
impl<'a, R: AccessRules> MakePolyShape for Zone<'a, R> {
fn shape(&self) -> PolyShape {
PolyShape {
polygon: Polygon::new(
@ -103,7 +103,7 @@ impl<'a, R: RulesTrait> MakePolyShape for Zone<'a, R> {
}
}
impl<'a, R: RulesTrait> GetMaybeApex for Zone<'a, R> {
impl<'a, R: AccessRules> GetMaybeApex for Zone<'a, R> {
fn maybe_apex(&self) -> Option<FixedDotIndex> {
self.layout
.drawing()

View File

@ -9,9 +9,9 @@ use crate::{
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
graph::{GetLayer, GetMaybeNet, MakePrimitive},
guide::Guide,
head::{CaneHead, Head, HeadTrait},
head::{CaneHead, GetFace, Head},
primitive::GetOtherJoint,
rules::RulesTrait,
rules::AccessRules,
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
wraparoundable::WraparoundableIndex,
Infringement, LayoutException,
@ -31,11 +31,11 @@ pub enum DrawException {
CannotWrapAround(WraparoundableIndex, #[source] LayoutException),
}
pub struct Draw<'a, R: RulesTrait> {
pub struct Draw<'a, R: AccessRules> {
layout: &'a mut Layout<R>,
}
impl<'a, R: RulesTrait> Draw<'a, R> {
impl<'a, R: AccessRules> Draw<'a, R> {
pub fn new(layout: &'a mut Layout<R>) -> Self {
Self { layout }
}

View File

@ -20,10 +20,10 @@ use crate::{
dot::FixedDotIndex,
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex},
primitive::{MakePrimitiveShape, Primitive},
rules::RulesTrait,
rules::AccessRules,
Drawing,
},
geometry::shape::ShapeTrait,
geometry::shape::AccessShape,
graph::GetPetgraphIndex,
layout::Layout,
router::astar::MakeEdgeRef,
@ -115,7 +115,7 @@ pub struct Navmesh {
impl Navmesh {
pub fn new(
layout: &Layout<impl RulesTrait>,
layout: &Layout<impl AccessRules>,
source: FixedDotIndex,
target: FixedDotIndex,
) -> Result<Self, NavmeshError> {

View File

@ -12,9 +12,9 @@ use crate::{
dot::{DotIndex, FixedDotIndex},
graph::{MakePrimitive, PrimitiveIndex},
primitive::MakePrimitiveShape,
rules::RulesTrait,
rules::AccessRules,
},
geometry::{primitive::PrimitiveShapeTrait, shape::ShapeTrait},
geometry::{primitive::AccessPrimitiveShape, shape::AccessShape},
graph::GetPetgraphIndex,
layout::Layout,
router::{
@ -37,7 +37,7 @@ pub struct Route {
impl Route {
pub fn new(
router: &mut Router<impl RulesTrait>,
router: &mut Router<impl AccessRules>,
from: FixedDotIndex,
to: FixedDotIndex,
width: f64,
@ -47,7 +47,7 @@ impl Route {
}
pub fn new_from_navmesh(
router: &mut Router<impl RulesTrait>,
router: &mut Router<impl AccessRules>,
navmesh: Navmesh,
width: f64,
) -> Self {
@ -66,7 +66,7 @@ impl Route {
pub fn step(
&mut self,
router: &mut Router<impl RulesTrait>,
router: &mut Router<impl AccessRules>,
) -> Result<RouterStatus, RouterError> {
let tracer = Tracer::new(router.layout_mut());
let target = self.astar.graph.destination();

View File

@ -7,13 +7,13 @@ use crate::{
band::BandFirstSegIndex,
dot::{DotIndex, FixedDotIndex},
graph::{MakePrimitive, PrimitiveIndex},
head::{Head, HeadTrait},
head::{GetFace, Head},
primitive::MakePrimitiveShape,
rules::RulesTrait,
rules::AccessRules,
},
geometry::{
primitive::PrimitiveShapeTrait,
shape::{MeasureLength, ShapeTrait},
primitive::AccessPrimitiveShape,
shape::{AccessShape, MeasureLength},
},
graph::GetPetgraphIndex,
layout::Layout,
@ -40,13 +40,13 @@ pub enum RouterStatus {
}
#[derive(Debug)]
pub struct RouterAstarStrategy<'a, R: RulesTrait> {
pub struct RouterAstarStrategy<'a, R: AccessRules> {
pub tracer: Tracer<'a, R>,
pub trace: &'a mut Trace,
pub target: FixedDotIndex,
}
impl<'a, R: RulesTrait> RouterAstarStrategy<'a, R> {
impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
pub fn new(tracer: Tracer<'a, R>, trace: &'a mut Trace, target: FixedDotIndex) -> Self {
Self {
tracer,
@ -71,7 +71,7 @@ impl<'a, R: RulesTrait> RouterAstarStrategy<'a, R> {
}
}
impl<'a, R: RulesTrait> AstarStrategy<Navmesh, f64, BandFirstSegIndex>
impl<'a, R: AccessRules> AstarStrategy<Navmesh, f64, BandFirstSegIndex>
for RouterAstarStrategy<'a, R>
{
fn is_goal(
@ -132,11 +132,11 @@ impl<'a, R: RulesTrait> AstarStrategy<Navmesh, f64, BandFirstSegIndex>
}
#[derive(Debug)]
pub struct Router<'a, R: RulesTrait> {
pub struct Router<'a, R: AccessRules> {
layout: &'a mut Layout<R>,
}
impl<'a, R: RulesTrait> Router<'a, R> {
impl<'a, R: AccessRules> Router<'a, R> {
pub fn new(layout: &'a mut Layout<R>) -> Self {
Self { layout }
}

View File

@ -7,7 +7,7 @@ use crate::{
dot::FixedDotIndex,
graph::PrimitiveIndex,
head::{BareHead, CaneHead, Head},
rules::RulesTrait,
rules::AccessRules,
},
router::{
draw::Draw,
@ -37,7 +37,7 @@ impl Trace {
#[debug_ensures(ret.is_err() -> self.path.len() == old(self.path.len()))]
pub fn step(
&mut self,
tracer: &mut Tracer<impl RulesTrait>,
tracer: &mut Tracer<impl AccessRules>,
navmesh: &Navmesh,
to: NavvertexIndex,
width: f64,
@ -49,7 +49,7 @@ impl Trace {
}
#[debug_ensures(self.path.len() == old(self.path.len() - 1))]
pub fn undo_step(&mut self, tracer: &mut Tracer<impl RulesTrait>) {
pub fn undo_step(&mut self, tracer: &mut Tracer<impl AccessRules>) {
if let Head::Cane(head) = self.head {
self.head = Draw::new(tracer.layout).undo_cane(head).unwrap();
} else {
@ -61,7 +61,7 @@ impl Trace {
fn wrap(
&mut self,
tracer: &mut Tracer<impl RulesTrait>,
tracer: &mut Tracer<impl AccessRules>,
navmesh: &Navmesh,
head: Head,
around: NavvertexIndex,
@ -84,7 +84,7 @@ impl Trace {
fn wrap_around_fixed_dot(
&mut self,
tracer: &mut Tracer<impl RulesTrait>,
tracer: &mut Tracer<impl AccessRules>,
head: Head,
around: FixedDotIndex,
cw: bool,
@ -95,7 +95,7 @@ impl Trace {
fn wrap_around_loose_bend(
&mut self,
tracer: &mut Tracer<impl RulesTrait>,
tracer: &mut Tracer<impl AccessRules>,
head: Head,
around: LooseBendIndex,
cw: bool,

View File

@ -8,7 +8,7 @@ use thiserror::Error;
use crate::{
drawing::{
band::BandFirstSegIndex, bend::LooseBendIndex, dot::FixedDotIndex, graph::PrimitiveIndex,
rules::RulesTrait,
rules::AccessRules,
},
layout::Layout,
router::{
@ -27,11 +27,11 @@ pub enum TracerException {
}
#[derive(Debug)]
pub struct Tracer<'a, R: RulesTrait> {
pub struct Tracer<'a, R: AccessRules> {
pub layout: &'a mut Layout<R>,
}
impl<'a, R: RulesTrait> Tracer<'a, R> {
impl<'a, R: AccessRules> Tracer<'a, R> {
pub fn new(layout: &mut Layout<R>) -> Tracer<R> {
Tracer { layout }
}

View File

@ -4,7 +4,7 @@ use geo::{point, Point, Rotate};
use thiserror::Error;
use crate::{
board::{mesadata::MesadataTrait, Board},
board::{mesadata::AccessMesadata, Board},
drawing::{dot::FixedDotWeight, seg::FixedSegWeight, Drawing},
layout::{zone::SolidZoneWeight, Layout},
math::Circle,

View File

@ -3,8 +3,8 @@ use std::collections::HashMap;
use bimap::BiHashMap;
use crate::{
board::mesadata::MesadataTrait,
drawing::rules::{Conditions, RulesTrait},
board::mesadata::AccessMesadata,
drawing::rules::{AccessRules, Conditions},
specctra::structure::Pcb,
};
@ -92,7 +92,7 @@ impl SpecctraMesadata {
}
}
impl RulesTrait for SpecctraMesadata {
impl AccessRules for SpecctraMesadata {
fn clearance(&self, conditions1: &Conditions, conditions2: &Conditions) -> f64 {
let (Some(net1), Some(net2)) = (conditions1.maybe_net, conditions2.maybe_net) else {
return 0.0;
@ -121,7 +121,7 @@ impl RulesTrait for SpecctraMesadata {
}
}
impl MesadataTrait for SpecctraMesadata {
impl AccessMesadata for SpecctraMesadata {
fn bename_layer(&mut self, layer: usize, layername: String) {
self.layer_layername.insert(layer, layername);
}

View File

@ -7,7 +7,7 @@ use topola::{
invoker::{Invoker, InvokerError},
Autorouter,
},
board::{mesadata::MesadataTrait, Board},
board::{mesadata::AccessMesadata, Board},
drawing::graph::{GetLayer, GetMaybeNet},
graph::GetPetgraphIndex,
specctra::{design::SpecctraDesign, mesadata::SpecctraMesadata},
@ -56,7 +56,7 @@ pub fn replay_and_assert(invoker: &mut Invoker<SpecctraMesadata>, filename: &str
}
pub fn assert_single_layer_groundless_autoroute(
autorouter: &mut Autorouter<impl MesadataTrait>,
autorouter: &mut Autorouter<impl AccessMesadata>,
layername: &str,
) {
let unionfind = unionfind(autorouter);
@ -139,7 +139,7 @@ pub fn assert_single_layer_groundless_autoroute(
}*/
pub fn assert_band_length(
board: &Board<impl MesadataTrait>,
board: &Board<impl AccessMesadata>,
source: &str,
target: &str,
length: f64,
@ -150,7 +150,7 @@ pub fn assert_band_length(
assert!((band_length - length).abs() < epsilon);
}
fn unionfind(autorouter: &mut Autorouter<impl MesadataTrait>) -> UnionFind<NodeIndex<usize>> {
fn unionfind(autorouter: &mut Autorouter<impl AccessMesadata>) -> UnionFind<NodeIndex<usize>> {
for ratline in autorouter.ratsnest().graph().edge_indices() {
// Accessing endpoints may create new dots because apex construction is lazy, so we access
// tem all before starting unionfind, as it requires a constant index bound.

View File

@ -3,7 +3,7 @@ use topola::{
invoker::{Command, InvokerError},
AutorouterError,
},
board::mesadata::MesadataTrait,
board::mesadata::AccessMesadata,
layout::via::ViaWeight,
math::Circle,
};