mirror of https://codeberg.org/topola/topola.git
refactor: get rid of unnecessary bounds on struct generics
This commit is contained in:
parent
3cb3a9a230
commit
ba41ff6837
|
|
@ -117,7 +117,7 @@ pub struct ListTokenizer<R> {
|
|||
column: usize,
|
||||
}
|
||||
|
||||
impl<R: std::io::BufRead> ListTokenizer<R> {
|
||||
impl<R> ListTokenizer<R> {
|
||||
pub fn new(reader: R) -> Self {
|
||||
Self {
|
||||
reader,
|
||||
|
|
@ -140,7 +140,9 @@ impl<R: std::io::BufRead> ListTokenizer<R> {
|
|||
context: (self.line, self.column),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: std::io::BufRead> ListTokenizer<R> {
|
||||
fn next_char(&mut self) -> Result<char, ParseErrorContext> {
|
||||
let return_chr = self.peek_char()?;
|
||||
self.reset_char();
|
||||
|
|
|
|||
|
|
@ -66,14 +66,14 @@ impl<W: io::Write> WriteSes<W> for f64 {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct ListWriter<W: io::Write> {
|
||||
pub struct ListWriter<W> {
|
||||
writable: W,
|
||||
indent_level: usize,
|
||||
multiline_level: usize,
|
||||
pub line_len: usize,
|
||||
}
|
||||
|
||||
impl<W: io::Write> ListWriter<W> {
|
||||
impl<W> ListWriter<W> {
|
||||
pub fn new(writable: W) -> Self {
|
||||
Self {
|
||||
writable,
|
||||
|
|
@ -82,7 +82,9 @@ impl<W: io::Write> ListWriter<W> {
|
|||
line_len: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<W: io::Write> ListWriter<W> {
|
||||
pub fn write_token(&mut self, token: ListToken) -> Result<(), io::Error> {
|
||||
let len = token.len();
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ pub enum AutorouterError {
|
|||
}
|
||||
|
||||
#[derive(Getters)]
|
||||
pub struct Autorouter<M: AccessMesadata> {
|
||||
pub struct Autorouter<M> {
|
||||
pub(super) board: Board<M>,
|
||||
pub(super) ratsnest: Ratsnest,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ pub enum InvokerError {
|
|||
|
||||
#[derive(Getters, Dissolve)]
|
||||
/// Structure that manages the execution and history of commands within the autorouting system
|
||||
pub struct Invoker<M: AccessMesadata> {
|
||||
pub struct Invoker<M> {
|
||||
/// Instance for executing desired autorouting commands
|
||||
pub(super) autorouter: Autorouter<M>,
|
||||
/// History of executed commands
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ impl BandName {
|
|||
/// The struct manages the relationships between board's layout,
|
||||
/// and its compounds, as well as provides methods to manipulate them.
|
||||
#[derive(Debug, Getters)]
|
||||
pub struct Board<M: AccessMesadata> {
|
||||
pub struct Board<M> {
|
||||
layout: Layout<M>,
|
||||
// TODO: Simplify access logic to these members so that `#[getter(skip)]`s can be removed.
|
||||
#[getter(skip)]
|
||||
|
|
@ -61,7 +61,7 @@ pub struct Board<M: AccessMesadata> {
|
|||
band_bandname: BiHashMap<BandUid, BandName>,
|
||||
}
|
||||
|
||||
impl<M: AccessMesadata> Board<M> {
|
||||
impl<M> Board<M> {
|
||||
/// Initializes the board with given [`Layout`]
|
||||
pub fn new(layout: Layout<M>) -> Self {
|
||||
Self {
|
||||
|
|
@ -71,6 +71,13 @@ impl<M: AccessMesadata> Board<M> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the layout, allowing modifications.
|
||||
pub fn layout_mut(&mut self) -> &mut Layout<M> {
|
||||
&mut self.layout
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: AccessMesadata> Board<M> {
|
||||
/// Adds a new fixed dot with an optional pin name.
|
||||
///
|
||||
/// Inserts the dot into the layout and, if a pin name is provided, maps it to the created dot's node.
|
||||
|
|
@ -249,11 +256,6 @@ impl<M: AccessMesadata> Board<M> {
|
|||
pub fn mesadata(&self) -> &M {
|
||||
self.layout.drawing().rules()
|
||||
}
|
||||
|
||||
/// Returns a mutable reference to the layout, allowing modifications.
|
||||
pub fn layout_mut(&mut self) -> &mut Layout<M> {
|
||||
&mut self.layout
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: AccessMesadata>
|
||||
|
|
|
|||
|
|
@ -56,20 +56,18 @@ impl From<BandTermsegIndex> for LooseIndex {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> MakeRef<'a, BandRef<'a, CW, R>, Drawing<CW, R>>
|
||||
for BandTermsegIndex
|
||||
{
|
||||
impl<'a, CW, R> MakeRef<'a, BandRef<'a, CW, R>, Drawing<CW, R>> for BandTermsegIndex {
|
||||
fn ref_(&self, drawing: &'a Drawing<CW, R>) -> BandRef<'a, CW, R> {
|
||||
BandRef::new(*self, drawing)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct BandRef<'a, CW: Copy, R: AccessRules> {
|
||||
pub struct BandRef<'a, CW, R> {
|
||||
first_seg: BandTermsegIndex,
|
||||
drawing: &'a Drawing<CW, R>,
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> BandRef<'a, CW, R> {
|
||||
impl<'a, CW, R> BandRef<'a, CW, R> {
|
||||
pub fn new(first_seg: BandTermsegIndex, drawing: &'a Drawing<CW, R>) -> BandRef<'a, CW, R> {
|
||||
Self { first_seg, drawing }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,15 +12,17 @@ use super::{
|
|||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Collect<'a, CW: Copy, R: AccessRules> {
|
||||
pub struct Collect<'a, CW, R> {
|
||||
drawing: &'a Drawing<CW, R>,
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> Collect<'a, CW, R> {
|
||||
impl<'a, CW, R> Collect<'a, CW, R> {
|
||||
pub fn new(drawing: &'a Drawing<CW, R>) -> Self {
|
||||
Self { drawing }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> Collect<'a, CW, R> {
|
||||
pub fn loose_band_uid(&self, start_loose: LooseIndex) -> BandUid {
|
||||
BandUid::new(
|
||||
self.loose_band_first_seg(start_loose),
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ pub struct Collision(pub PrimitiveShape, pub PrimitiveIndex);
|
|||
#[error("{1:?} is already connected to net {0}")]
|
||||
pub struct AlreadyConnected(pub usize, pub PrimitiveIndex);
|
||||
|
||||
pub type DrawingEdit<CW: Copy> = GeometryEdit<
|
||||
pub type DrawingEdit<CW> = GeometryEdit<
|
||||
PrimitiveWeight,
|
||||
DotWeight,
|
||||
SegWeight,
|
||||
|
|
@ -79,7 +79,7 @@ pub type DrawingEdit<CW: Copy> = GeometryEdit<
|
|||
>;
|
||||
|
||||
#[derive(Debug, Getters)]
|
||||
pub struct Drawing<CW: Copy, R: AccessRules> {
|
||||
pub struct Drawing<CW, R> {
|
||||
recording_geometry_with_rtree: RecordingGeometryWithRtree<
|
||||
PrimitiveWeight,
|
||||
DotWeight,
|
||||
|
|
|
|||
|
|
@ -18,15 +18,17 @@ use super::{
|
|||
Drawing,
|
||||
};
|
||||
|
||||
pub struct Guide<'a, CW: Copy, R: AccessRules> {
|
||||
pub struct Guide<'a, CW, R> {
|
||||
drawing: &'a Drawing<CW, R>,
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> Guide<'a, CW, R> {
|
||||
impl<'a, CW, R> Guide<'a, CW, R> {
|
||||
pub fn new(drawing: &'a Drawing<CW, R>) -> Self {
|
||||
Self { drawing }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> Guide<'a, CW, R> {
|
||||
pub fn head_into_dot_segment(
|
||||
&self,
|
||||
head: &Head,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub enum Head {
|
|||
Cane(CaneHead),
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> MakeRef<'a, HeadRef<'a, CW, R>, Drawing<CW, R>> for Head {
|
||||
impl<'a, CW, R> MakeRef<'a, HeadRef<'a, CW, R>, Drawing<CW, R>> for Head {
|
||||
fn ref_(&self, drawing: &'a Drawing<CW, R>) -> HeadRef<'a, CW, R> {
|
||||
HeadRef::new(*self, drawing)
|
||||
}
|
||||
|
|
@ -67,18 +67,18 @@ impl GetFace for CaneHead {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct HeadRef<'a, CW: Copy, R: AccessRules> {
|
||||
pub struct HeadRef<'a, CW, R> {
|
||||
head: Head,
|
||||
drawing: &'a Drawing<CW, R>,
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> HeadRef<'a, CW, R> {
|
||||
impl<'a, CW, R> HeadRef<'a, CW, R> {
|
||||
pub fn new(head: Head, drawing: &'a Drawing<CW, R>) -> Self {
|
||||
Self { drawing, head }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, CW: Copy, R: AccessRules> GetFace for HeadRef<'a, CW, R> {
|
||||
impl<'a, CW, R> GetFace for HeadRef<'a, CW, R> {
|
||||
fn face(&self) -> DotIndex {
|
||||
self.head.face()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,17 +23,7 @@ pub trait ApplyGeometryEdit<
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct GeometryEdit<
|
||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
DW: AccessDotWeight<PW> + GetLayer,
|
||||
SW: AccessSegWeight<PW> + GetLayer,
|
||||
BW: AccessBendWeight<PW> + GetLayer,
|
||||
CW: Copy,
|
||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
|
||||
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
> {
|
||||
pub struct GeometryEdit<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
|
||||
pub(super) dots: HashMap<DI, (Option<DW>, Option<DW>)>,
|
||||
pub(super) segs: HashMap<SI, (Option<((DI, DI), SW)>, Option<((DI, DI), SW)>)>,
|
||||
pub(super) bends: HashMap<BI, (Option<((DI, DI, DI), BW)>, Option<((DI, DI, DI), BW)>)>,
|
||||
|
|
|
|||
|
|
@ -70,17 +70,7 @@ pub trait AccessSegWeight<PW>: GetWidth + Into<PW> + Copy {}
|
|||
pub trait AccessBendWeight<PW>: GetOffset + SetOffset + GetWidth + Into<PW> + Copy {}
|
||||
|
||||
#[derive(Debug, Getters)]
|
||||
pub struct Geometry<
|
||||
PW: GetWidth + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
DW: AccessDotWeight<PW>,
|
||||
SW: AccessSegWeight<PW>,
|
||||
BW: AccessBendWeight<PW>,
|
||||
CW: Copy,
|
||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
|
||||
DI: GetPetgraphIndex + Into<PI> + Copy,
|
||||
SI: GetPetgraphIndex + Into<PI> + Copy,
|
||||
BI: GetPetgraphIndex + Into<PI> + Copy,
|
||||
> {
|
||||
pub struct Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
|
||||
graph: StableDiGraph<GenericNode<PW, CW>, GeometryLabel, usize>,
|
||||
primitive_weight_marker: PhantomData<PW>,
|
||||
dot_weight_marker: PhantomData<DW>,
|
||||
|
|
|
|||
|
|
@ -19,17 +19,7 @@ use super::{
|
|||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RecordingGeometryWithRtree<
|
||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
DW: AccessDotWeight<PW> + GetLayer,
|
||||
SW: AccessSegWeight<PW> + GetLayer,
|
||||
BW: AccessBendWeight<PW> + GetLayer,
|
||||
CW: Copy,
|
||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Eq + Hash + Copy,
|
||||
DI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
SI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
BI: GetPetgraphIndex + Into<PI> + Eq + Hash + Copy,
|
||||
> {
|
||||
pub struct RecordingGeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
|
||||
geometry_with_rtree: GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,17 +36,7 @@ impl RTreeObject for Bbox {
|
|||
pub type BboxedIndex<I> = GeomWithData<Bbox, I>;
|
||||
|
||||
#[derive(Debug, Getters)]
|
||||
pub struct GeometryWithRtree<
|
||||
PW: GetWidth + GetLayer + TryInto<DW> + TryInto<SW> + TryInto<BW> + Retag<PI> + Copy,
|
||||
DW: AccessDotWeight<PW> + GetLayer,
|
||||
SW: AccessSegWeight<PW> + GetLayer,
|
||||
BW: AccessBendWeight<PW> + GetLayer,
|
||||
CW: Copy,
|
||||
PI: GetPetgraphIndex + TryInto<DI> + TryInto<SI> + TryInto<BI> + Copy,
|
||||
DI: GetPetgraphIndex + Into<PI> + Copy,
|
||||
SI: GetPetgraphIndex + Into<PI> + Copy,
|
||||
BI: GetPetgraphIndex + Into<PI> + Copy,
|
||||
> {
|
||||
pub struct GeometryWithRtree<PW, DW, SW, BW, CW, PI, DI, SI, BI> {
|
||||
geometry: Geometry<PW, DW, SW, BW, CW, PI, DI, SI, BI>,
|
||||
rtree: RTree<BboxedIndex<GenericNode<PI, GenericIndex<CW>>>>,
|
||||
layer_count: usize,
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub struct InteractiveInput {
|
|||
}
|
||||
|
||||
/// This is the execution context passed to the stepper on each step
|
||||
pub struct ActivityContext<'a, M: AccessMesadata> {
|
||||
pub struct ActivityContext<'a, M> {
|
||||
pub interactive_input: &'a InteractiveInput,
|
||||
pub invoker: &'a mut Invoker<M>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
};
|
||||
|
||||
/// Structure that manages the invoker and activities
|
||||
pub struct Interactor<M: AccessMesadata> {
|
||||
pub struct Interactor<M> {
|
||||
invoker: Invoker<M>,
|
||||
activity: Option<ActivityStepperWithStatus>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,15 +43,17 @@ pub type LayoutEdit = DrawingEdit<CompoundWeight>;
|
|||
|
||||
#[derive(Debug, Getters)]
|
||||
/// Structure for managing the Layout design
|
||||
pub struct Layout<R: AccessRules> {
|
||||
pub struct Layout<R> {
|
||||
drawing: Drawing<CompoundWeight, R>,
|
||||
}
|
||||
|
||||
impl<R: AccessRules> Layout<R> {
|
||||
impl<R> Layout<R> {
|
||||
pub fn new(drawing: Drawing<CompoundWeight, R>) -> Self {
|
||||
Self { drawing }
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: AccessRules> Layout<R> {
|
||||
/// Insert [`Cane`] object into the [`Layout`]
|
||||
pub fn insert_cane(
|
||||
&mut self,
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ pub trait GetMaybeApex {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Poly<'a, R: AccessRules> {
|
||||
pub struct Poly<'a, R> {
|
||||
pub index: GenericIndex<PolyWeight>,
|
||||
layout: &'a Layout<R>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,12 +11,12 @@ use crate::{
|
|||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Via<'a, R: AccessRules> {
|
||||
pub struct Via<'a, R> {
|
||||
pub index: GenericIndex<ViaWeight>,
|
||||
layout: &'a Layout<R>,
|
||||
}
|
||||
|
||||
impl<'a, R: AccessRules> Via<'a, R> {
|
||||
impl<'a, R> Via<'a, R> {
|
||||
pub fn new(index: GenericIndex<ViaWeight>, layout: &'a Layout<R>) -> Self {
|
||||
Self { index, layout }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ pub enum DrawException {
|
|||
/// This struct is a simple wrapper whose sole purpose is to have a separate
|
||||
/// file for the router module's routines for drawing and erasing the primitives
|
||||
/// to pull out or contract the currently routed band.
|
||||
pub struct Draw<'a, R: AccessRules> {
|
||||
pub struct Draw<'a, R> {
|
||||
layout: &'a mut Layout<R>,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ impl NavcordStepper {
|
|||
}
|
||||
}
|
||||
|
||||
pub struct NavcordStepContext<'a: 'b, 'b, R: AccessRules> {
|
||||
pub struct NavcordStepContext<'a: 'b, 'b, R> {
|
||||
pub navcorder: &'b mut Navcorder<'a, R>,
|
||||
pub navmesh: &'b Navmesh,
|
||||
pub to: NavvertexIndex,
|
||||
|
|
|
|||
|
|
@ -21,15 +21,17 @@ pub enum NavcorderException {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Navcorder<'a, R: AccessRules> {
|
||||
pub struct Navcorder<'a, R> {
|
||||
pub layout: &'a mut Layout<R>,
|
||||
}
|
||||
|
||||
impl<'a, R: AccessRules> Navcorder<'a, R> {
|
||||
impl<'a, R> Navcorder<'a, R> {
|
||||
pub fn new(layout: &mut Layout<R>) -> Navcorder<R> {
|
||||
Navcorder { layout }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, R: AccessRules> Navcorder<'a, R> {
|
||||
pub fn start(
|
||||
&mut self,
|
||||
recorder: LayoutEdit,
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ pub struct RouterOptions {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct RouterAstarStrategy<'a, R: AccessRules> {
|
||||
pub struct RouterAstarStrategy<'a, R> {
|
||||
pub navcorder: Navcorder<'a, R>,
|
||||
pub navcord: &'a mut NavcordStepper,
|
||||
pub target: FixedDotIndex,
|
||||
|
|
@ -46,7 +46,7 @@ pub struct RouterAstarStrategy<'a, R: AccessRules> {
|
|||
pub probe_obstacles: Vec<PrimitiveIndex>,
|
||||
}
|
||||
|
||||
impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
|
||||
impl<'a, R> RouterAstarStrategy<'a, R> {
|
||||
pub fn new(
|
||||
navcorder: Navcorder<'a, R>,
|
||||
navcord: &'a mut NavcordStepper,
|
||||
|
|
@ -60,7 +60,9 @@ impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
|
|||
probe_obstacles: vec![],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, R: AccessRules> RouterAstarStrategy<'a, R> {
|
||||
fn bihead_length(&self) -> f64 {
|
||||
self.navcord
|
||||
.head
|
||||
|
|
|
|||
|
|
@ -12,21 +12,14 @@ pub trait GetTrianvertexNodeIndex<I> {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Triangulation<
|
||||
I: Copy + PartialEq + GetPetgraphIndex,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||
EW: Copy + Default,
|
||||
> {
|
||||
pub struct Triangulation<I, VW: GetTrianvertexNodeIndex<I> + HasPosition, EW: Default> {
|
||||
triangulation: DelaunayTriangulation<VW, EW>,
|
||||
trianvertex_to_handle: Box<[Option<FixedVertexHandle>]>,
|
||||
index_marker: PhantomData<I>,
|
||||
}
|
||||
|
||||
impl<
|
||||
I: Copy + PartialEq + GetPetgraphIndex,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
||||
EW: Copy + Default,
|
||||
> Triangulation<I, VW, EW>
|
||||
impl<I: GetPetgraphIndex, VW: GetTrianvertexNodeIndex<I> + HasPosition, EW: Default>
|
||||
Triangulation<I, VW, EW>
|
||||
{
|
||||
pub fn new(node_bound: usize) -> Self {
|
||||
Self {
|
||||
|
|
@ -57,12 +50,6 @@ impl<
|
|||
)
|
||||
}
|
||||
|
||||
pub fn position(&self, vertex: I) -> Point {
|
||||
let position =
|
||||
spade::Triangulation::vertex(&self.triangulation, self.handle(vertex)).position();
|
||||
point! {x: position.x, y: position.y}
|
||||
}
|
||||
|
||||
fn vertex(&self, handle: FixedVertexHandle) -> I {
|
||||
spade::Triangulation::vertex(&self.triangulation, handle)
|
||||
.as_ref()
|
||||
|
|
@ -72,12 +59,21 @@ impl<
|
|||
fn handle(&self, vertex: I) -> FixedVertexHandle {
|
||||
self.trianvertex_to_handle[vertex.petgraph_index().index()].unwrap()
|
||||
}
|
||||
|
||||
pub fn position(&self, vertex: I) -> Point<<VW as HasPosition>::Scalar>
|
||||
where
|
||||
<VW as HasPosition>::Scalar: geo::CoordNum,
|
||||
{
|
||||
let position =
|
||||
spade::Triangulation::vertex(&self.triangulation, self.handle(vertex)).position();
|
||||
point! {x: position.x, y: position.y}
|
||||
}
|
||||
}
|
||||
|
||||
impl<
|
||||
I: Copy + PartialEq + GetPetgraphIndex,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
||||
EW: Copy + Default,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||
EW: Default,
|
||||
> visit::GraphBase for Triangulation<I, VW, EW>
|
||||
{
|
||||
type NodeId = I;
|
||||
|
|
@ -85,18 +81,18 @@ impl<
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct TriangulationEdgeWeightWrapper<EW: Copy + Default> {
|
||||
pub struct TriangulationEdgeWeightWrapper<EW> {
|
||||
length: f64,
|
||||
pub weight: EW,
|
||||
}
|
||||
|
||||
impl<EW: Copy + Default> PartialEq for TriangulationEdgeWeightWrapper<EW> {
|
||||
impl<EW> PartialEq for TriangulationEdgeWeightWrapper<EW> {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.length.eq(&other.length)
|
||||
}
|
||||
}
|
||||
|
||||
impl<EW: Copy + Default> PartialOrd for TriangulationEdgeWeightWrapper<EW> {
|
||||
impl<EW> PartialOrd for TriangulationEdgeWeightWrapper<EW> {
|
||||
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||
self.length.partial_cmp(&other.length)
|
||||
}
|
||||
|
|
@ -104,7 +100,7 @@ impl<EW: Copy + Default> PartialOrd for TriangulationEdgeWeightWrapper<EW> {
|
|||
|
||||
impl<
|
||||
I: Copy + PartialEq + GetPetgraphIndex,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||
EW: Copy + Default,
|
||||
> visit::Data for Triangulation<I, VW, EW>
|
||||
{
|
||||
|
|
@ -113,13 +109,13 @@ impl<
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct TriangulationEdgeReference<I, EW: Copy + Default> {
|
||||
pub struct TriangulationEdgeReference<I, EW> {
|
||||
from: I,
|
||||
to: I,
|
||||
weight: TriangulationEdgeWeightWrapper<EW>,
|
||||
}
|
||||
|
||||
impl<I: Copy, EW: Copy + Default> visit::EdgeRef for TriangulationEdgeReference<I, EW> {
|
||||
impl<I: Copy, EW: Copy> visit::EdgeRef for TriangulationEdgeReference<I, EW> {
|
||||
type NodeId = I;
|
||||
type EdgeId = (I, I);
|
||||
type Weight = TriangulationEdgeWeightWrapper<EW>;
|
||||
|
|
@ -144,8 +140,8 @@ impl<I: Copy, EW: Copy + Default> visit::EdgeRef for TriangulationEdgeReference<
|
|||
impl<
|
||||
'a,
|
||||
I: Copy + PartialEq + GetPetgraphIndex,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
||||
EW: Copy + Default,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||
EW: Default,
|
||||
> visit::IntoNeighbors for &'a Triangulation<I, VW, EW>
|
||||
{
|
||||
type Neighbors = Box<dyn Iterator<Item = I> + 'a>;
|
||||
|
|
@ -221,8 +217,8 @@ impl<
|
|||
impl<
|
||||
'a,
|
||||
I: Copy + PartialEq + GetPetgraphIndex,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
||||
EW: Copy + Default,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||
EW: Default,
|
||||
> visit::IntoNodeIdentifiers for &'a Triangulation<I, VW, EW>
|
||||
{
|
||||
type NodeIdentifiers = Box<dyn Iterator<Item = I> + 'a>;
|
||||
|
|
@ -238,13 +234,24 @@ impl<
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub struct TriangulationVertexReference<'a, I: Copy, VW> {
|
||||
#[derive(Debug, PartialEq)]
|
||||
pub struct TriangulationVertexReference<'a, I, VW> {
|
||||
index: I,
|
||||
weight: &'a VW,
|
||||
}
|
||||
|
||||
impl<'a, I: Copy, VW: Copy> visit::NodeRef for TriangulationVertexReference<'a, I, VW> {
|
||||
impl<I: Clone, VW> Clone for TriangulationVertexReference<'_, I, VW> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
index: self.index.clone(),
|
||||
weight: self.weight,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<I: Copy, VW> Copy for TriangulationVertexReference<'_, I, VW> {}
|
||||
|
||||
impl<I: Copy, VW> visit::NodeRef for TriangulationVertexReference<'_, I, VW> {
|
||||
type NodeId = I;
|
||||
type Weight = VW;
|
||||
|
||||
|
|
@ -260,7 +267,7 @@ impl<'a, I: Copy, VW: Copy> visit::NodeRef for TriangulationVertexReference<'a,
|
|||
impl<
|
||||
'a,
|
||||
I: Copy + PartialEq + GetPetgraphIndex,
|
||||
VW: Copy + GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||
EW: Copy + Default,
|
||||
> visit::IntoNodeReferences for &'a Triangulation<I, VW, EW>
|
||||
{
|
||||
|
|
@ -283,8 +290,8 @@ impl<
|
|||
impl<
|
||||
'a,
|
||||
I: Copy + PartialEq + GetPetgraphIndex + std::fmt::Debug,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition<Scalar = f64>,
|
||||
EW: Copy + Default,
|
||||
VW: GetTrianvertexNodeIndex<I> + HasPosition,
|
||||
EW: Default,
|
||||
> visit::NodeIndexable for &'a Triangulation<I, VW, EW>
|
||||
{
|
||||
fn node_bound(&self) -> usize {
|
||||
|
|
|
|||
Loading…
Reference in New Issue