autorouter: implement measurement of band length

This commit is contained in:
Mikolaj Wielgus 2024-06-05 23:10:11 +02:00
parent 86d2555b36
commit a02bf1541e
5 changed files with 54 additions and 11 deletions

View File

@ -13,14 +13,12 @@ use crate::{
graph::GenericIndex, graph::GenericIndex,
layout::{ layout::{
zone::{GetMaybeApex, MakePolyShape, ZoneWeight}, zone::{GetMaybeApex, MakePolyShape, ZoneWeight},
Layout, Layout, NodeIndex,
}, },
math::Circle, math::Circle,
router::{navmesh::Navmesh, Router, RouterError, RouterObserverTrait}, router::{navmesh::Navmesh, Router, RouterError, RouterObserverTrait},
}; };
pub type NodeIndex = GenericNode<PrimitiveIndex, GenericIndex<ZoneWeight>>;
#[derive(Debug)] #[derive(Debug)]
pub struct Board<R: RulesTrait> { pub struct Board<R: RulesTrait> {
layout: Layout<R>, layout: Layout<R>,

View File

@ -3,12 +3,13 @@ use std::collections::HashSet;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use crate::{ use crate::{
autorouter::board::{Board, NodeIndex}, autorouter::board::Board,
drawing::{ drawing::{
graph::{GetLayer, MakePrimitive, PrimitiveIndex}, graph::{GetLayer, MakePrimitive, PrimitiveIndex},
rules::RulesTrait, rules::RulesTrait,
}, },
graph::GenericIndex, graph::GenericIndex,
layout::NodeIndex,
}; };
#[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)] #[derive(Debug, Clone, Hash, Eq, PartialEq, Serialize, Deserialize)]

View File

@ -10,6 +10,7 @@ use crate::{
bend::LooseBendWeight, bend::LooseBendWeight,
dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight}, dot::{DotIndex, FixedDotIndex, FixedDotWeight, LooseDotIndex, LooseDotWeight},
graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight, Retag}, graph::{GetLayer, GetMaybeNet, PrimitiveIndex, PrimitiveWeight, Retag},
primitive::{GetJoints, GetOtherJoint},
rules::RulesTrait, rules::RulesTrait,
seg::{ seg::{
FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex, FixedSegIndex, FixedSegWeight, LoneLooseSegIndex, LoneLooseSegWeight, SeqLooseSegIndex,
@ -20,8 +21,9 @@ use crate::{
Drawing, Infringement, LayoutException, Drawing, Infringement, LayoutException,
}, },
geometry::{ geometry::{
compound::CompoundManagerTrait, poly::PolyShape, shape::ShapeTrait, BendWeightTrait, compound::CompoundManagerTrait, poly::PolyShape, primitive::PrimitiveShapeTrait,
DotWeightTrait, GenericNode, Geometry, GeometryLabel, GetWidth, SegWeightTrait, shape::ShapeTrait, BendWeightTrait, DotWeightTrait, GenericNode, Geometry, GeometryLabel,
GetWidth, SegWeightTrait,
}, },
graph::{GenericIndex, GetNodeIndex}, graph::{GenericIndex, GetNodeIndex},
layout::zone::{GetMaybeApex, MakePolyShape, PourZoneIndex, SolidZoneIndex, Zone, ZoneWeight}, layout::zone::{GetMaybeApex, MakePolyShape, PourZoneIndex, SolidZoneIndex, Zone, ZoneWeight},
@ -137,9 +139,34 @@ impl<R: RulesTrait> Layout<R> {
self.drawing.compounds(node) self.drawing.compounds(node)
} }
pub fn band_length(&self, face: DotIndex) -> f64 { pub fn band_length(&self, band: BandIndex) -> f64 {
// TODO. match band {
0.0 BandIndex::Straight(seg) => self.drawing.geometry().seg_shape(seg.into()).length(),
BandIndex::Bended(mut 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 bend = self.drawing.primitive(start_dot).bend();
length += self.drawing.geometry().bend_shape(bend.into()).length();
let mut prev_dot = self.drawing.primitive(bend).other_joint(start_dot.into());
let mut seg = self.drawing.primitive(prev_dot).seg().unwrap();
length += self.drawing.geometry().seg_shape(seg.into()).length();
while let DotIndex::Loose(dot) =
self.drawing.primitive(seg).other_joint(prev_dot.into())
{
let bend = self.drawing.primitive(dot).bend();
length += self.drawing.geometry().bend_shape(bend.into()).length();
prev_dot = self.drawing.primitive(bend).other_joint(dot);
seg = self.drawing.primitive(prev_dot).seg().unwrap();
length += self.drawing.geometry().seg_shape(seg.into()).length();
}
length
}
}
} }
pub fn zone_nodes(&self) -> impl Iterator<Item = GenericIndex<ZoneWeight>> + '_ { pub fn zone_nodes(&self) -> impl Iterator<Item = GenericIndex<ZoneWeight>> + '_ {

View File

@ -114,14 +114,14 @@ impl<'a, RO: RouterObserverTrait<R>, R: RulesTrait> AstarStrategy<&Navmesh, f64,
return None; return None;
} }
let before_probe_length = self.tracer.layout.band_length(self.trace.head.face()); let before_probe_length = 0.0; //self.tracer.layout.band_length(self.trace.head.face());
let width = self.trace.width; let width = self.trace.width;
let result = self.tracer.step(&mut self.trace, edge.target(), width); let result = self.tracer.step(&mut self.trace, edge.target(), width);
self.observer self.observer
.on_probe(&self.tracer, &self.trace, edge, result); .on_probe(&self.tracer, &self.trace, edge, result);
let probe_length = self.tracer.layout.band_length(self.trace.head.face()); let probe_length = 0.0; //self.tracer.layout.band_length(self.trace.head.face());
if result.is_ok() { if result.is_ok() {
self.tracer.undo_step(&mut self.trace); self.tracer.undo_step(&mut self.trace);

View File

@ -12,6 +12,7 @@ use topola::{
}, },
dsn::design::DsnDesign, dsn::design::DsnDesign,
graph::GetNodeIndex, graph::GetNodeIndex,
layout::NodeIndex,
triangulation::GetTrianvertexIndex, triangulation::GetTrianvertexIndex,
}; };
@ -111,5 +112,21 @@ fn test() {
unionfind.find(target_dot.node_index()) unionfind.find(target_dot.node_index())
); );
} }
let source_pinname = autorouter
.board()
.node_pinname(NodeIndex::Primitive(source_dot.into()))
.unwrap();
let target_pinname = autorouter
.board()
.node_pinname(NodeIndex::Primitive(target_dot.into()))
.unwrap();
dbg!(source_pinname, target_pinname);
let band = autorouter
.board()
.band_between_pins(source_pinname, target_pinname)
.unwrap();
dbg!(autorouter.board().layout().band_length(band));
} }
} }