Triangulate only after drawing finishes

Otherwise we'll end up with the (not yet implemented) pathfinding
algorithm trying to route traces with themselves.
This commit is contained in:
Mikolaj Wielgus 2023-08-26 22:23:40 +02:00
parent a1afd19fcb
commit 9196d95546
1 changed files with 5 additions and 6 deletions

View File

@ -42,10 +42,13 @@ impl Router {
pub fn draw_finish(&mut self, head: Head, into: DotIndex, width: f64) -> Result<(), ()> { pub fn draw_finish(&mut self, head: Head, into: DotIndex, width: f64) -> Result<(), ()> {
if let Some(bend) = self.layout.primitive(into).bend() { if let Some(bend) = self.layout.primitive(into).bend() {
self.draw_finish_in_bend(head, bend, into, width) self.draw_finish_in_bend(head, bend, into, width)?;
} else { } else {
self.draw_finish_in_dot(head, into, width) self.draw_finish_in_dot(head, into, width)?;
} }
self.mesh.triangulate(&self.layout);
Ok(())
} }
fn draw_finish_in_dot(&mut self, head: Head, into: DotIndex, width: f64) -> Result<(), ()> { fn draw_finish_in_dot(&mut self, head: Head, into: DotIndex, width: f64) -> Result<(), ()> {
@ -57,7 +60,6 @@ impl Router {
let net = self.layout.primitive(head.dot).weight().net; let net = self.layout.primitive(head.dot).weight().net;
self.layout self.layout
.add_seg(head.dot, into, SegWeight { net, width })?; .add_seg(head.dot, into, SegWeight { net, width })?;
self.mesh.triangulate(&self.layout);
Ok(()) Ok(())
} }
@ -83,7 +85,6 @@ impl Router {
let net = self.layout.primitive(head.dot).weight().net; let net = self.layout.primitive(head.dot).weight().net;
self.layout self.layout
.add_seg(head.dot, into, SegWeight { net, width })?; .add_seg(head.dot, into, SegWeight { net, width })?;
self.mesh.triangulate(&self.layout);
Ok(()) Ok(())
} }
@ -176,7 +177,6 @@ impl Router {
let bend = self let bend = self
.layout .layout
.add_bend(head.dot, bend_to, around, BendWeight { net, cw })?; .add_bend(head.dot, bend_to, around, BendWeight { net, cw })?;
self.mesh.triangulate(&self.layout);
Ok(Head { Ok(Head {
dot: bend_to, dot: bend_to,
bend: Some(bend), bend: Some(bend),
@ -239,7 +239,6 @@ impl Router {
})?; })?;
self.layout self.layout
.add_seg(head.dot, to_index, SegWeight { net, width })?; .add_seg(head.dot, to_index, SegWeight { net, width })?;
self.mesh.triangulate(&self.layout);
Ok(Head { Ok(Head {
dot: to_index, dot: to_index,
bend: None, bend: None,