mirror of https://codeberg.org/topola/topola.git
router,layout,draw: remove hardcoded widths
This commit is contained in:
parent
fd73531687
commit
850941715e
|
|
@ -6,12 +6,14 @@ use crate::{
|
||||||
layout::{
|
layout::{
|
||||||
bend::{BendIndex, LooseBendWeight},
|
bend::{BendIndex, LooseBendWeight},
|
||||||
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
dot::{DotIndex, FixedDotIndex, LooseDotIndex, LooseDotWeight},
|
||||||
|
geometry::GetWidth,
|
||||||
graph::{GetBandIndex, MakePrimitive},
|
graph::{GetBandIndex, MakePrimitive},
|
||||||
guide::{Guide, Head, HeadTrait, SegbendHead},
|
guide::{Guide, Head, HeadTrait, SegbendHead},
|
||||||
primitive::GetOtherJoint,
|
primitive::GetOtherJoint,
|
||||||
|
rules::RulesTrait,
|
||||||
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
seg::{LoneLooseSegWeight, SeqLooseSegWeight},
|
||||||
|
Infringement, Layout, LayoutException,
|
||||||
},
|
},
|
||||||
layout::{rules::RulesTrait, Infringement, Layout, LayoutException},
|
|
||||||
math::{Circle, NoTangents},
|
math::{Circle, NoTangents},
|
||||||
wraparoundable::WraparoundableIndex,
|
wraparoundable::WraparoundableIndex,
|
||||||
};
|
};
|
||||||
|
|
@ -65,7 +67,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
into.into(),
|
into.into(),
|
||||||
LoneLooseSegWeight {
|
LoneLooseSegWeight {
|
||||||
band: head.band(),
|
band: head.band(),
|
||||||
width: 3.0,
|
width: self.layout.band(head.band()).width(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
|
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
|
||||||
|
|
@ -77,7 +79,7 @@ impl<'a, R: RulesTrait> Draw<'a, R> {
|
||||||
dot,
|
dot,
|
||||||
SeqLooseSegWeight {
|
SeqLooseSegWeight {
|
||||||
band: head.band(),
|
band: head.band(),
|
||||||
width: 3.0,
|
width: self.layout.band(head.band()).width(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
|
.map_err(|err| DrawException::CannotFinishIn(into, err.into()))?;
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ use crate::{
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::rules::RulesTrait;
|
use super::{geometry::GetWidth, rules::RulesTrait};
|
||||||
|
|
||||||
pub struct Band<'a, R: RulesTrait> {
|
pub struct Band<'a, R: RulesTrait> {
|
||||||
pub index: BandIndex,
|
pub index: BandIndex,
|
||||||
|
|
@ -92,3 +92,9 @@ impl<'a, R: RulesTrait> GetNet for Band<'a, R> {
|
||||||
self.weight().net
|
self.weight().net
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a, R: RulesTrait> GetWidth for Band<'a, R> {
|
||||||
|
fn width(&self) -> f64 {
|
||||||
|
self.weight().width
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use crate::graph::{GenericIndex, GetNodeIndex};
|
||||||
use crate::layout::bend::BendIndex;
|
use crate::layout::bend::BendIndex;
|
||||||
use crate::layout::dot::DotWeight;
|
use crate::layout::dot::DotWeight;
|
||||||
use crate::layout::geometry::{
|
use crate::layout::geometry::{
|
||||||
BendWeightTrait, DotWeightTrait, Geometry, GeometryLabel, GetPos, SegWeightTrait,
|
BendWeightTrait, DotWeightTrait, Geometry, GeometryLabel, GetPos, GetWidth, SegWeightTrait,
|
||||||
};
|
};
|
||||||
use crate::layout::guide::Guide;
|
use crate::layout::guide::Guide;
|
||||||
use crate::layout::rules::{Conditions, GetConditions};
|
use crate::layout::rules::{Conditions, GetConditions};
|
||||||
|
|
@ -413,39 +413,67 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
|
|
||||||
while let Some(rail) = maybe_rail {
|
while let Some(rail) = maybe_rail {
|
||||||
let rail_primitive = self.primitive(rail);
|
let rail_primitive = self.primitive(rail);
|
||||||
let ends = rail_primitive.joints();
|
let joints = rail_primitive.joints();
|
||||||
|
|
||||||
let guide = Guide::new(self);
|
let guide = Guide::new(self);
|
||||||
let from_head = guide.rear_head(ends.1);
|
let from_head = guide.rear_head(joints.1);
|
||||||
let to_head = guide.rear_head(ends.0);
|
let to_head = guide.rear_head(joints.0);
|
||||||
|
|
||||||
if let Some(inner) = rail_primitive.inner() {
|
if let Some(inner) = rail_primitive.inner() {
|
||||||
let from = guide
|
let from = guide
|
||||||
.head_around_bend_segment(&from_head.into(), inner.into(), true, 6.0)?
|
.head_around_bend_segment(
|
||||||
|
&from_head.into(),
|
||||||
|
inner.into(),
|
||||||
|
true,
|
||||||
|
self.primitive(rail).width(),
|
||||||
|
)?
|
||||||
.end_point();
|
.end_point();
|
||||||
let to = guide
|
let to = guide
|
||||||
.head_around_bend_segment(&to_head.into(), inner.into(), false, 6.0)?
|
.head_around_bend_segment(
|
||||||
|
&to_head.into(),
|
||||||
|
inner.into(),
|
||||||
|
false,
|
||||||
|
self.primitive(rail).width(),
|
||||||
|
)?
|
||||||
.end_point();
|
.end_point();
|
||||||
self.move_dot_infringably(
|
self.move_dot_infringably(
|
||||||
ends.0.into(),
|
joints.0.into(),
|
||||||
from,
|
from,
|
||||||
&self.inner_bow_and_outer_bows(rail),
|
&self.inner_bow_and_outer_bows(rail),
|
||||||
)?;
|
)?;
|
||||||
self.move_dot_infringably(ends.1.into(), to, &self.inner_bow_and_outer_bows(rail))?;
|
self.move_dot_infringably(
|
||||||
|
joints.1.into(),
|
||||||
|
to,
|
||||||
|
&self.inner_bow_and_outer_bows(rail),
|
||||||
|
)?;
|
||||||
} else {
|
} else {
|
||||||
let core = rail_primitive.core();
|
let core = rail_primitive.core();
|
||||||
let from = guide
|
let from = guide
|
||||||
.head_around_dot_segment(&from_head.into(), core.into(), true, 6.0)?
|
.head_around_dot_segment(
|
||||||
|
&from_head.into(),
|
||||||
|
core.into(),
|
||||||
|
true,
|
||||||
|
self.primitive(rail).width(),
|
||||||
|
)?
|
||||||
.end_point();
|
.end_point();
|
||||||
let to = guide
|
let to = guide
|
||||||
.head_around_dot_segment(&to_head.into(), core.into(), false, 6.0)?
|
.head_around_dot_segment(
|
||||||
|
&to_head.into(),
|
||||||
|
core.into(),
|
||||||
|
false,
|
||||||
|
self.primitive(rail).width(),
|
||||||
|
)?
|
||||||
.end_point();
|
.end_point();
|
||||||
self.move_dot_infringably(
|
self.move_dot_infringably(
|
||||||
ends.0.into(),
|
joints.0.into(),
|
||||||
from,
|
from,
|
||||||
&self.inner_bow_and_outer_bows(rail),
|
&self.inner_bow_and_outer_bows(rail),
|
||||||
)?;
|
)?;
|
||||||
self.move_dot_infringably(ends.1.into(), to, &self.inner_bow_and_outer_bows(rail))?;
|
self.move_dot_infringably(
|
||||||
|
joints.1.into(),
|
||||||
|
to,
|
||||||
|
&self.inner_bow_and_outer_bows(rail),
|
||||||
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
maybe_rail = self.primitive(rail).outer();
|
maybe_rail = self.primitive(rail).outer();
|
||||||
|
|
|
||||||
|
|
@ -523,8 +523,8 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
dot_start,
|
dot_start,
|
||||||
dot_end,
|
dot_end,
|
||||||
3.0,
|
3.0,
|
||||||
//&mut EmptyRouterObserver,
|
&mut EmptyRouterObserver,
|
||||||
&mut DebugRouterObserver::new(&mut event_pump, &window, &mut renderer, &font_context),
|
//&mut DebugRouterObserver::new(&mut event_pump, &window, &mut renderer, &font_context),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
render_times(
|
render_times(
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ use thiserror::Error;
|
||||||
|
|
||||||
use crate::astar::{astar, AstarStrategy, PathTracker};
|
use crate::astar::{astar, AstarStrategy, PathTracker};
|
||||||
use crate::draw::DrawException;
|
use crate::draw::DrawException;
|
||||||
|
use crate::layout::geometry::GetWidth;
|
||||||
use crate::layout::guide::HeadTrait;
|
use crate::layout::guide::HeadTrait;
|
||||||
use crate::layout::rules::RulesTrait;
|
use crate::layout::rules::RulesTrait;
|
||||||
use crate::layout::Layout;
|
use crate::layout::Layout;
|
||||||
|
|
@ -84,13 +85,24 @@ impl<'a, RO: RouterObserverTrait<R>, R: RulesTrait> AstarStrategy<&Mesh, f64>
|
||||||
{
|
{
|
||||||
fn is_goal(&mut self, vertex: VertexIndex, tracker: &PathTracker<&Mesh>) -> bool {
|
fn is_goal(&mut self, vertex: VertexIndex, tracker: &PathTracker<&Mesh>) -> bool {
|
||||||
let new_path = tracker.reconstruct_path_to(vertex);
|
let new_path = tracker.reconstruct_path_to(vertex);
|
||||||
|
let band = self.trace.head.band();
|
||||||
|
|
||||||
self.tracer
|
self.tracer
|
||||||
.rework_path(&mut self.trace, &new_path, 5.0)
|
.rework_path(
|
||||||
|
&mut self.trace,
|
||||||
|
&new_path,
|
||||||
|
self.tracer.layout.band(band).width(),
|
||||||
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
self.observer.on_rework(&self.tracer, &self.trace);
|
self.observer.on_rework(&self.tracer, &self.trace);
|
||||||
|
|
||||||
self.tracer.finish(&mut self.trace, self.to, 5.0).is_ok()
|
self.tracer
|
||||||
|
.finish(
|
||||||
|
&mut self.trace,
|
||||||
|
self.to,
|
||||||
|
self.tracer.layout.band(band).width(),
|
||||||
|
)
|
||||||
|
.is_ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn edge_cost(&mut self, edge: MeshEdgeReference) -> Option<f64> {
|
fn edge_cost(&mut self, edge: MeshEdgeReference) -> Option<f64> {
|
||||||
|
|
@ -99,9 +111,14 @@ impl<'a, RO: RouterObserverTrait<R>, R: RulesTrait> AstarStrategy<&Mesh, f64>
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
let before_probe_length = self.tracer.layout.band(self.trace.head.band()).length();
|
let band = self.trace.head.band();
|
||||||
|
let before_probe_length = self.tracer.layout.band(band).length();
|
||||||
|
|
||||||
let result = self.tracer.step(&mut self.trace, edge.target(), 5.0);
|
let result = self.tracer.step(
|
||||||
|
&mut self.trace,
|
||||||
|
edge.target(),
|
||||||
|
self.tracer.layout.band(band).width(),
|
||||||
|
);
|
||||||
self.observer
|
self.observer
|
||||||
.on_probe(&self.tracer, &self.trace, edge, result);
|
.on_probe(&self.tracer, &self.trace, edge, result);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue