mirror of https://codeberg.org/topola/topola.git
Rename "route" to "draw" and "shove" to "squeeze"
The terms "route" and "shove" will be reserved to functions on the higher level of abstraction.
This commit is contained in:
parent
bbbd2f57fe
commit
234a52f9e8
|
|
@ -29,22 +29,22 @@ impl Layout {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn route_start(&mut self, from: DotIndex) -> Head {
|
pub fn draw_start(&mut self, from: DotIndex) -> Head {
|
||||||
Head {
|
Head {
|
||||||
dot: from,
|
dot: from,
|
||||||
bend: self.mesh.primitive(from).bend(),
|
bend: self.mesh.primitive(from).bend(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn route_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.mesh.primitive(into).bend() {
|
if let Some(bend) = self.mesh.primitive(into).bend() {
|
||||||
self.route_finish_in_bend(head, bend, into, width)
|
self.draw_finish_in_bend(head, bend, into, width)
|
||||||
} else {
|
} else {
|
||||||
self.route_finish_in_dot(head, into, width)
|
self.draw_finish_in_dot(head, into, width)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn route_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<(), ()> {
|
||||||
let tangent = self
|
let tangent = self
|
||||||
.guide(&Default::default())
|
.guide(&Default::default())
|
||||||
.head_into_dot_segment(&head, into, width);
|
.head_into_dot_segment(&head, into, width);
|
||||||
|
|
@ -53,7 +53,7 @@ impl Layout {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn route_finish_in_bend(
|
fn draw_finish_in_bend(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
to_bend: BendIndex,
|
to_bend: BendIndex,
|
||||||
|
|
@ -75,7 +75,7 @@ impl Layout {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shove_around_dot(
|
pub fn squeeze_around_dot(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: DotIndex,
|
around: DotIndex,
|
||||||
|
|
@ -83,14 +83,14 @@ impl Layout {
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<Head, ()> {
|
) -> Result<Head, ()> {
|
||||||
let outer = self.mesh.primitive(around).outer().unwrap();
|
let outer = self.mesh.primitive(around).outer().unwrap();
|
||||||
let head = self.route_around_dot(head, around, cw, width)?;
|
let head = self.draw_around_dot(head, around, cw, width)?;
|
||||||
self.mesh.reattach_bend(outer, head.bend.unwrap());
|
self.mesh.reattach_bend(outer, head.bend.unwrap());
|
||||||
|
|
||||||
self.reroute_outward(outer)?;
|
self.reroute_outward(outer)?;
|
||||||
Ok(head)
|
Ok(head)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn route_around_dot(
|
pub fn draw_around_dot(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: DotIndex,
|
around: DotIndex,
|
||||||
|
|
@ -102,7 +102,7 @@ impl Layout {
|
||||||
.head_around_dot_segment(&head, around, cw, width);
|
.head_around_dot_segment(&head, around, cw, width);
|
||||||
|
|
||||||
let head = self.extend_head(head, tangent.start_point())?;
|
let head = self.extend_head(head, tangent.start_point())?;
|
||||||
self.route_seg_bend(
|
self.draw_seg_bend(
|
||||||
head,
|
head,
|
||||||
TaggedIndex::Dot(around),
|
TaggedIndex::Dot(around),
|
||||||
tangent.end_point(),
|
tangent.end_point(),
|
||||||
|
|
@ -111,7 +111,7 @@ impl Layout {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn shove_around_bend(
|
pub fn squeeze_around_bend(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: BendIndex,
|
around: BendIndex,
|
||||||
|
|
@ -119,14 +119,14 @@ impl Layout {
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<Head, ()> {
|
) -> Result<Head, ()> {
|
||||||
let outer = self.mesh.primitive(around).outer().unwrap();
|
let outer = self.mesh.primitive(around).outer().unwrap();
|
||||||
let head = self.route_around_bend(head, around, cw, width)?;
|
let head = self.draw_around_bend(head, around, cw, width)?;
|
||||||
self.mesh.reattach_bend(outer, head.bend.unwrap());
|
self.mesh.reattach_bend(outer, head.bend.unwrap());
|
||||||
|
|
||||||
self.reroute_outward(outer)?;
|
self.reroute_outward(outer)?;
|
||||||
Ok(head)
|
Ok(head)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn route_around_bend(
|
pub fn draw_around_bend(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: BendIndex,
|
around: BendIndex,
|
||||||
|
|
@ -138,7 +138,7 @@ impl Layout {
|
||||||
.head_around_bend_segment(&head, around, cw, width);
|
.head_around_bend_segment(&head, around, cw, width);
|
||||||
|
|
||||||
let head = self.extend_head(head, tangent.start_point())?;
|
let head = self.extend_head(head, tangent.start_point())?;
|
||||||
self.route_seg_bend(
|
self.draw_seg_bend(
|
||||||
head,
|
head,
|
||||||
TaggedIndex::Bend(around),
|
TaggedIndex::Bend(around),
|
||||||
tangent.end_point(),
|
tangent.end_point(),
|
||||||
|
|
@ -147,7 +147,7 @@ impl Layout {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn route_seg_bend(
|
fn draw_seg_bend(
|
||||||
&mut self,
|
&mut self,
|
||||||
head: Head,
|
head: Head,
|
||||||
around: TaggedIndex,
|
around: TaggedIndex,
|
||||||
|
|
@ -155,7 +155,7 @@ impl Layout {
|
||||||
cw: bool,
|
cw: bool,
|
||||||
width: f64,
|
width: f64,
|
||||||
) -> Result<Head, ()> {
|
) -> Result<Head, ()> {
|
||||||
let head = self.route_seg(head, to, width)?;
|
let head = self.draw_seg(head, to, width)?;
|
||||||
let bend_to = self.add_dot(self.mesh.primitive(head.dot).weight())?;
|
let bend_to = self.add_dot(self.mesh.primitive(head.dot).weight())?;
|
||||||
let net = self.mesh.primitive(head.dot).weight().net;
|
let net = self.mesh.primitive(head.dot).weight().net;
|
||||||
|
|
||||||
|
|
@ -193,24 +193,24 @@ impl Layout {
|
||||||
}
|
}
|
||||||
|
|
||||||
for ends in endss {
|
for ends in endss {
|
||||||
let mut head = self.route_start(ends[0]);
|
let mut head = self.draw_start(ends[0]);
|
||||||
let width = 5.0;
|
let width = 5.0;
|
||||||
|
|
||||||
if let Some(inner) = maybe_inner {
|
if let Some(inner) = maybe_inner {
|
||||||
head = self.route_around_bend(head, inner, cw, width)?;
|
head = self.draw_around_bend(head, inner, cw, width)?;
|
||||||
} else {
|
} else {
|
||||||
head = self.route_around_dot(head, core, cw, width)?;
|
head = self.draw_around_dot(head, core, cw, width)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
maybe_inner = head.bend;
|
maybe_inner = head.bend;
|
||||||
self.route_finish(head, ends[1], width)?;
|
self.draw_finish(head, ends[1], width)?;
|
||||||
self.relax_band(maybe_inner.unwrap());
|
self.relax_band(maybe_inner.unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn route_seg(&mut self, head: Head, to: Point, width: f64) -> Result<Head, ()> {
|
fn draw_seg(&mut self, head: Head, to: Point, width: f64) -> Result<Head, ()> {
|
||||||
let net = self.mesh.primitive(head.dot).weight().net;
|
let net = self.mesh.primitive(head.dot).weight().net;
|
||||||
|
|
||||||
assert!(width <= self.mesh.primitive(head.dot).weight().circle.r * 2.);
|
assert!(width <= self.mesh.primitive(head.dot).weight().circle.r * 2.);
|
||||||
|
|
@ -255,8 +255,8 @@ impl Layout {
|
||||||
|
|
||||||
self.mesh.remove_open_set(bow.interior());
|
self.mesh.remove_open_set(bow.interior());
|
||||||
|
|
||||||
let head = self.route_start(ends[0]);
|
let head = self.draw_start(ends[0]);
|
||||||
let _ = self.route_finish(head, ends[1], 5.);
|
let _ = self.draw_finish(head, ends[1], 5.);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn move_dot(&mut self, dot: DotIndex, to: Point) -> Result<(), ()> {
|
pub fn move_dot(&mut self, dot: DotIndex, to: Point) -> Result<(), ()> {
|
||||||
|
|
|
||||||
68
src/main.rs
68
src/main.rs
|
|
@ -56,7 +56,7 @@ fn main() {
|
||||||
let mut layout = Layout::new();
|
let mut layout = Layout::new();
|
||||||
|
|
||||||
/*let index = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (150.5, 80.5).into(), r: 8.0}});
|
/*let index = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (150.5, 80.5).into(), r: 8.0}});
|
||||||
//layout.route_seg(index, Point {x: 400.5, y: 350.5}, 6.0);
|
//layout.draw_seg(index, Point {x: 400.5, y: 350.5}, 6.0);
|
||||||
|
|
||||||
let index2 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (180.5, 150.5).into(), r: 8.0}});
|
let index2 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (180.5, 150.5).into(), r: 8.0}});
|
||||||
let barrier1 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (90.5, 150.5).into(), r: 8.0}});
|
let barrier1 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (90.5, 150.5).into(), r: 8.0}});
|
||||||
|
|
@ -66,11 +66,11 @@ fn main() {
|
||||||
let barrier2 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (190.5, 250.5).into(), r: 8.0}});
|
let barrier2 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (190.5, 250.5).into(), r: 8.0}});
|
||||||
layout.add_seg(index3, barrier2, 16.0);
|
layout.add_seg(index3, barrier2, 16.0);
|
||||||
|
|
||||||
let index4 = layout.route_around_dot(index, index2, true, 5.0);
|
let index4 = layout.draw_around_dot(index, index2, true, 5.0);
|
||||||
let index5 = layout.route_around_dot(index4, index3, false, 5.0);
|
let index5 = layout.draw_around_dot(index4, index3, false, 5.0);
|
||||||
|
|
||||||
let index6 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (140.5, 300.5).into(), r: 8.0}});
|
let index6 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (140.5, 300.5).into(), r: 8.0}});
|
||||||
let index7 = layout.route_to(index5, index6, 5.0);*/
|
let index7 = layout.draw_to(index5, index6, 5.0);*/
|
||||||
|
|
||||||
/*let dot1 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (100.5, 150.5).into(), r: 8.0}});
|
/*let dot1 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (100.5, 150.5).into(), r: 8.0}});
|
||||||
let dot2 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (130.5, 150.5).into(), r: 8.0}});
|
let dot2 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (130.5, 150.5).into(), r: 8.0}});
|
||||||
|
|
@ -84,25 +84,25 @@ fn main() {
|
||||||
let dot5 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (220.5, 380.5).into(), r: 8.0}});
|
let dot5 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (220.5, 380.5).into(), r: 8.0}});
|
||||||
let dot6 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (290.5, 380.5).into(), r: 8.0}});
|
let dot6 = layout.add_dot(DotWeight {net: 0, circle: Circle {pos: (290.5, 380.5).into(), r: 8.0}});
|
||||||
|
|
||||||
let head = layout.route_start(dot3);
|
let head = layout.draw_start(dot3);
|
||||||
let head = layout.route_around_dot(head, obstacle_dot1, true, 5.0);
|
let head = layout.draw_around_dot(head, obstacle_dot1, true, 5.0);
|
||||||
let dot3_1 = head.dot;
|
let dot3_1 = head.dot;
|
||||||
let bend3_1 = head.bend.unwrap();
|
let bend3_1 = head.bend.unwrap();
|
||||||
layout.route_finish(head, dot4, 5.0);
|
layout.draw_finish(head, dot4, 5.0);
|
||||||
|
|
||||||
let head = layout.route_start(dot2);
|
let head = layout.draw_start(dot2);
|
||||||
let head = layout.route_around_dot(head, dot3, true, 5.0);
|
let head = layout.draw_around_dot(head, dot3, true, 5.0);
|
||||||
let dot2_1 = head.dot;
|
let dot2_1 = head.dot;
|
||||||
let bend2_1 = head.bend.unwrap();
|
let bend2_1 = head.bend.unwrap();
|
||||||
let head = layout.route_around_bend(head, bend3_1, true, 5.0);
|
let head = layout.draw_around_bend(head, bend3_1, true, 5.0);
|
||||||
let dot2_2 = head.dot;
|
let dot2_2 = head.dot;
|
||||||
let bend2_2 = head.bend.unwrap();
|
let bend2_2 = head.bend.unwrap();
|
||||||
layout.route_finish(head, dot5, 5.0);
|
layout.draw_finish(head, dot5, 5.0);
|
||||||
|
|
||||||
let head = layout.route_start(dot1);
|
let head = layout.draw_start(dot1);
|
||||||
let head = layout.route_around_bend(head, bend2_1, true, 5.0);
|
let head = layout.draw_around_bend(head, bend2_1, true, 5.0);
|
||||||
let head = layout.route_around_bend(head, bend2_2, true, 5.0);
|
let head = layout.draw_around_bend(head, bend2_2, true, 5.0);
|
||||||
layout.route_finish(head, dot6, 5.0);*/
|
layout.draw_finish(head, dot6, 5.0);*/
|
||||||
|
|
||||||
let dot1_1 = layout
|
let dot1_1 = layout
|
||||||
.add_dot(DotWeight {
|
.add_dot(DotWeight {
|
||||||
|
|
@ -248,73 +248,73 @@ fn main() {
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let _ = layout.add_seg(barrier2_dot1, barrier2_dot2, 16.0);
|
let _ = layout.add_seg(barrier2_dot1, barrier2_dot2, 16.0);
|
||||||
|
|
||||||
let head = layout.route_start(dot5);
|
let head = layout.draw_start(dot5);
|
||||||
let head = layout.route_around_dot(head, dot6, false, 5.0).unwrap();
|
let head = layout.draw_around_dot(head, dot6, false, 5.0).unwrap();
|
||||||
let _ = layout.route_finish(head, dot7, 5.0);
|
let _ = layout.draw_finish(head, dot7, 5.0);
|
||||||
|
|
||||||
/*render_times(&mut event_pump, &mut canvas, &mut layout, None, -1);
|
/*render_times(&mut event_pump, &mut canvas, &mut layout, None, -1);
|
||||||
|
|
||||||
let head = layout.route_start(dot1_1);
|
let head = layout.draw_start(dot1_1);
|
||||||
let head = layout
|
let head = layout
|
||||||
.route_around_dot(head, barrier1_dot1, true, 5.0)
|
.draw_around_dot(head, barrier1_dot1, true, 5.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let head = layout
|
let head = layout
|
||||||
.route_around_dot(head, barrier2_dot1, true, 5.0)
|
.draw_around_dot(head, barrier2_dot1, true, 5.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
layout.route_finish(head, dot1_2, 5.0).unwrap();
|
layout.draw_finish(head, dot1_2, 5.0).unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
|
|
||||||
let head = layout.route_start(dot2_1);
|
let head = layout.draw_start(dot2_1);
|
||||||
let head = layout
|
let head = layout
|
||||||
.shove_around_dot(head, barrier1_dot1, true, 5.0)
|
.squeeze_around_dot(head, barrier1_dot1, true, 5.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let head = layout
|
let head = layout
|
||||||
.shove_around_dot(head, barrier2_dot1, true, 5.0)
|
.squeeze_around_dot(head, barrier2_dot1, true, 5.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let _ = layout.route_finish(head, dot2_2, 5.0);
|
let _ = layout.draw_finish(head, dot2_2, 5.0);
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
|
|
||||||
let head = layout.route_start(dot3_1);
|
let head = layout.draw_start(dot3_1);
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let head = layout
|
let head = layout
|
||||||
.shove_around_dot(head, barrier1_dot1, true, 5.0)
|
.squeeze_around_dot(head, barrier1_dot1, true, 5.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let head = layout
|
let head = layout
|
||||||
.shove_around_dot(head, barrier2_dot1, true, 5.0)
|
.squeeze_around_dot(head, barrier2_dot1, true, 5.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let _ = layout.route_finish(head, dot3_2, 5.0);
|
let _ = layout.draw_finish(head, dot3_2, 5.0);
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
|
|
||||||
let head = layout.route_start(dot4_1);
|
let head = layout.draw_start(dot4_1);
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let head = layout
|
let head = layout
|
||||||
.shove_around_dot(head, barrier1_dot1, true, 5.0)
|
.squeeze_around_dot(head, barrier1_dot1, true, 5.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let head = layout
|
let head = layout
|
||||||
.shove_around_dot(head, barrier2_dot1, true, 5.0)
|
.squeeze_around_dot(head, barrier2_dot1, true, 5.0)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, 50);
|
||||||
let _ = layout.route_finish(head, dot4_2, 5.0);*/
|
let _ = layout.draw_finish(head, dot4_2, 5.0);*/
|
||||||
|
|
||||||
render_times(&mut event_pump, &mut canvas, &mut layout, None, -1);
|
render_times(&mut event_pump, &mut canvas, &mut layout, None, -1);
|
||||||
render_times(
|
render_times(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue