mirror of https://codeberg.org/topola/topola.git
graph: Store the offset from the bend immediately below in bend weight
This commit is contained in:
parent
294e6c4f72
commit
92834c66c8
|
|
@ -255,6 +255,7 @@ impl<'a> Draw<'a> {
|
||||||
LooseSegWeight { band: head.band() },
|
LooseSegWeight { band: head.band() },
|
||||||
LooseBendWeight {
|
LooseBendWeight {
|
||||||
band: head.band(),
|
band: head.band(),
|
||||||
|
offset: 3.0,
|
||||||
cw,
|
cw,
|
||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
|
||||||
13
src/graph.rs
13
src/graph.rs
|
|
@ -29,12 +29,10 @@ pub trait GetNet {
|
||||||
fn net(&self) -> i64;
|
fn net(&self) -> i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[enum_dispatch]
|
|
||||||
pub trait GetNetMut {
|
pub trait GetNetMut {
|
||||||
fn net_mut(&mut self) -> &mut i64;
|
fn net_mut(&mut self) -> &mut i64;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[enum_dispatch]
|
|
||||||
pub trait GetBand {
|
pub trait GetBand {
|
||||||
fn band(&self) -> usize;
|
fn band(&self) -> usize;
|
||||||
}
|
}
|
||||||
|
|
@ -44,6 +42,10 @@ pub trait GetWidth {
|
||||||
fn width(&self) -> f64;
|
fn width(&self) -> f64;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait GetOffset {
|
||||||
|
fn offset(&self) -> f64;
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! impl_weight {
|
macro_rules! impl_weight {
|
||||||
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
|
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
|
||||||
impl Retag for $weight_struct {
|
impl Retag for $weight_struct {
|
||||||
|
|
@ -243,9 +245,16 @@ impl GetWidth for FixedBendWeight {
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||||
pub struct LooseBendWeight {
|
pub struct LooseBendWeight {
|
||||||
pub band: usize,
|
pub band: usize,
|
||||||
|
pub offset: f64,
|
||||||
pub cw: bool,
|
pub cw: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl GetOffset for LooseBendWeight {
|
||||||
|
fn offset(&self) -> f64 {
|
||||||
|
self.offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl_loose_weight!(LooseBendWeight, LooseBend, LooseBendIndex);
|
impl_loose_weight!(LooseBendWeight, LooseBend, LooseBendIndex);
|
||||||
impl BendWeight for LooseBendWeight {}
|
impl BendWeight for LooseBendWeight {}
|
||||||
|
|
||||||
|
|
|
||||||
15
src/guide.rs
15
src/guide.rs
|
|
@ -7,7 +7,7 @@ use crate::{
|
||||||
math::{self, Circle},
|
math::{self, Circle},
|
||||||
primitive::{GetCore, GetInnerOuter, GetWeight, MakeShape},
|
primitive::{GetCore, GetInnerOuter, GetWeight, MakeShape},
|
||||||
rules::{Conditions, Rules},
|
rules::{Conditions, Rules},
|
||||||
shape::ShapeTrait,
|
shape::{Shape, ShapeTrait},
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Guide<'a, 'b> {
|
pub struct Guide<'a, 'b> {
|
||||||
|
|
@ -134,13 +134,14 @@ impl<'a, 'b> Guide<'a, 'b> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn bend_circle(&self, bend: BendIndex, width: f64) -> Circle {
|
fn bend_circle(&self, bend: BendIndex, width: f64) -> Circle {
|
||||||
let shape = bend.primitive(self.layout).shape();
|
let outer_circle = match bend.primitive(self.layout).shape() {
|
||||||
|
Shape::Bend(shape) => shape.outer_circle(),
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
|
||||||
Circle {
|
Circle {
|
||||||
pos: shape.center(),
|
pos: outer_circle.pos,
|
||||||
r: shape.width() / 2.0
|
r: outer_circle.r + width,
|
||||||
+ width
|
|
||||||
+ 6.0
|
|
||||||
+ self.rules.ruleset(self.conditions).clearance.min,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,9 @@ use petgraph::Direction::{Incoming, Outgoing};
|
||||||
|
|
||||||
use crate::graph::{
|
use crate::graph::{
|
||||||
DotIndex, FixedBendIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight, FixedSegWeight,
|
DotIndex, FixedBendIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight, FixedSegWeight,
|
||||||
GenericIndex, GetBand, GetEnds, GetNet, GetNodeIndex, GetWidth, Index, Interior, Label,
|
GenericIndex, GetBand, GetEnds, GetNet, GetNodeIndex, GetOffset, GetWidth, Index, Interior,
|
||||||
LooseBendIndex, LooseBendWeight, LooseDotIndex, LooseDotWeight, LooseSegIndex, LooseSegWeight,
|
Label, LooseBendIndex, LooseBendWeight, LooseDotIndex, LooseDotWeight, LooseSegIndex,
|
||||||
MakePrimitive, Retag, Weight,
|
LooseSegWeight, MakePrimitive, Retag, Weight,
|
||||||
};
|
};
|
||||||
use crate::layout::Layout;
|
use crate::layout::Layout;
|
||||||
use crate::math::{self, Circle};
|
use crate::math::{self, Circle};
|
||||||
|
|
@ -484,11 +484,12 @@ impl_loose_primitive!(LooseBend, LooseBendWeight);
|
||||||
|
|
||||||
impl<'a> LooseBend<'a> {
|
impl<'a> LooseBend<'a> {
|
||||||
fn inner_radius(&self) -> f64 {
|
fn inner_radius(&self) -> f64 {
|
||||||
let mut r = 0.0;
|
let mut r = self.offset();
|
||||||
let mut rail = LooseBendIndex::new(self.index.node_index());
|
let mut rail = LooseBendIndex::new(self.index.node_index());
|
||||||
|
|
||||||
while let Some(inner) = self.primitive(rail).inner() {
|
while let Some(inner) = self.primitive(rail).inner() {
|
||||||
r += self.primitive(inner).width();
|
let primitive = self.primitive(inner);
|
||||||
|
r += primitive.width() + primitive.offset();
|
||||||
rail = inner;
|
rail = inner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -500,7 +501,7 @@ impl<'a> LooseBend<'a> {
|
||||||
.weight()
|
.weight()
|
||||||
.circle;
|
.circle;
|
||||||
|
|
||||||
core_circle.r + r + 3.0
|
core_circle.r + r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -531,6 +532,12 @@ impl<'a> GetWidth for LooseBend<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> GetOffset for LooseBend<'a> {
|
||||||
|
fn offset(&self) -> f64 {
|
||||||
|
self.weight().offset
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> GetEnds<LooseDotIndex, LooseDotIndex> for LooseBend<'a> {
|
impl<'a> GetEnds<LooseDotIndex, LooseDotIndex> for LooseBend<'a> {
|
||||||
fn ends(&self) -> (LooseDotIndex, LooseDotIndex) {
|
fn ends(&self) -> (LooseDotIndex, LooseDotIndex) {
|
||||||
let v = self.adjacents();
|
let v = self.adjacents();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue