From cff6b5aaf6bd0b6e6399f11a2fc02bef5bdf33b5 Mon Sep 17 00:00:00 2001 From: Mikolaj Wielgus Date: Thu, 13 Jun 2024 13:34:16 +0200 Subject: [PATCH] cleanup: cargo fix, cargo fmt --- src/autorouter/autorouter.rs | 26 ++------ src/autorouter/place_via.rs | 2 - src/autorouter/ratsnest.rs | 2 +- src/autorouter/selection.rs | 2 +- src/board/board.rs | 3 +- src/board/mesadata.rs | 2 +- src/drawing/drawing.rs | 2 +- src/drawing/primitive.rs | 6 +- src/dsn/common.rs | 9 +-- src/dsn/design.rs | 39 ++++++------ src/dsn/mod.rs | 6 +- src/dsn/read.rs | 40 ++++++++---- src/dsn/structure2.rs | 119 +++++++++++++++++++++++------------ src/dsn/write.rs | 42 +++++-------- src/geometry/geometry.rs | 8 +-- src/geometry/poly.rs | 1 - src/layout/layout.rs | 18 ++---- src/layout/zone.rs | 8 +-- src/router/router.rs | 5 -- src/router/tracer.rs | 4 +- tests/single_layer.rs | 17 +---- 21 files changed, 170 insertions(+), 191 deletions(-) diff --git a/src/autorouter/autorouter.rs b/src/autorouter/autorouter.rs index 60e8347..b92e433 100644 --- a/src/autorouter/autorouter.rs +++ b/src/autorouter/autorouter.rs @@ -1,14 +1,4 @@ -use std::{ - collections::HashSet, - iter::Peekable, - sync::{Arc, Mutex}, -}; - -use geo::Point; -use petgraph::{ - graph::{EdgeIndex, EdgeIndices}, - visit::{EdgeRef, IntoEdgeReferences}, -}; +use petgraph::graph::EdgeIndex; use spade::InsertionError; use thiserror::Error; @@ -20,17 +10,9 @@ use crate::{ selection::Selection, }, board::{mesadata::MesadataTrait, Board}, - drawing::{ - dot::FixedDotIndex, - graph::{GetLayer, GetMaybeNet}, - Infringement, - }, - layout::{via::ViaWeight, Layout}, - math::Circle, - router::{ - navmesh::{Navmesh, NavmeshError}, - Router, RouterError, RouterObserverTrait, - }, + drawing::{dot::FixedDotIndex, Infringement}, + layout::via::ViaWeight, + router::{navmesh::NavmeshError, RouterError, RouterObserverTrait}, triangulation::GetTrianvertexIndex, }; diff --git a/src/autorouter/place_via.rs b/src/autorouter/place_via.rs index d9cdc8b..c77c0ef 100644 --- a/src/autorouter/place_via.rs +++ b/src/autorouter/place_via.rs @@ -1,5 +1,3 @@ -use geo::Point; - use crate::{ autorouter::{Autorouter, AutorouterError}, board::mesadata::MesadataTrait, diff --git a/src/autorouter/ratsnest.rs b/src/autorouter/ratsnest.rs index 2f66f96..b4ace6f 100644 --- a/src/autorouter/ratsnest.rs +++ b/src/autorouter/ratsnest.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use enum_dispatch::enum_dispatch; use geo::Point; use petgraph::{ - data::{Element, FromElements}, + data::Element, graph::{EdgeIndex, NodeIndex, UnGraph}, unionfind::UnionFind, visit::{EdgeRef, IntoEdgeReferences, NodeIndexable}, diff --git a/src/autorouter/selection.rs b/src/autorouter/selection.rs index b76f58d..9abe479 100644 --- a/src/autorouter/selection.rs +++ b/src/autorouter/selection.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use crate::{ board::{mesadata::MesadataTrait, Board}, - drawing::graph::{GetLayer, MakePrimitive, PrimitiveIndex}, + drawing::graph::{GetLayer, MakePrimitive}, geometry::compound::CompoundManagerTrait, graph::{GenericIndex, GetNodeIndex}, layout::{zone::ZoneWeight, CompoundWeight, NodeIndex}, diff --git a/src/board/board.rs b/src/board/board.rs index 2c4b054..dbe1d9d 100644 --- a/src/board/board.rs +++ b/src/board/board.rs @@ -5,9 +5,8 @@ use crate::{ drawing::{ band::BandIndex, dot::{FixedDotIndex, FixedDotWeight}, - graph::{GetLayer, GetMaybeNet, PrimitiveIndex}, + graph::{GetLayer, GetMaybeNet}, seg::{FixedSegIndex, FixedSegWeight}, - Infringement, }, geometry::{shape::ShapeTrait, GenericNode}, graph::GenericIndex, diff --git a/src/board/mesadata.rs b/src/board/mesadata.rs index 4b82f46..54d46a2 100644 --- a/src/board/mesadata.rs +++ b/src/board/mesadata.rs @@ -1,4 +1,4 @@ -use crate::{drawing::rules::RulesTrait, layout::NodeIndex}; +use crate::drawing::rules::RulesTrait; pub trait MesadataTrait: RulesTrait { fn bename_layer(&mut self, layer: u64, layername: String); diff --git a/src/drawing/drawing.rs b/src/drawing/drawing.rs index 526177a..8fa0ad1 100644 --- a/src/drawing/drawing.rs +++ b/src/drawing/drawing.rs @@ -2,7 +2,7 @@ use contracts::debug_ensures; use enum_dispatch::enum_dispatch; use geo::Point; -use rstar::{RTree, RTreeObject, AABB}; +use rstar::{RTree, AABB}; use thiserror::Error; use crate::drawing::{ diff --git a/src/drawing/primitive.rs b/src/drawing/primitive.rs index 8437533..8caaee1 100644 --- a/src/drawing/primitive.rs +++ b/src/drawing/primitive.rs @@ -10,12 +10,8 @@ use crate::{ bend::{BendIndex, FixedBendWeight, LooseBendIndex, LooseBendWeight}, dot::{DotIndex, DotWeight, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight}, graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight, Retag}, - loose::LooseIndex, rules::{Conditions, GetConditions, RulesTrait}, - seg::{ - FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SegIndex, SeqLooseSegIndex, - SeqLooseSegWeight, - }, + seg::{FixedSegWeight, LoneLooseSegWeight, SegIndex, SeqLooseSegIndex, SeqLooseSegWeight}, Drawing, }, geometry::GenericNode, diff --git a/src/dsn/common.rs b/src/dsn/common.rs index 6540f86..d4a3913 100644 --- a/src/dsn/common.rs +++ b/src/dsn/common.rs @@ -1,8 +1,4 @@ -use dsn_derive::ReadDsn; - -use super::structure2::*; -use super::read::{ListTokenizer, ReadDsn, ParseError}; -use super::write::{ListWriter, WriteDsn}; +use super::read::ParseError; pub enum ListToken { Start { name: String }, @@ -39,7 +35,7 @@ impl ListToken { } } - pub fn expect_end(self) -> Result<(), ParseError> { + pub fn expect_end(self) -> Result<(), ParseError> { if let Self::End = self { Ok(()) } else { @@ -55,4 +51,3 @@ impl ListToken { } } } - diff --git a/src/dsn/design.rs b/src/dsn/design.rs index 6eeccd9..505ecf9 100644 --- a/src/dsn/design.rs +++ b/src/dsn/design.rs @@ -1,6 +1,6 @@ use std::collections::HashMap; -use geo::{point, Point, Rotate, Translate}; +use geo::{point, Point, Rotate}; use thiserror::Error; use crate::{ @@ -11,8 +11,6 @@ use crate::{ mesadata::DsnMesadata, structure::{self, DsnFile, Layer, Pcb, Shape}, }, - geometry::compound::CompoundManagerTrait, - graph::{GenericIndex, GetNodeIndex}, layout::{zone::SolidZoneWeight, Layout}, math::Circle, }; @@ -32,12 +30,11 @@ pub struct DsnDesign { impl DsnDesign { pub fn load_from_file(filename: &str) -> Result { - let file = std::fs::File::open(filename)?; let reader = std::io::BufReader::new(file); let mut list_reader = super::read::ListTokenizer::new(reader); - let mut dsn = list_reader.read_value::(); + let dsn = list_reader.read_value::(); // TODO: make_board() still uses the old version of structure.rs // so we can't pass the data to topola for real @@ -62,22 +59,28 @@ impl DsnDesign { if let Some(net) = net_outs.get_mut(&wire.net) { net.wire.push(wire); } else { - net_outs.insert(wire.net.clone(), NetOut { - name: wire.net.clone(), - wire: vec!(wire), - via: Vec::new() - }); + net_outs.insert( + wire.net.clone(), + NetOut { + name: wire.net.clone(), + wire: vec![wire], + via: Vec::new(), + }, + ); } } for via in dsn.pcb.wiring.vias { if let Some(net) = net_outs.get_mut(&via.net) { net.via.push(via); } else { - net_outs.insert(via.net.clone(), NetOut { - name: via.net.clone(), - wire: Vec::new(), - via: vec!(via) - }); + net_outs.insert( + via.net.clone(), + NetOut { + name: via.net.clone(), + wire: Vec::new(), + via: vec![via], + }, + ); } } @@ -89,7 +92,7 @@ impl DsnDesign { resolution: Resolution { unit: "um".into(), // TODO: why does resolution need to be adjusted from what was imported? - value: 1.0 + value: 1.0, }, library_out: Library { images: Vec::new(), @@ -98,8 +101,8 @@ impl DsnDesign { network_out: NetworkOut { net: net_outs.into_values().collect(), }, - } - } + }, + }, }; println!("{:?}", list_writer.write_value(&ses)); diff --git a/src/dsn/mod.rs b/src/dsn/mod.rs index 0093e31..a58be18 100644 --- a/src/dsn/mod.rs +++ b/src/dsn/mod.rs @@ -1,8 +1,8 @@ +mod common; mod de; pub mod design; pub mod mesadata; -mod structure; -mod common; -mod structure2; mod read; +mod structure; +mod structure2; mod write; diff --git a/src/dsn/read.rs b/src/dsn/read.rs index efdd463..f259de7 100644 --- a/src/dsn/read.rs +++ b/src/dsn/read.rs @@ -1,7 +1,7 @@ -use thiserror::Error; -use utf8_chars::BufReadCharsExt; use super::common::ListToken; use super::structure2::Parser; +use thiserror::Error; +use utf8_chars::BufReadCharsExt; #[derive(Error, Debug)] pub enum ParseError { @@ -34,7 +34,6 @@ impl ReadDsn for Parser { } } - impl ReadDsn for String { fn read_dsn(tokenizer: &mut ListTokenizer) -> Result { Ok(tokenizer.consume_token()?.expect_leaf()?) @@ -236,12 +235,16 @@ impl ListTokenizer { Ok(if chr == '(' { self.next_char().unwrap(); self.skip_whitespace()?; - ListToken::Start { name: self.read_string()? } + ListToken::Start { + name: self.read_string()?, + } } else if chr == ')' { self.next_char().unwrap(); ListToken::End } else { - ListToken::Leaf { value: self.read_string()? } + ListToken::Leaf { + value: self.read_string()?, + } }) } @@ -256,9 +259,15 @@ impl ListTokenizer { Ok(value) } - pub fn read_optional>(&mut self, name: &'static str) -> Result, ParseError> { + pub fn read_optional>( + &mut self, + name: &'static str, + ) -> Result, ParseError> { let token = self.consume_token()?; - if let ListToken::Start { name: ref actual_name } = token { + if let ListToken::Start { + name: ref actual_name, + } = token + { if actual_name == name { let value = self.read_value::()?; self.consume_token()?.expect_end()?; @@ -282,31 +291,36 @@ impl ListTokenizer { array.push(self.read_value::()?); } else { self.return_token(token); - break + break; } } Ok(array) } - pub fn read_named_array>(&mut self, name: &'static str) -> Result, ParseError> { + pub fn read_named_array>( + &mut self, + name: &'static str, + ) -> Result, ParseError> { let mut array = Vec::::new(); loop { let token = self.consume_token()?; - if let ListToken::Start { name: ref actual_name } = token { + if let ListToken::Start { + name: ref actual_name, + } = token + { if actual_name == name { let value = self.read_value::()?; self.consume_token()?.expect_end()?; array.push(value); } else { self.return_token(token); - break + break; } } else { self.return_token(token); - break + break; } } Ok(array) } } - diff --git a/src/dsn/structure2.rs b/src/dsn/structure2.rs index 52f3569..eccc704 100644 --- a/src/dsn/structure2.rs +++ b/src/dsn/structure2.rs @@ -1,10 +1,10 @@ +use super::common::ListToken; use super::read::ReadDsn; +use super::read::{ListTokenizer, ParseError}; +use super::write::ListWriter; use super::write::WriteDsn; use dsn_derive::ReadDsn; use dsn_derive::WriteDsn; -use super::common::ListToken; -use super::read::{ListTokenizer, ParseError}; -use super::write::ListWriter; #[derive(ReadDsn, WriteDsn, Debug)] pub struct Dummy {} @@ -16,7 +16,8 @@ pub struct SesFile { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Session { - #[anon] pub id: String, + #[anon] + pub id: String, pub routes: Routes, } @@ -35,7 +36,8 @@ pub struct NetworkOut { #[derive(ReadDsn, WriteDsn, Debug)] pub struct NetOut { - #[anon] pub name: String, + #[anon] + pub name: String, #[vec("wire")] pub wire: Vec, #[vec("via")] @@ -49,7 +51,8 @@ pub struct DsnFile { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Pcb { - #[anon] pub name: String, + #[anon] + pub name: String, pub parser: Parser, pub resolution: Resolution, pub unit: String, @@ -70,8 +73,10 @@ pub struct Parser { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Resolution { - #[anon] pub unit: String, - #[anon] pub value: f32, + #[anon] + pub unit: String, + #[anon] + pub value: f32, } #[derive(ReadDsn, WriteDsn, Debug)] @@ -87,7 +92,8 @@ pub struct Structure { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Layer { - #[anon] pub name: String, + #[anon] + pub name: String, pub r#type: String, pub property: Property, } @@ -104,7 +110,8 @@ pub struct Boundary { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Plane { - #[anon] pub net: String, + #[anon] + pub net: String, pub polygon: Polygon, } @@ -122,7 +129,8 @@ pub struct Placement { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Component { - #[anon] pub name: String, + #[anon] + pub name: String, #[vec("place")] pub places: Vec, } @@ -130,11 +138,16 @@ pub struct Component { #[derive(ReadDsn, WriteDsn, Debug)] #[allow(non_snake_case)] pub struct Place { - #[anon] pub name: String, - #[anon] pub x: f32, - #[anon] pub y: f32, - #[anon] pub side: String, - #[anon] pub rotation: f32, + #[anon] + pub name: String, + #[anon] + pub x: f32, + #[anon] + pub y: f32, + #[anon] + pub side: String, + #[anon] + pub rotation: f32, pub PN: Option, } @@ -148,7 +161,8 @@ pub struct Library { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Image { - #[anon] pub name: String, + #[anon] + pub name: String, #[vec("outline")] pub outlines: Vec, #[vec("pin")] @@ -164,11 +178,15 @@ pub struct Outline { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Pin { - #[anon] pub name: String, + #[anon] + pub name: String, pub rotate: Option, - #[anon] pub id: String, - #[anon] pub x: f32, - #[anon] pub y: f32, + #[anon] + pub id: String, + #[anon] + pub x: f32, + #[anon] + pub y: f32, } #[derive(ReadDsn, WriteDsn, Debug)] @@ -178,13 +196,16 @@ pub struct Rotate { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Keepout { - #[anon] pub idk: String, - #[anon] pub shape: Shape, + #[anon] + pub idk: String, + #[anon] + pub shape: Shape, } #[derive(ReadDsn, WriteDsn, Debug)] pub struct Padstack { - #[anon] pub name: String, + #[anon] + pub name: String, #[vec("shape")] pub shapes: Vec, pub attach: bool, @@ -227,9 +248,12 @@ impl WriteDsn for Shape { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Circle { - #[anon] pub layer: String, - #[anon] pub diameter: u32, - #[anon] pub offset: Option, + #[anon] + pub layer: String, + #[anon] + pub diameter: u32, + #[anon] + pub offset: Option, } #[derive(ReadDsn, WriteDsn, Debug)] @@ -243,7 +267,8 @@ pub struct Network { #[derive(ReadDsn, WriteDsn, Debug)] // dsn names this "net", but it's a structure unrelated to "net" in wiring or elsewhere pub struct NetPinAssignments { - #[anon] pub name: String, + #[anon] + pub name: String, pub pins: Pins, } @@ -309,7 +334,7 @@ impl ReadDsn for Vec { array.push(Point { x, y }); } else { tokenizer.return_token(token); - break + break; } } Ok(array) @@ -352,25 +377,36 @@ impl WriteDsn for Option { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Polygon { - #[anon] pub layer: String, - #[anon] pub width: f32, - #[anon] pub coords: Vec, + #[anon] + pub layer: String, + #[anon] + pub width: f32, + #[anon] + pub coords: Vec, } #[derive(ReadDsn, WriteDsn, Debug)] pub struct Path { - #[anon] pub layer: String, - #[anon] pub width: f32, - #[anon] pub coords: Vec, + #[anon] + pub layer: String, + #[anon] + pub width: f32, + #[anon] + pub coords: Vec, } #[derive(ReadDsn, WriteDsn, Debug)] pub struct Rect { - #[anon] pub layer: String, - #[anon] pub x1: f32, - #[anon] pub y1: f32, - #[anon] pub x2: f32, - #[anon] pub y2: f32, + #[anon] + pub layer: String, + #[anon] + pub x1: f32, + #[anon] + pub y1: f32, + #[anon] + pub x2: f32, + #[anon] + pub y2: f32, } #[derive(ReadDsn, WriteDsn, Debug)] @@ -394,6 +430,7 @@ pub struct Rule { #[derive(ReadDsn, WriteDsn, Debug)] pub struct Clearance { - #[anon] pub value: f32, + #[anon] + pub value: f32, pub r#type: Option, } diff --git a/src/dsn/write.rs b/src/dsn/write.rs index 71ae500..f90a963 100644 --- a/src/dsn/write.rs +++ b/src/dsn/write.rs @@ -16,9 +16,9 @@ impl WriteDsn for String { let string = if self.len() == 0 { "\"\"".to_string() } else if self.contains(" ") - || self.contains("(") - || self.contains(")") - || self.contains("\n") + || self.contains("(") + || self.contains(")") + || self.contains("\n") { format!("\"{}\"", self) } else { @@ -83,7 +83,8 @@ impl ListWriter { match token { ListToken::Start { name } => { - write!(self.writable, + write!( + self.writable, "\n{}({}", " ".repeat(self.indent_level), name @@ -101,10 +102,7 @@ impl ListWriter { if self.indent_level <= self.multiline_level { self.indent_level -= 1; self.line_len = 2 * self.indent_level + len; - write!(self.writable, - "\n{})", - " ".repeat(self.indent_level) - ) + write!(self.writable, "\n{})", " ".repeat(self.indent_level)) } else { self.indent_level -= 1; self.line_len += len; @@ -118,10 +116,7 @@ impl ListWriter { self.write_token(ListToken::Leaf { value }) } - pub fn write_value>( - &mut self, - value: &T, - ) -> Result<(), io::Error> { + pub fn write_value>(&mut self, value: &T) -> Result<(), io::Error> { value.write_dsn(self) } @@ -129,10 +124,10 @@ impl ListWriter { &mut self, name: &'static str, value: &T, - ) - -> Result<(), io::Error> - { - self.write_token(ListToken::Start { name: name.to_string() } )?; + ) -> Result<(), io::Error> { + self.write_token(ListToken::Start { + name: name.to_string(), + })?; self.write_value(value)?; self.write_token(ListToken::End)?; @@ -143,9 +138,7 @@ impl ListWriter { &mut self, name: &'static str, optional: &Option, - ) - -> Result<(), io::Error> - { + ) -> Result<(), io::Error> { if let Some(value) = optional { self.write_named(name, value)?; } @@ -153,12 +146,7 @@ impl ListWriter { Ok(()) } - pub fn write_array>( - &mut self, - array: &Vec, - ) - -> Result<(), io::Error> - { + pub fn write_array>(&mut self, array: &Vec) -> Result<(), io::Error> { for elem in array { self.write_value(elem)?; } @@ -170,9 +158,7 @@ impl ListWriter { &mut self, name: &'static str, array: &Vec, - ) - -> Result<(), io::Error> - { + ) -> Result<(), io::Error> { for elem in array { self.write_named(name, elem)?; } diff --git a/src/geometry/geometry.rs b/src/geometry/geometry.rs index af2c21d..90946d0 100644 --- a/src/geometry/geometry.rs +++ b/src/geometry/geometry.rs @@ -5,17 +5,17 @@ use geo::Point; use petgraph::{ stable_graph::{NodeIndex, StableDiGraph}, visit::EdgeRef, - Direction::{Incoming, Outgoing}, + Direction::Incoming, }; use crate::{ drawing::{ - bend::{BendWeight, FixedBendWeight, LooseBendWeight}, - dot::{DotWeight, FixedDotWeight, LooseDotWeight}, + bend::BendWeight, + dot::DotWeight, graph::{PrimitiveWeight, Retag}, primitive::Primitive, rules::RulesTrait, - seg::{FixedSegWeight, LoneLooseSegWeight, SegWeight, SeqLooseSegWeight}, + seg::SegWeight, }, geometry::{ compound::CompoundManagerTrait, diff --git a/src/geometry/poly.rs b/src/geometry/poly.rs index 85ebbe5..e71c0fc 100644 --- a/src/geometry/poly.rs +++ b/src/geometry/poly.rs @@ -1,4 +1,3 @@ -use enum_dispatch::enum_dispatch; use geo::{Centroid, Contains, Point, Polygon}; use crate::geometry::shape::ShapeTrait; diff --git a/src/layout/layout.rs b/src/layout/layout.rs index 277604b..79ada58 100644 --- a/src/layout/layout.rs +++ b/src/layout/layout.rs @@ -1,8 +1,5 @@ -use std::collections::HashMap; - use enum_dispatch::enum_dispatch; use geo::Point; -use petgraph::stable_graph::StableDiGraph; use rstar::AABB; use crate::{ @@ -10,7 +7,7 @@ use crate::{ band::BandIndex, bend::LooseBendWeight, dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight}, - graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight, Retag}, + graph::{GetMaybeNet, PrimitiveIndex}, primitive::{GetJoints, GetOtherJoint}, rules::RulesTrait, seg::{ @@ -21,17 +18,12 @@ use crate::{ wraparoundable::WraparoundableIndex, Drawing, Infringement, LayoutException, }, - geometry::{ - compound::CompoundManagerTrait, poly::PolyShape, primitive::PrimitiveShapeTrait, - shape::ShapeTrait, BendWeightTrait, DotWeightTrait, GenericNode, Geometry, GeometryLabel, - GetWidth, SegWeightTrait, - }, + geometry::{compound::CompoundManagerTrait, primitive::PrimitiveShapeTrait, GenericNode}, graph::{GenericIndex, GetNodeIndex}, layout::{ via::{Via, ViaWeight}, - zone::{GetMaybeApex, MakePolyShape, Zone, ZoneWeight}, + zone::{Zone, ZoneWeight}, }, - math::Circle, }; #[derive(Debug, Clone, Copy)] @@ -207,9 +199,9 @@ impl Layout { pub fn band_length(&self, band: BandIndex) -> f64 { match band { BandIndex::Straight(seg) => self.drawing.geometry().seg_shape(seg.into()).length(), - BandIndex::Bended(mut start_seg) => { + BandIndex::Bended(start_seg) => { let mut length = self.drawing.geometry().seg_shape(start_seg.into()).length(); - let mut start_dot = self.drawing.primitive(start_seg).joints().1; + let start_dot = self.drawing.primitive(start_seg).joints().1; let bend = self.drawing.primitive(start_dot).bend(); length += self.drawing.geometry().bend_shape(bend.into()).length(); diff --git a/src/layout/zone.rs b/src/layout/zone.rs index 75d87e0..32f80d9 100644 --- a/src/layout/zone.rs +++ b/src/layout/zone.rs @@ -1,16 +1,14 @@ use enum_dispatch::enum_dispatch; use geo::{LineString, Point, Polygon}; -use petgraph::stable_graph::NodeIndex; use crate::{ drawing::{ - dot::{DotIndex, FixedDotIndex}, - graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex, PrimitiveWeight, Retag}, - primitive::{GenericPrimitive, GetLimbs, Primitive}, + dot::FixedDotIndex, + graph::{GetLayer, GetMaybeNet, MakePrimitive, PrimitiveIndex}, + primitive::GetLimbs, rules::RulesTrait, seg::SegIndex, - Drawing, }, geometry::{compound::CompoundManagerTrait, poly::PolyShape, GetPos}, graph::{GenericIndex, GetNodeIndex}, diff --git a/src/router/router.rs b/src/router/router.rs index d6d7d78..cf0aa58 100644 --- a/src/router/router.rs +++ b/src/router/router.rs @@ -1,9 +1,5 @@ -use std::sync::{Arc, Mutex}; - -use geo::geometry::Point; use geo::EuclideanDistance; use petgraph::visit::EdgeRef; -use spade::InsertionError; use thiserror::Error; use crate::{ @@ -11,7 +7,6 @@ use crate::{ band::BandIndex, dot::FixedDotIndex, graph::{MakePrimitive, PrimitiveIndex}, - guide::HeadTrait, primitive::MakePrimitiveShape, rules::RulesTrait, }, diff --git a/src/router/tracer.rs b/src/router/tracer.rs index 6016231..2e4e4c3 100644 --- a/src/router/tracer.rs +++ b/src/router/tracer.rs @@ -1,5 +1,3 @@ -use std::sync::{Arc, Mutex}; - use contracts::debug_ensures; use crate::{ @@ -13,7 +11,7 @@ use crate::{ layout::Layout, router::{ draw::{Draw, DrawException}, - navmesh::{Navmesh, NavvertexIndex}, + navmesh::NavvertexIndex, }, }; diff --git a/tests/single_layer.rs b/tests/single_layer.rs index 126b4a6..4a9a0ac 100644 --- a/tests/single_layer.rs +++ b/tests/single_layer.rs @@ -1,24 +1,11 @@ -use std::fs::File; - -use petgraph::{ - unionfind::UnionFind, - visit::{EdgeRef, IntoEdgeReferences, NodeIndexable}, -}; use topola::{ autorouter::{ invoker::{Command, Invoker, InvokerError}, - Autorouter, AutorouterError, + AutorouterError, }, - drawing::{ - graph::{GetLayer, GetMaybeNet}, - primitive::GetInnerOuter, - }, - dsn::design::DsnDesign, - graph::GetNodeIndex, - layout::{via::ViaWeight, NodeIndex}, + layout::via::ViaWeight, math::Circle, router::EmptyRouterObserver, - triangulation::GetTrianvertexIndex, }; mod common;