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>;
|
||||
|
||||
#[enum_dispatch]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum ConnectivityLabel {}
|
||||
pub enum ConnectivityLabel {
|
||||
Band,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,14 +10,14 @@ use thiserror::Error;
|
|||
|
||||
use crate::band::Band;
|
||||
use crate::connectivity::{
|
||||
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityWeight,
|
||||
GetNet,
|
||||
BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityGraph, ConnectivityLabel,
|
||||
ConnectivityWeight, GetNet,
|
||||
};
|
||||
use crate::geometry::{
|
||||
BendWeight, DotIndex, DotWeight, FixedBendIndex, FixedDotIndex, FixedDotWeight, FixedSegIndex,
|
||||
FixedSegWeight, GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, LoneLooseSegIndex,
|
||||
LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex, LooseDotWeight,
|
||||
MakePrimitive, Retag, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
|
||||
FixedSegWeight, GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, GetComponentIndex,
|
||||
LoneLooseSegIndex, LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex,
|
||||
LooseDotWeight, MakePrimitive, Retag, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
|
||||
};
|
||||
use crate::graph::{GenericIndex, GetNodeIndex};
|
||||
use crate::guide::Guide;
|
||||
|
|
@ -131,6 +131,8 @@ impl Layout {
|
|||
for outer in outers {
|
||||
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))]
|
||||
|
|
@ -533,7 +535,20 @@ impl Layout {
|
|||
to: FixedDotIndex,
|
||||
weight: LoneLooseSegWeight,
|
||||
) -> 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))]
|
||||
|
|
@ -546,7 +561,17 @@ impl Layout {
|
|||
to: LooseDotIndex,
|
||||
weight: SeqLooseSegWeight,
|
||||
) -> 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))]
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use enum_dispatch::enum_dispatch;
|
|||
use petgraph::stable_graph::NodeIndex;
|
||||
use petgraph::Direction::{Incoming, Outgoing};
|
||||
|
||||
use crate::connectivity::{BandIndex, GetNet};
|
||||
use crate::connectivity::{BandIndex, ComponentIndex, GetNet};
|
||||
use crate::geometry::{
|
||||
DotIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight, FixedSegWeight, GeometryIndex,
|
||||
GeometryLabel, GeometryWeight, GetBandIndex, GetComponentIndex, GetOffset, GetWidth,
|
||||
|
|
@ -174,11 +174,17 @@ macro_rules! impl_fixed_primitive {
|
|||
($primitive_struct:ident, $weight_struct:ident) => {
|
||||
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> {
|
||||
fn net(&self) -> i64 {
|
||||
self.layout()
|
||||
.connectivity()
|
||||
.node_weight(self.weight().component().node_index())
|
||||
.node_weight(self.component().node_index())
|
||||
.unwrap()
|
||||
.net()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue