mirror of https://codeberg.org/topola/topola.git
layout,connectivity: add band edges when adding terminating segs
This commit is contained in:
parent
644d648f71
commit
37fa62a4c2
|
|
@ -45,6 +45,7 @@ impl GetNet for BandWeight {
|
||||||
|
|
||||||
pub type BandIndex = GenericIndex<BandWeight>;
|
pub type BandIndex = GenericIndex<BandWeight>;
|
||||||
|
|
||||||
#[enum_dispatch]
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy)]
|
||||||
pub enum ConnectivityLabel {}
|
pub enum ConnectivityLabel {
|
||||||
|
Band,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,14 +10,14 @@ use thiserror::Error;
|
||||||
|
|
||||||
use crate::band::Band;
|
use crate::band::Band;
|
||||||
use crate::connectivity::{
|
use crate::connectivity::{
|
||||||
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityWeight,
|
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel,
|
||||||
GetNet,
|
ConnectivityWeight, GetNet,
|
||||||
};
|
};
|
||||||
use crate::geometry::{
|
use crate::geometry::{
|
||||||
BendWeight, DotIndex, DotWeight, FixedBendIndex, FixedDotIndex, FixedDotWeight, FixedSegIndex,
|
BendWeight, DotIndex, DotWeight, FixedBendIndex, FixedDotIndex, FixedDotWeight, FixedSegIndex,
|
||||||
FixedSegWeight, GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, LoneLooseSegIndex,
|
FixedSegWeight, GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, GetComponentIndex,
|
||||||
LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex, LooseDotWeight,
|
LoneLooseSegIndex, LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex,
|
||||||
MakePrimitive, Retag, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
|
LooseDotWeight, MakePrimitive, Retag, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
|
||||||
};
|
};
|
||||||
use crate::graph::{GenericIndex, GetNodeIndex};
|
use crate::graph::{GenericIndex, GetNodeIndex};
|
||||||
use crate::guide::Guide;
|
use crate::guide::Guide;
|
||||||
|
|
@ -131,6 +131,8 @@ impl Layout {
|
||||||
for outer in outers {
|
for outer in outers {
|
||||||
self.update_this_and_outward_bows(outer).unwrap(); // Must never fail.
|
self.update_this_and_outward_bows(outer).unwrap(); // Must never fail.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.connectivity.remove_node(band.node_index());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_ensures(self.geometry.node_count() == old(self.geometry.node_count() - 4))]
|
#[debug_ensures(self.geometry.node_count() == old(self.geometry.node_count() - 4))]
|
||||||
|
|
@ -533,7 +535,20 @@ impl Layout {
|
||||||
to: FixedDotIndex,
|
to: FixedDotIndex,
|
||||||
weight: LoneLooseSegWeight,
|
weight: LoneLooseSegWeight,
|
||||||
) -> Result<LoneLooseSegIndex, Infringement> {
|
) -> Result<LoneLooseSegIndex, Infringement> {
|
||||||
self.add_seg_infringably(from, to, weight, &[])
|
let seg = self.add_seg_infringably(from, to, weight, &[])?;
|
||||||
|
|
||||||
|
self.connectivity.update_edge(
|
||||||
|
self.primitive(from).component().node_index(),
|
||||||
|
weight.band.node_index(),
|
||||||
|
ConnectivityLabel::Band,
|
||||||
|
);
|
||||||
|
self.connectivity.update_edge(
|
||||||
|
weight.band.node_index(),
|
||||||
|
self.primitive(to).component().node_index(),
|
||||||
|
ConnectivityLabel::Band,
|
||||||
|
);
|
||||||
|
|
||||||
|
Ok(seg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_ensures(ret.is_ok() -> self.geometry.node_count() == old(self.geometry.node_count() + 1))]
|
#[debug_ensures(ret.is_ok() -> self.geometry.node_count() == old(self.geometry.node_count() + 1))]
|
||||||
|
|
@ -546,7 +561,17 @@ impl Layout {
|
||||||
to: LooseDotIndex,
|
to: LooseDotIndex,
|
||||||
weight: SeqLooseSegWeight,
|
weight: SeqLooseSegWeight,
|
||||||
) -> Result<SeqLooseSegIndex, Infringement> {
|
) -> Result<SeqLooseSegIndex, Infringement> {
|
||||||
self.add_seg_infringably(from, to, weight, &[])
|
let seg = self.add_seg_infringably(from, to, weight, &[])?;
|
||||||
|
|
||||||
|
if let DotIndex::Fixed(dot) = from {
|
||||||
|
self.connectivity.update_edge(
|
||||||
|
self.primitive(dot).component().node_index(),
|
||||||
|
weight.band.node_index(),
|
||||||
|
ConnectivityLabel::Band,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(seg)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[debug_ensures(ret.is_ok() -> self.geometry.node_count() == old(self.geometry.node_count() + 1))]
|
#[debug_ensures(ret.is_ok() -> self.geometry.node_count() == old(self.geometry.node_count() + 1))]
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ use enum_dispatch::enum_dispatch;
|
||||||
use petgraph::stable_graph::NodeIndex;
|
use petgraph::stable_graph::NodeIndex;
|
||||||
use petgraph::Direction::{Incoming, Outgoing};
|
use petgraph::Direction::{Incoming, Outgoing};
|
||||||
|
|
||||||
use crate::connectivity::{BandIndex, GetNet};
|
use crate::connectivity::{BandIndex, ComponentIndex, GetNet};
|
||||||
use crate::geometry::{
|
use crate::geometry::{
|
||||||
DotIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight, FixedSegWeight, GeometryIndex,
|
DotIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight, FixedSegWeight, GeometryIndex,
|
||||||
GeometryLabel, GeometryWeight, GetBandIndex, GetComponentIndex, GetOffset, GetWidth,
|
GeometryLabel, GeometryWeight, GetBandIndex, GetComponentIndex, GetOffset, GetWidth,
|
||||||
|
|
@ -174,11 +174,17 @@ macro_rules! impl_fixed_primitive {
|
||||||
($primitive_struct:ident, $weight_struct:ident) => {
|
($primitive_struct:ident, $weight_struct:ident) => {
|
||||||
impl_primitive!($primitive_struct, $weight_struct);
|
impl_primitive!($primitive_struct, $weight_struct);
|
||||||
|
|
||||||
|
impl<'a> GetComponentIndex for $primitive_struct<'a> {
|
||||||
|
fn component(&self) -> ComponentIndex {
|
||||||
|
self.weight().component()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> GetNet for $primitive_struct<'a> {
|
impl<'a> GetNet for $primitive_struct<'a> {
|
||||||
fn net(&self) -> i64 {
|
fn net(&self) -> i64 {
|
||||||
self.layout()
|
self.layout()
|
||||||
.connectivity()
|
.connectivity()
|
||||||
.node_weight(self.weight().component().node_index())
|
.node_weight(self.component().node_index())
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.net()
|
.net()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue