mirror of https://codeberg.org/topola/topola.git
Unroute path whose routing failed in the middle
This commit is contained in:
parent
53c24b1a14
commit
5f37ff7616
18
src/draw.rs
18
src/draw.rs
|
|
@ -1,4 +1,4 @@
|
||||||
use geo::Point;
|
use geo::{EuclideanLength, Point};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
graph::{BendIndex, BendWeight, DotIndex, DotWeight, Ends, SegIndex, SegWeight, TaggedIndex},
|
graph::{BendIndex, BendWeight, DotIndex, DotWeight, Ends, SegIndex, SegWeight, TaggedIndex},
|
||||||
|
|
@ -88,7 +88,21 @@ impl<'a> Draw<'a> {
|
||||||
) -> Result<Head, ()> {
|
) -> Result<Head, ()> {
|
||||||
let tangent = self
|
let tangent = self
|
||||||
.guide(&Default::default())
|
.guide(&Default::default())
|
||||||
.head_around_dot_segment(&head, around, cw, width);
|
.head_around_dot_segments(&head, around, width)
|
||||||
|
.1;
|
||||||
|
/*.into_iter()
|
||||||
|
.max_by(|x, y| x.euclidean_length().total_cmp(&y.euclidean_length()))
|
||||||
|
.unwrap();*/
|
||||||
|
|
||||||
|
/*let tangents = self
|
||||||
|
.guide(&Default::default())
|
||||||
|
.head_around_dot_segments(&head, around, width);
|
||||||
|
|
||||||
|
let tangent = if tangents.0.euclidean_length() <= tangents.1.euclidean_length() {
|
||||||
|
tangents.0
|
||||||
|
} else {
|
||||||
|
tangents.1
|
||||||
|
};*/
|
||||||
|
|
||||||
head = self.extend_head(head, tangent.start_point())?;
|
head = self.extend_head(head, tangent.start_point())?;
|
||||||
self.segbend(
|
self.segbend(
|
||||||
|
|
|
||||||
15
src/guide.rs
15
src/guide.rs
|
|
@ -48,6 +48,21 @@ impl<'a, 'b> Guide<'a, 'b> {
|
||||||
math::tangent_segment(from_circle, from_cw, to_circle, Some(cw))
|
math::tangent_segment(from_circle, from_cw, to_circle, Some(cw))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn head_around_dot_segments(
|
||||||
|
&self,
|
||||||
|
head: &Head,
|
||||||
|
around: DotIndex,
|
||||||
|
width: f64,
|
||||||
|
) -> (Line, Line) {
|
||||||
|
let from_circle = self.head_circle(&head, width);
|
||||||
|
let to_circle = self.dot_circle(around, width);
|
||||||
|
|
||||||
|
let from_cw = self.head_cw(&head);
|
||||||
|
let tangents: Vec<Line> =
|
||||||
|
math::tangent_segments(from_circle, from_cw, to_circle, None).collect();
|
||||||
|
(tangents[0], tangents[1])
|
||||||
|
}
|
||||||
|
|
||||||
pub fn head_around_dot_segment(
|
pub fn head_around_dot_segment(
|
||||||
&self,
|
&self,
|
||||||
head: &Head,
|
head: &Head,
|
||||||
|
|
|
||||||
|
|
@ -239,7 +239,7 @@ fn main() {
|
||||||
.add_dot(DotWeight {
|
.add_dot(DotWeight {
|
||||||
net: 20,
|
net: 20,
|
||||||
circle: Circle {
|
circle: Circle {
|
||||||
pos: (480.5, 700.5).into(),
|
pos: (480.5, 550.5).into(),
|
||||||
r: 8.0,
|
r: 8.0,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -60,8 +60,11 @@ impl<'a> Route<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn path(&mut self, trace: &mut Trace, path: &[VertexIndex], width: f64) -> Result<(), ()> {
|
pub fn path(&mut self, trace: &mut Trace, path: &[VertexIndex], width: f64) -> Result<(), ()> {
|
||||||
for vertex in path {
|
for (i, vertex) in path.iter().enumerate() {
|
||||||
self.step(trace, *vertex, width)?;
|
if let Err(err) = self.step(trace, *vertex, width) {
|
||||||
|
self.undo_path(trace, i)?;
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,17 +71,6 @@ impl<'a, RS: RouteStrategy> AstarStrategy<&Mesh, u64> for RouterAstarStrategy<'a
|
||||||
fn reroute(&mut self, vertex: VertexIndex, tracker: &PathTracker<&Mesh>) -> Option<u64> {
|
fn reroute(&mut self, vertex: VertexIndex, tracker: &PathTracker<&Mesh>) -> Option<u64> {
|
||||||
let new_path = tracker.reconstruct_path_to(vertex);
|
let new_path = tracker.reconstruct_path_to(vertex);
|
||||||
|
|
||||||
/*if vertex == self.to {
|
|
||||||
self.route
|
|
||||||
.rework_path(&mut self.trace, &new_path[..new_path.len() - 1], 5.0)
|
|
||||||
.ok();
|
|
||||||
self.route
|
|
||||||
.finish(&mut self.trace, new_path[new_path.len() - 1], 5.0)
|
|
||||||
.ok();
|
|
||||||
None
|
|
||||||
} else {*/
|
|
||||||
//}
|
|
||||||
|
|
||||||
self.route.rework_path(&mut self.trace, &new_path, 5.0).ok();
|
self.route.rework_path(&mut self.trace, &new_path, 5.0).ok();
|
||||||
|
|
||||||
if self.route.finish(&mut self.trace, self.to, 5.0).is_ok() {
|
if self.route.finish(&mut self.trace, self.to, 5.0).is_ok() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue