diff --git a/src/geometry/geometry.rs b/src/geometry/geometry.rs index e7061c0..4eb2192 100644 --- a/src/geometry/geometry.rs +++ b/src/geometry/geometry.rs @@ -2,9 +2,7 @@ // // SPDX-License-Identifier: MIT -use std::marker::PhantomData; - -use derive_getters::Getters; +use core::marker::PhantomData; use enum_dispatch::enum_dispatch; use geo::Point; use petgraph::{ @@ -75,7 +73,7 @@ impl AccessSegWeight for T {} pub trait AccessBendWeight: SetOffset + GetWidth + Copy {} impl AccessBendWeight for T {} -#[derive(Debug, Getters)] +#[derive(Debug)] pub struct Geometry { graph: StableDiGraph, GeometryLabel, usize>, primitive_weight_marker: PhantomData, @@ -89,18 +87,7 @@ pub struct Geometry { bend_index_marker: PhantomData, } -impl< - PW: GetWidth + TryInto + TryInto + TryInto + Retag + Copy, - DW: AccessDotWeight + Into, - SW: AccessSegWeight + Into, - BW: AccessBendWeight + Into, - CW: Copy, - PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Copy, - DI: GetPetgraphIndex + Into + Copy, - SI: GetPetgraphIndex + Into + Copy, - BI: GetPetgraphIndex + Into + Copy, - > Geometry -{ +impl Geometry { pub fn new() -> Self { Self { graph: StableDiGraph::default(), @@ -116,6 +103,27 @@ impl< } } + // we could use `derive_getters` to generate these, but `Geometry` only wraps a single + // field that actually contains data... + + #[inline(always)] + pub fn graph(&self) -> &StableDiGraph, GeometryLabel, usize> { + &self.graph + } +} + +impl< + PW: GetWidth + TryInto + TryInto + TryInto + Retag + Copy, + DW: AccessDotWeight + Into, + SW: AccessSegWeight + Into, + BW: AccessBendWeight + Into, + CW: Copy, + PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Copy, + DI: GetPetgraphIndex + Into + Copy, + SI: GetPetgraphIndex + Into + Copy, + BI: GetPetgraphIndex + Into + Copy, + > Geometry +{ pub fn add_dot>(&mut self, weight: W) -> GenericIndex { GenericIndex::::new(self.graph.add_node(GenericNode::Primitive(weight.into()))) } @@ -564,17 +572,8 @@ impl< } } -impl< - PW: GetWidth + TryInto + TryInto + TryInto + Retag + Copy, - DW: AccessDotWeight + Into, - SW: AccessSegWeight + Into, - BW: AccessBendWeight + Into, - CW: Copy, - PI: GetPetgraphIndex + TryInto + TryInto + TryInto + Copy, - DI: GetPetgraphIndex + Into + Copy, - SI: GetPetgraphIndex + Into + Copy, - BI: GetPetgraphIndex + Into + Copy, - > ManageCompounds> for Geometry +impl ManageCompounds> + for Geometry { fn add_compound(&mut self, weight: CW) -> GenericIndex { GenericIndex::::new(self.graph.add_node(GenericNode::Compound(weight)))