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

View File

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

View File

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

View File

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

View File

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

View File

@ -3,9 +3,9 @@ use std::collections::HashSet;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
board::{mesadata::MesadataTrait, Board}, board::{mesadata::AccessMesadata, Board},
drawing::graph::{GetLayer, MakePrimitive}, drawing::graph::{GetLayer, MakePrimitive},
geometry::compound::CompoundManagerTrait, geometry::compound::ManageCompounds,
graph::{GenericIndex, GetPetgraphIndex}, graph::{GenericIndex, GetPetgraphIndex},
layout::{zone::ZoneWeight, CompoundWeight, NodeIndex}, 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 { let Some(selector) = self.node_selector(board, node) else {
return; 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); 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); 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 { let Some(selector) = self.node_selector(board, node) else {
return false; return false;
}; };
@ -58,7 +58,7 @@ impl Selection {
fn node_selector( fn node_selector(
&self, &self,
board: &Board<impl MesadataTrait>, board: &Board<impl AccessMesadata>,
node: NodeIndex, node: NodeIndex,
) -> Option<Selector> { ) -> Option<Selector> {
let layer = match node { let layer = match node {

View File

@ -20,13 +20,13 @@ use topola::{
dot::FixedDotIndex, dot::FixedDotIndex,
graph::{MakePrimitive, PrimitiveIndex}, graph::{MakePrimitive, PrimitiveIndex},
primitive::MakePrimitiveShape, primitive::MakePrimitiveShape,
rules::RulesTrait, rules::AccessRules,
Drawing, Infringement, LayoutException, Drawing, Infringement, LayoutException,
}, },
geometry::{ geometry::{
compound::CompoundManagerTrait, compound::ManageCompounds,
primitive::{BendShape, DotShape, PrimitiveShape, PrimitiveShapeTrait, SegShape}, primitive::{AccessPrimitiveShape, BendShape, DotShape, PrimitiveShape, SegShape},
shape::ShapeTrait, shape::AccessShape,
GenericNode, GenericNode,
}, },
layout::{via::ViaWeight, zone::MakePolyShape, Layout}, 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 { pub struct Layers {
// TODO: // TODO:
@ -10,7 +10,7 @@ pub struct Layers {
} }
impl 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 layer_count = board.layout().drawing().layer_count();
let visible = std::iter::repeat(true) let visible = std::iter::repeat(true)
.take(layer_count) .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| { egui::SidePanel::right("right_side_panel").show(ctx, |ui| {
ui.label("Layers"); ui.label("Layers");

View File

@ -6,14 +6,14 @@ use spade::InsertionError;
use topola::{ use topola::{
autorouter::{ratsnest::Ratsnest, selection::Selection}, autorouter::{ratsnest::Ratsnest, selection::Selection},
board::{mesadata::MesadataTrait, Board}, board::{mesadata::AccessMesadata, Board},
drawing::{ drawing::{
graph::{GetLayer, MakePrimitive}, graph::{GetLayer, MakePrimitive},
primitive::MakePrimitiveShape, primitive::MakePrimitiveShape,
}, },
geometry::{ geometry::{
compound::CompoundManagerTrait, compound::ManageCompounds,
shape::{Shape, ShapeTrait}, shape::{AccessShape, Shape},
}, },
graph::{GenericIndex, GetPetgraphIndex}, graph::{GenericIndex, GetPetgraphIndex},
layout::{ layout::{
@ -30,7 +30,7 @@ pub struct Overlay {
} }
impl 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 { Ok(Self {
ratsnest: Ratsnest::new(board.layout())?, ratsnest: Ratsnest::new(board.layout())?,
selection: Selection::new(), 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 let geoms: Vec<_> = board
.layout() .layout()
.drawing() .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 { let shape: Shape = match node {
NodeIndex::Primitive(primitive) => { NodeIndex::Primitive(primitive) => {
primitive.primitive(board.layout().drawing()).shape().into() primitive.primitive(board.layout().drawing()).shape().into()

View File

@ -1,6 +1,6 @@
use geo::{CoordsIter, Point, Polygon}; use geo::{CoordsIter, Point, Polygon};
use topola::{ use topola::{
geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait}, geometry::primitive::{AccessPrimitiveShape, PrimitiveShape},
math::{self, Circle}, math::{self, Circle},
}; };
@ -54,7 +54,7 @@ impl<'a> Painter<'a> {
self.ui.painter().add(epaint_shape); 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 { let rect = egui::epaint::Rect {
min: [envelope.lower()[0] as f32, -envelope.upper()[1] as f32].into(), min: [envelope.lower()[0] as f32, -envelope.upper()[1] as f32].into(),
max: [envelope.upper()[0] as f32, -envelope.lower()[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::{ use topola::{
autorouter::invoker::{Command, ExecuteWithStatus, GetMaybeNavmesh, GetMaybeTrace, Invoker}, autorouter::invoker::{Command, ExecuteWithStatus, GetMaybeNavmesh, GetMaybeTrace, Invoker},
board::mesadata::MesadataTrait, board::mesadata::AccessMesadata,
drawing::{ drawing::{
graph::{MakePrimitive, PrimitiveIndex}, graph::{MakePrimitive, PrimitiveIndex},
primitive::MakePrimitiveShape, primitive::MakePrimitiveShape,
}, },
geometry::{shape::ShapeTrait, GenericNode}, geometry::{shape::AccessShape, GenericNode},
layout::{via::ViaWeight, zone::MakePolyShape}, layout::{via::ViaWeight, zone::MakePolyShape},
math::Circle, math::Circle,
specctra::mesadata::SpecctraMesadata, specctra::mesadata::SpecctraMesadata,

View File

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

View File

@ -2,7 +2,7 @@ use geo::{CoordsIter, Point, Polygon};
use pathfinder_canvas::{ use pathfinder_canvas::{
vec2f, ArcDirection, Canvas, CanvasRenderingContext2D, ColorU, FillRule, Path2D, RectF, vec2f, ArcDirection, Canvas, CanvasRenderingContext2D, ColorU, FillRule, Path2D, RectF,
}; };
use topola::geometry::primitive::{PrimitiveShape, PrimitiveShapeTrait}; use topola::geometry::primitive::{AccessPrimitiveShape, PrimitiveShape};
pub struct Painter<'a> { pub struct Painter<'a> {
canvas: &'a mut CanvasRenderingContext2D, 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 // 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 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); let bottomright = vec2f(envelope.upper()[0] as f32, -envelope.lower()[1] as f32);

View File

@ -1,14 +1,14 @@
use std::collections::HashMap; use std::collections::HashMap;
use crate::{ use crate::{
board::mesadata::MesadataTrait, board::mesadata::AccessMesadata,
drawing::{ drawing::{
band::BandFirstSegIndex, band::BandFirstSegIndex,
dot::{FixedDotIndex, FixedDotWeight}, dot::{FixedDotIndex, FixedDotWeight},
graph::{GetLayer, GetMaybeNet}, graph::{GetLayer, GetMaybeNet},
seg::{FixedSegIndex, FixedSegWeight}, seg::{FixedSegIndex, FixedSegWeight},
}, },
geometry::{shape::ShapeTrait, GenericNode}, geometry::{shape::AccessShape, GenericNode},
graph::GenericIndex, graph::GenericIndex,
layout::{ layout::{
zone::{GetMaybeApex, MakePolyShape, ZoneWeight}, zone::{GetMaybeApex, MakePolyShape, ZoneWeight},
@ -19,13 +19,13 @@ use crate::{
}; };
#[derive(Debug)] #[derive(Debug)]
pub struct Board<M: MesadataTrait> { pub struct Board<M: AccessMesadata> {
layout: Layout<M>, layout: Layout<M>,
node_to_pinname: HashMap<NodeIndex, String>, node_to_pinname: HashMap<NodeIndex, String>,
pinname_pair_to_band: HashMap<(String, String), BandFirstSegIndex>, 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 { pub fn new(layout: Layout<M>) -> Self {
Self { Self {
layout, 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 bename_layer(&mut self, layer: usize, layername: String);
fn layer_layername(&self, layer: usize) -> Option<&str>; fn layer_layername(&self, layer: usize) -> Option<&str>;
fn layername_layer(&self, layername: &str) -> Option<usize>; fn layername_layer(&self, layername: &str) -> Option<usize>;

View File

@ -4,10 +4,10 @@ use crate::{
drawing::{ drawing::{
graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight, Retag}, graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight, Retag},
primitive::{GenericPrimitive, Primitive}, primitive::{GenericPrimitive, Primitive},
rules::RulesTrait, rules::AccessRules,
Drawing, Drawing,
}, },
geometry::{BendWeightTrait, GetOffset, GetWidth, SetOffset}, geometry::{AccessBendWeight, GetOffset, GetWidth, SetOffset},
graph::{GenericIndex, GetPetgraphIndex}, 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)] #[derive(Debug, Clone, Copy, PartialEq)]
pub struct FixedBendWeight { pub struct FixedBendWeight {
@ -80,7 +80,7 @@ pub struct FixedBendWeight {
} }
impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex); impl_fixed_weight!(FixedBendWeight, FixedBend, FixedBendIndex);
impl BendWeightTrait<PrimitiveWeight> for FixedBendWeight {} impl AccessBendWeight<PrimitiveWeight> for FixedBendWeight {}
impl GetOffset for FixedBendWeight { impl GetOffset for FixedBendWeight {
fn offset(&self) -> f64 { fn offset(&self) -> f64 {
@ -127,4 +127,4 @@ impl GetWidth for LooseBendWeight {
} }
impl_loose_weight!(LooseBendWeight, LooseBend, LooseBendIndex); 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, Drawing,
}; };
use super::rules::RulesTrait; use super::rules::AccessRules;
#[derive(Debug, Clone, Copy)] #[derive(Debug, Clone, Copy)]
pub struct Cane { pub struct Cane {
@ -17,7 +17,7 @@ pub struct Cane {
} }
impl 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 bend = LooseDot::new(dot, drawing).bend();
let dot = LooseBend::new(bend, drawing).other_joint(dot); let dot = LooseBend::new(bend, drawing).other_joint(dot);
let seg = LooseDot::new(dot, drawing).seg().unwrap(); let seg = LooseDot::new(dot, drawing).seg().unwrap();

View File

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

View File

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

View File

@ -18,7 +18,7 @@ use crate::drawing::{
GenericPrimitive, GetCore, GetInnerOuter, GetJoints, GetLimbs, GetOtherJoint, GenericPrimitive, GetCore, GetInnerOuter, GetJoints, GetLimbs, GetOtherJoint,
MakePrimitiveShape, MakePrimitiveShape,
}, },
rules::{GetConditions, RulesTrait}, rules::{AccessRules, GetConditions},
seg::{ seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SegWeight, FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SegWeight,
SeqLooseSegIndex, SeqLooseSegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
@ -26,11 +26,11 @@ use crate::drawing::{
wraparoundable::{GetWraparound, Wraparoundable, WraparoundableIndex}, wraparoundable::{GetWraparound, Wraparoundable, WraparoundableIndex},
}; };
use crate::geometry::{ use crate::geometry::{
compound::CompoundManagerTrait, compound::ManageCompounds,
primitive::{PrimitiveShape, PrimitiveShapeTrait}, primitive::{AccessPrimitiveShape, PrimitiveShape},
with_rtree::{BboxedIndex, GeometryWithRtree}, with_rtree::{BboxedIndex, GeometryWithRtree},
BendWeightTrait, DotWeightTrait, GenericNode, Geometry, GeometryLabel, GetOffset, GetPos, AccessBendWeight, AccessDotWeight, AccessSegWeight, GenericNode, Geometry, GeometryLabel,
GetWidth, SegWeightTrait, GetOffset, GetPos, GetWidth,
}; };
use crate::graph::{GenericIndex, GetPetgraphIndex}; use crate::graph::{GenericIndex, GetPetgraphIndex};
use crate::math::NoTangents; use crate::math::NoTangents;
@ -64,7 +64,7 @@ pub struct Collision(pub PrimitiveShape, pub PrimitiveIndex);
pub struct AlreadyConnected(pub usize, pub PrimitiveIndex); pub struct AlreadyConnected(pub usize, pub PrimitiveIndex);
#[derive(Debug)] #[derive(Debug)]
pub struct Drawing<CW: Copy, R: RulesTrait> { pub struct Drawing<CW: Copy, R: AccessRules> {
geometry_with_rtree: GeometryWithRtree< geometry_with_rtree: GeometryWithRtree<
PrimitiveWeight, PrimitiveWeight,
DotWeight, DotWeight,
@ -80,7 +80,7 @@ pub struct Drawing<CW: Copy, R: RulesTrait> {
} }
#[debug_invariant(self.test_if_looses_dont_infringe_each_other())] #[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 { pub fn new(rules: R, layer_count: usize) -> Self {
Self { Self {
geometry_with_rtree: GeometryWithRtree::new(layer_count), 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_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()))] #[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, &mut self,
weight: W, weight: W,
infringables: Option<&[PrimitiveIndex]>, 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_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().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()))] #[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, &mut self,
from: DotIndex, from: DotIndex,
to: 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_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_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()))] #[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, &mut self,
from: DotIndex, from: DotIndex,
to: 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().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()))] #[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, &mut self,
weight: W, weight: W,
) -> GenericIndex<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().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))] #[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, &mut self,
from: DotIndex, from: DotIndex,
to: 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> { fn add_compound(&mut self, weight: CW) -> GenericIndex<CW> {
self.geometry_with_rtree.add_compound(weight) self.geometry_with_rtree.add_compound(weight)
} }

View File

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

View File

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

View File

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

View File

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

View File

@ -2,7 +2,7 @@ use enum_dispatch::enum_dispatch;
use petgraph::stable_graph::NodeIndex; use petgraph::stable_graph::NodeIndex;
use crate::geometry::{ use crate::geometry::{
primitive::{PrimitiveShape, PrimitiveShapeTrait}, primitive::{AccessPrimitiveShape, PrimitiveShape},
GetOffset, GetWidth, GetOffset, GetWidth,
}; };
use crate::{ use crate::{
@ -10,7 +10,7 @@ use crate::{
bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight}, bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight},
dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight}, dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight, Retag}, graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight, Retag},
rules::{Conditions, GetConditions, RulesTrait}, rules::{AccessRules, Conditions, GetConditions},
seg::{FixedSegWeight, LoneLooseSegWeight, SegIndex, SeqLooseSegIndex, SeqLooseSegWeight}, seg::{FixedSegWeight, LoneLooseSegWeight, SegIndex, SeqLooseSegIndex, SeqLooseSegWeight},
Drawing, Drawing,
}, },
@ -19,7 +19,7 @@ use crate::{
}; };
#[enum_dispatch] #[enum_dispatch]
pub trait GetDrawing<'a, R: RulesTrait> { pub trait GetDrawing<'a, R: AccessRules> {
fn drawing(&self) -> &Drawing<impl Copy, R>; fn drawing(&self) -> &Drawing<impl Copy, R>;
} }
@ -72,7 +72,7 @@ pub trait GetJoints<F, T> {
fn joints(&self) -> (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> { fn first_rail(&self) -> Option<LooseBendIndex> {
self.drawing() self.drawing()
.geometry() .geometry()
@ -85,7 +85,7 @@ pub trait GetBendIndex {
fn bend_index(&self) -> BendIndex; 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 { fn core(&self) -> FixedDotIndex {
FixedDotIndex::new( FixedDotIndex::new(
self.drawing() 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> { fn inner(&self) -> Option<LooseBendIndex> {
self.drawing() self.drawing()
.geometry() .geometry()
@ -114,7 +114,7 @@ pub trait GetInnerOuter<'a, R: RulesTrait>: GetDrawing<'a, R> + GetBendIndex {
macro_rules! impl_primitive { macro_rules! impl_primitive {
($primitive_struct:ident, $weight_struct:ident) => { ($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> for $primitive_struct<'a, CW, R>
{ {
fn weight(&self) -> $weight_struct { 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 { fn layer(&self) -> usize {
self.weight().layer() 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> { fn maybe_net(&self) -> Option<usize> {
self.weight().maybe_net() self.weight().maybe_net()
} }
@ -161,7 +161,7 @@ macro_rules! impl_loose_primitive {
GetLimbs, GetLimbs,
GetConditions GetConditions
)] )]
pub enum Primitive<'a, CW: Copy, R: RulesTrait> { pub enum Primitive<'a, CW: Copy, R: AccessRules> {
FixedDot(FixedDot<'a, CW, R>), FixedDot(FixedDot<'a, CW, R>),
LooseDot(LooseDot<'a, CW, R>), LooseDot(LooseDot<'a, CW, R>),
FixedSeg(FixedSeg<'a, CW, R>), FixedSeg(FixedSeg<'a, CW, R>),
@ -172,12 +172,12 @@ pub enum Primitive<'a, CW: Copy, R: RulesTrait> {
} }
#[derive(Debug)] #[derive(Debug)]
pub struct GenericPrimitive<'a, W, CW: Copy, R: RulesTrait> { pub struct GenericPrimitive<'a, W, CW: Copy, R: AccessRules> {
pub index: GenericIndex<W>, pub index: GenericIndex<W>,
drawing: &'a Drawing<CW, R>, 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 { pub fn new(index: GenericIndex<W>, drawing: &'a Drawing<CW, R>) -> Self {
Self { index, drawing } 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> for GenericPrimitive<'a, W, CW, R>
{ {
fn interior(&self) -> Vec<PrimitiveIndex> { 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> { fn drawing(&self) -> &Drawing<impl Copy, R> {
self.drawing 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> { fn petgraph_index(&self) -> NodeIndex<usize> {
self.index.petgraph_index() 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 where
GenericPrimitive<'a, W, CW, R>: GetWeight<W>, 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 where
GenericPrimitive<'a, W, CW, R>: GetMaybeNet, GenericPrimitive<'a, W, CW, R>: GetMaybeNet,
{ {
@ -246,13 +246,13 @@ where
pub type FixedDot<'a, CW, R> = GenericPrimitive<'a, FixedDotWeight, CW, R>; pub type FixedDot<'a, CW, R> = GenericPrimitive<'a, FixedDotWeight, CW, R>;
impl_fixed_primitive!(FixedDot, FixedDotWeight); 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 { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().dot_shape(self.index.into()) 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> { fn segs(&self) -> Vec<SegIndex> {
self.drawing self.drawing
.geometry() .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>; pub type LooseDot<'a, CW, R> = GenericPrimitive<'a, LooseDotWeight, CW, R>;
impl_loose_primitive!(LooseDot, LooseDotWeight); 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> { pub fn seg(&self) -> Option<SeqLooseSegIndex> {
self.drawing self.drawing
.geometry() .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 { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().dot_shape(self.index.into()) 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> { fn segs(&self) -> Vec<SegIndex> {
if let Some(seg) = self.seg() { if let Some(seg) = self.seg() {
vec![seg.into()] 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>; pub type FixedSeg<'a, CW, R> = GenericPrimitive<'a, FixedSegWeight, CW, R>;
impl_fixed_primitive!(FixedSeg, FixedSegWeight); 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 { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) 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) { fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
let (from, to) = self.drawing.geometry().seg_joints(self.index.into()); 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> 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>; pub type LoneLooseSeg<'a, CW, R> = GenericPrimitive<'a, LoneLooseSegWeight, CW, R>;
impl_loose_primitive!(LoneLooseSeg, LoneLooseSegWeight); 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 { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) 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> for LoneLooseSeg<'a, CW, R>
{ {
fn joints(&self) -> (FixedDotIndex, FixedDotIndex) { 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> 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>; pub type SeqLooseSeg<'a, CW, R> = GenericPrimitive<'a, SeqLooseSegWeight, CW, R>;
impl_loose_primitive!(SeqLooseSeg, SeqLooseSegWeight); 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 { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().seg_shape(self.index.into()) 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) { fn joints(&self) -> (DotIndex, LooseDotIndex) {
let joints = self.drawing.geometry().seg_joints(self.index.into()); let joints = self.drawing.geometry().seg_joints(self.index.into());
if let DotWeight::Fixed(..) = self.drawing.geometry().dot_weight(joints.0) { 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> 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>; pub type FixedBend<'a, CW, R> = GenericPrimitive<'a, FixedBendWeight, CW, R>;
impl_fixed_primitive!(FixedBend, FixedBendWeight); 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 { fn bend_index(&self) -> BendIndex {
self.index.into() 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 { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().bend_shape(self.index.into()) 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) { fn joints(&self) -> (FixedDotIndex, FixedDotIndex) {
let (from, to) = self.drawing.geometry().bend_joints(self.index.into()); 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> for FixedBend<'a, CW, R>
{ {
} }
impl<'a, CW: Copy, R: RulesTrait> GetFirstRail<'a, R> for FixedBend<'a, CW, R> {} impl<'a, CW: Copy, R: AccessRules> 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> 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> {} //impl<'a, R: QueryRules> GetInnerOuter for FixedBend<'a, CW, R> {}
pub type LooseBend<'a, CW, R> = GenericPrimitive<'a, LooseBendWeight, CW, R>; pub type LooseBend<'a, CW, R> = GenericPrimitive<'a, LooseBendWeight, CW, R>;
impl_loose_primitive!(LooseBend, LooseBendWeight); 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 { fn bend_index(&self) -> BendIndex {
self.index.into() 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 { fn from(bend: LooseBend<'a, CW, R>) -> BendIndex {
bend.index.into() 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 { fn shape(&self) -> PrimitiveShape {
self.drawing.geometry().bend_shape(self.index.into()) 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 { fn offset(&self) -> f64 {
self.weight().offset 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) { fn joints(&self) -> (LooseDotIndex, LooseDotIndex) {
let (from, to) = self.drawing.geometry().bend_joints(self.index.into()); 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> for LooseBend<'a, CW, R>
{ {
} }
impl<'a, CW: Copy, R: RulesTrait> GetCore<'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: RulesTrait> GetInnerOuter<'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 maybe_layer: Option<String>,
} }
pub trait RulesTrait { pub trait AccessRules {
fn clearance(&self, conditions1: &Conditions, conditions2: &Conditions) -> f64; fn clearance(&self, conditions1: &Conditions, conditions2: &Conditions) -> f64;
fn largest_clearance(&self, net: Option<usize>) -> f64; fn largest_clearance(&self, net: Option<usize>) -> f64;
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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