mirror of https://codeberg.org/topola/topola.git
layout: don't make abutters infringable as we don't need that anymore
Since we switched from having a long infringables list to using an epsilon in intersection detection.
This commit is contained in:
parent
ff19c252c1
commit
4365284d47
|
|
@ -19,74 +19,7 @@ impl<'a, R: RulesTrait> Collect<'a, R> {
|
||||||
Self { layout }
|
Self { layout }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bend_abutters_and_posteriors(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
pub fn bend_bow(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
||||||
// Bend's posteriors are the outer abutters and afterouter bows.
|
|
||||||
// Bend's afterouter bows are the bows of bend's afterouters.
|
|
||||||
// Bend's afterouters are the bends outer to the outer bend of said bend.
|
|
||||||
let mut v = vec![];
|
|
||||||
let bend_primitive = self.layout.primitive(bend);
|
|
||||||
|
|
||||||
if let Some(inner) = bend_primitive.inner() {
|
|
||||||
v.append(&mut self.bow(inner.into()));
|
|
||||||
} else {
|
|
||||||
let core = bend_primitive.core();
|
|
||||||
v.push(core.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
let mut rail = bend;
|
|
||||||
|
|
||||||
while let Some(outer) = self.layout.primitive(rail).outer() {
|
|
||||||
v.append(&mut self.bow(outer.into()));
|
|
||||||
rail = outer;
|
|
||||||
}
|
|
||||||
|
|
||||||
v
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn bend_abutters(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
|
||||||
let mut v = vec![];
|
|
||||||
let bend_primitive = self.layout.primitive(bend);
|
|
||||||
|
|
||||||
if let Some(inner) = bend_primitive.inner() {
|
|
||||||
v.append(&mut self.bow(inner.into()));
|
|
||||||
} else {
|
|
||||||
let core = bend_primitive.core();
|
|
||||||
v.push(core.into());
|
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(outer) = bend_primitive.outer() {
|
|
||||||
v.append(&mut self.bow(outer.into()));
|
|
||||||
}
|
|
||||||
|
|
||||||
v
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn potential_segbend_abutters(
|
|
||||||
&self,
|
|
||||||
from: DotIndex,
|
|
||||||
around: WraparoundableIndex,
|
|
||||||
) -> Vec<GeometryIndex> {
|
|
||||||
let mut v = match from {
|
|
||||||
DotIndex::Fixed(..) => vec![],
|
|
||||||
DotIndex::Loose(dot) => self.bend_abutters(self.layout.primitive(dot).bend().into()),
|
|
||||||
};
|
|
||||||
v.append(&mut self.this_and_wraparound_bow(around));
|
|
||||||
v
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn this_and_wraparound_bow(&self, around: WraparoundableIndex) -> Vec<GeometryIndex> {
|
|
||||||
let mut v = match around {
|
|
||||||
WraparoundableIndex::FixedDot(..) => vec![around.into()],
|
|
||||||
WraparoundableIndex::FixedBend(..) => vec![around.into()],
|
|
||||||
WraparoundableIndex::LooseBend(bend) => self.bow(bend),
|
|
||||||
};
|
|
||||||
if let Some(wraparound) = self.layout.wraparoundable(around).wraparound() {
|
|
||||||
v.append(&mut self.bow(wraparound));
|
|
||||||
}
|
|
||||||
v
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn bow(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
|
||||||
let mut v: Vec<GeometryIndex> = vec![];
|
let mut v: Vec<GeometryIndex> = vec![];
|
||||||
v.push(bend.into());
|
v.push(bend.into());
|
||||||
|
|
||||||
|
|
@ -105,11 +38,23 @@ impl<'a, R: RulesTrait> Collect<'a, R> {
|
||||||
v
|
v
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn outer_bows(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
pub fn bend_outer_bows(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
||||||
let mut v = vec![];
|
let mut v = vec![];
|
||||||
let mut rail = bend;
|
let mut rail = bend;
|
||||||
|
|
||||||
while let Some(outer) = self.layout.primitive(rail).outer() {
|
while let Some(outer) = self.layout.primitive(rail).outer() {
|
||||||
|
v.append(&mut self.bend_bow(outer.into()));
|
||||||
|
rail = outer;
|
||||||
|
}
|
||||||
|
|
||||||
|
v
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn wraparounded_bows(&self, around: WraparoundableIndex) -> Vec<GeometryIndex> {
|
||||||
|
let mut v = vec![];
|
||||||
|
let mut rail = around.into();
|
||||||
|
|
||||||
|
while let Some(outer) = self.layout.wraparoundable(rail).wraparound() {
|
||||||
let primitive = self.layout.primitive(outer);
|
let primitive = self.layout.primitive(outer);
|
||||||
|
|
||||||
v.push(outer.into());
|
v.push(outer.into());
|
||||||
|
|
@ -121,7 +66,7 @@ impl<'a, R: RulesTrait> Collect<'a, R> {
|
||||||
v.push(self.layout.primitive(ends.0).seg().unwrap().into());
|
v.push(self.layout.primitive(ends.0).seg().unwrap().into());
|
||||||
v.push(self.layout.primitive(ends.1).seg().unwrap().into());
|
v.push(self.layout.primitive(ends.1).seg().unwrap().into());
|
||||||
|
|
||||||
rail = outer;
|
rail = outer.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
v
|
v
|
||||||
|
|
|
||||||
|
|
@ -260,11 +260,7 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
cw: bool,
|
cw: bool,
|
||||||
) -> Result<Segbend, LayoutException> {
|
) -> Result<Segbend, LayoutException> {
|
||||||
let maybe_wraparound = self.wraparoundable(around).wraparound();
|
let maybe_wraparound = self.wraparoundable(around).wraparound();
|
||||||
let mut infringables = self.collect().potential_segbend_abutters(from, around);
|
let infringables = self.collect().wraparounded_bows(around);
|
||||||
|
|
||||||
if let Some(wraparound) = maybe_wraparound {
|
|
||||||
infringables.append(&mut self.collect().outer_bows(wraparound));
|
|
||||||
}
|
|
||||||
|
|
||||||
let segbend = self.add_segbend_infringably(
|
let segbend = self.add_segbend_infringably(
|
||||||
from,
|
from,
|
||||||
|
|
@ -281,7 +277,7 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(outer) = self.primitive(segbend.bend).outer() {
|
if let Some(outer) = self.primitive(segbend.bend).outer() {
|
||||||
self.update_this_and_outward_bows(outer)?;
|
self.update_this_and_outward_bows(outer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Segs must not cross.
|
// Segs must not cross.
|
||||||
|
|
@ -346,18 +342,18 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
self.move_dot_infringably(
|
self.move_dot_infringably(
|
||||||
joints.0.into(),
|
joints.0.into(),
|
||||||
from,
|
from,
|
||||||
&self.collect().bend_abutters_and_posteriors(rail),
|
&self.collect().bend_outer_bows(rail),
|
||||||
)?;
|
)?;
|
||||||
self.move_dot_infringably(
|
self.move_dot_infringably(
|
||||||
joints.1.into(),
|
joints.1.into(),
|
||||||
to,
|
to,
|
||||||
&self.collect().bend_abutters_and_posteriors(rail),
|
&self.collect().bend_outer_bows(rail),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.shift_bend_infringably(
|
self.shift_bend_infringably(
|
||||||
rail.into(),
|
rail.into(),
|
||||||
offset,
|
offset,
|
||||||
&self.collect().bend_abutters_and_posteriors(rail),
|
&self.collect().bend_outer_bows(rail),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Update offsets in case the rule conditions changed.
|
// Update offsets in case the rule conditions changed.
|
||||||
|
|
@ -388,18 +384,18 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
self.move_dot_infringably(
|
self.move_dot_infringably(
|
||||||
joints.0.into(),
|
joints.0.into(),
|
||||||
from,
|
from,
|
||||||
&self.collect().bend_abutters_and_posteriors(rail),
|
&self.collect().bend_outer_bows(rail),
|
||||||
)?;
|
)?;
|
||||||
self.move_dot_infringably(
|
self.move_dot_infringably(
|
||||||
joints.1.into(),
|
joints.1.into(),
|
||||||
to,
|
to,
|
||||||
&self.collect().bend_abutters_and_posteriors(rail),
|
&self.collect().bend_outer_bows(rail),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
self.shift_bend_infringably(
|
self.shift_bend_infringably(
|
||||||
rail.into(),
|
rail.into(),
|
||||||
offset,
|
offset,
|
||||||
&self.collect().bend_abutters_and_posteriors(rail),
|
&self.collect().bend_outer_bows(rail),
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -429,7 +425,7 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
seg_weight,
|
seg_weight,
|
||||||
bend_weight,
|
bend_weight,
|
||||||
cw,
|
cw,
|
||||||
&self.collect().potential_segbend_abutters(from, around),
|
&self.collect().wraparounded_bows(around),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -733,11 +729,7 @@ impl<R: RulesTrait> Layout<R> {
|
||||||
pub fn move_dot(&mut self, dot: DotIndex, to: Point) -> Result<(), Infringement> {
|
pub fn move_dot(&mut self, dot: DotIndex, to: Point) -> Result<(), Infringement> {
|
||||||
match dot {
|
match dot {
|
||||||
DotIndex::Fixed(..) => self.move_dot_infringably(dot, to, &[]),
|
DotIndex::Fixed(..) => self.move_dot_infringably(dot, to, &[]),
|
||||||
DotIndex::Loose(loose) => self.move_dot_infringably(
|
DotIndex::Loose(..) => self.move_dot_infringably(dot, to, &[]),
|
||||||
dot,
|
|
||||||
to,
|
|
||||||
&self.collect().bend_abutters(self.primitive(loose).bend()),
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -559,8 +559,8 @@ fn main() -> Result<(), anyhow::Error> {
|
||||||
dot_start2,
|
dot_start2,
|
||||||
dot_end2,
|
dot_end2,
|
||||||
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(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue