layout: use epsilons instead of infringable lists to evade abutters

This commit is contained in:
Mikolaj Wielgus 2024-02-15 02:34:25 +00:00
parent 2197017f54
commit 6fa6ec7527
2 changed files with 10 additions and 15 deletions

View File

@ -281,7 +281,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.
@ -309,6 +309,7 @@ impl<R: RulesTrait> Layout<R> {
&mut self, &mut self,
around: LooseBendIndex, around: LooseBendIndex,
) -> Result<(), LayoutException> { ) -> Result<(), LayoutException> {
// FIXME: Fail gracefully on infringement.
let mut maybe_rail = Some(around); let mut maybe_rail = Some(around);
while let Some(rail) = maybe_rail { while let Some(rail) = maybe_rail {
@ -516,14 +517,7 @@ impl<R: RulesTrait> Layout<R> {
to: LooseDotIndex, to: LooseDotIndex,
weight: SeqLooseSegWeight, weight: SeqLooseSegWeight,
) -> Result<SeqLooseSegIndex, Infringement> { ) -> Result<SeqLooseSegIndex, Infringement> {
let seg = self.add_seg_infringably( let seg = self.add_seg_infringably(from, to.into(), weight, &[])?;
from,
to.into(),
weight,
&self
.collect()
.bend_abutters(self.primitive(to).bend().into()),
)?;
if let DotIndex::Fixed(dot) = from { if let DotIndex::Fixed(dot) = from {
self.connectivity.update_edge( self.connectivity.update_edge(
@ -821,10 +815,11 @@ impl<R: RulesTrait> Layout<R> {
.filter(|wrapper| { .filter(|wrapper| {
let infringee_conditions = wrapper.data.primitive(self).conditions(); let infringee_conditions = wrapper.data.primitive(self).conditions();
inflated_shape = node let epsilon = 1.0;
.primitive(self) inflated_shape = node.primitive(self).shape().inflate(
.shape() (self.rules.clearance(&conditions, &infringee_conditions) - epsilon)
.inflate(self.rules.clearance(&conditions, &infringee_conditions)); .clamp(0.0, f64::INFINITY),
);
inflated_shape.intersects(wrapper.geom()) inflated_shape.intersects(wrapper.geom())
}) })

View File

@ -526,8 +526,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(