diff --git a/src/route.rs b/src/route.rs index 0ae0adc..171d3de 100644 --- a/src/route.rs +++ b/src/route.rs @@ -15,16 +15,14 @@ pub struct Route<'a> { layout: &'a mut Layout, rules: &'a Rules, mesh: &'a Mesh, - width: f64, } impl<'a> Route<'a> { - pub fn new(layout: &'a mut Layout, rules: &'a Rules, mesh: &'a Mesh, width: f64) -> Self { + pub fn new(layout: &'a mut Layout, rules: &'a Rules, mesh: &'a Mesh) -> Self { Route { layout, rules, mesh, - width, } } @@ -38,13 +36,17 @@ impl<'a> Route<'a> { } } - pub fn finish(&mut self, trace: Trace, into: VertexIndex) { + pub fn finish(&mut self, trace: Trace, into: VertexIndex, width: f64) -> Result<(), ()> { let into_dot = self.mesh.dot(into); - let width = self.width; - self.draw().finish(trace.head, into_dot, width); + self.draw().finish(trace.head, into_dot, width) } - pub fn rework_path(&mut self, mut trace: Trace, path: &[VertexIndex]) -> Result { + pub fn rework_path( + &mut self, + mut trace: Trace, + path: &[VertexIndex], + width: f64, + ) -> Result { let prefix_length = trace .path .iter() @@ -54,12 +56,17 @@ impl<'a> Route<'a> { let length = trace.path.len(); trace = self.undo_path(trace, length - prefix_length)?; - self.path(trace, &path[prefix_length..]) + self.path(trace, &path[prefix_length..], width) } - pub fn path(&mut self, mut trace: Trace, path: &[VertexIndex]) -> Result { + pub fn path( + &mut self, + mut trace: Trace, + path: &[VertexIndex], + width: f64, + ) -> Result { for vertex in path { - trace = self.step(trace, *vertex)?; + trace = self.step(trace, *vertex, width)?; } Ok(trace) } @@ -71,9 +78,8 @@ impl<'a> Route<'a> { Ok(trace) } - pub fn step(&mut self, mut trace: Trace, to: VertexIndex) -> Result { + pub fn step(&mut self, mut trace: Trace, to: VertexIndex, width: f64) -> Result { let to_dot = self.mesh.dot(to); - let width = self.width; trace.head = self .draw() .segbend_around_dot(trace.head, to_dot, true, width)?; diff --git a/src/router.rs b/src/router.rs index d6c663c..73815bd 100644 --- a/src/router.rs +++ b/src/router.rs @@ -54,12 +54,12 @@ impl Router { .map(|vertex| self.mesh.dot(*vertex)) .collect();*/ - let mut trace = self.route(&mesh, 5.0).start(path[0]); + let mut trace = self.route(&mesh).start(path[0]); trace = self - .route(&mesh, 5.0) - .path(trace, &path[1..(path.len() - 1)]) + .route(&mesh) + .path(trace, &path[1..(path.len() - 1)], 5.0) .unwrap(); // TODO. - let _ = self.route(&mesh, 5.0).finish(trace, path[path.len() - 1]); + let _ = self.route(&mesh).finish(trace, path[path.len() - 1], 5.0); Ok(()) } @@ -176,8 +176,8 @@ impl Router { Ok(()) }*/ - pub fn route<'a>(&'a mut self, mesh: &'a Mesh, width: f64) -> Route { - Route::new(&mut self.layout, &self.rules, mesh, width) + pub fn route<'a>(&'a mut self, mesh: &'a Mesh) -> Route { + Route::new(&mut self.layout, &self.rules, mesh) } /*pub fn routeedges(&self) -> impl Iterator + '_ {