mirror of https://codeberg.org/topola/topola.git
primitive: rename "dependents" to "legs"
This commit is contained in:
parent
cded5eda7f
commit
5d1b3dff9a
|
|
@ -24,7 +24,7 @@ use crate::guide::Guide;
|
|||
use crate::loose::{GetNextLoose, Loose, LooseIndex};
|
||||
use crate::math::NoTangents;
|
||||
use crate::primitive::{
|
||||
GenericPrimitive, GetConnectable, GetCore, GetDependents, GetEnds, GetInnerOuter, GetOtherEnd,
|
||||
GenericPrimitive, GetConnectable, GetCore, GetEnds, GetInnerOuter, GetLegs, GetOtherEnd,
|
||||
GetWeight, MakeShape,
|
||||
};
|
||||
use crate::segbend::Segbend;
|
||||
|
|
@ -823,7 +823,7 @@ impl Layout {
|
|||
to: Point,
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<(), Infringement> {
|
||||
self.remove_from_rtree_with_dependents(dot.into());
|
||||
self.remove_from_rtree_with_legs(dot.into());
|
||||
|
||||
let mut weight = *self.geometry.node_weight(dot.node_index()).unwrap();
|
||||
let old_weight = weight;
|
||||
|
|
@ -844,11 +844,11 @@ impl Layout {
|
|||
// Restore original state.
|
||||
*self.geometry.node_weight_mut(dot.node_index()).unwrap() = old_weight;
|
||||
|
||||
self.insert_into_rtree_with_dependents(dot.into());
|
||||
self.insert_into_rtree_with_legs(dot.into());
|
||||
return Err(infringement);
|
||||
}
|
||||
|
||||
self.insert_into_rtree_with_dependents(dot.into());
|
||||
self.insert_into_rtree_with_legs(dot.into());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
@ -894,11 +894,11 @@ impl Layout {
|
|||
|
||||
#[debug_ensures(self.geometry.node_count() == old(self.geometry.node_count()))]
|
||||
#[debug_ensures(self.geometry.edge_count() == old(self.geometry.edge_count()))]
|
||||
fn insert_into_rtree_with_dependents(&mut self, node: GeometryIndex) {
|
||||
fn insert_into_rtree_with_legs(&mut self, node: GeometryIndex) {
|
||||
self.insert_into_rtree(node);
|
||||
|
||||
for dependent in node.primitive(self).dependents() {
|
||||
self.insert_into_rtree(dependent);
|
||||
for leg in node.primitive(self).legs() {
|
||||
self.insert_into_rtree(leg);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -911,9 +911,9 @@ impl Layout {
|
|||
|
||||
#[debug_ensures(self.geometry.node_count() == old(self.geometry.node_count()))]
|
||||
#[debug_ensures(self.geometry.edge_count() == old(self.geometry.edge_count()))]
|
||||
fn remove_from_rtree_with_dependents(&mut self, node: GeometryIndex) {
|
||||
for dependent in node.primitive(self).dependents() {
|
||||
self.remove_from_rtree(dependent);
|
||||
fn remove_from_rtree_with_legs(&mut self, node: GeometryIndex) {
|
||||
for leg in node.primitive(self).legs() {
|
||||
self.remove_from_rtree(leg);
|
||||
}
|
||||
|
||||
self.remove_from_rtree(node);
|
||||
|
|
|
|||
|
|
@ -44,8 +44,8 @@ pub trait MakeShape {
|
|||
}
|
||||
|
||||
#[enum_dispatch]
|
||||
pub trait GetDependents {
|
||||
fn dependents(&self) -> Vec<GeometryIndex> {
|
||||
pub trait GetLegs {
|
||||
fn legs(&self) -> Vec<GeometryIndex> {
|
||||
let mut v = vec![];
|
||||
v.extend(self.segs().into_iter().map(Into::<GeometryIndex>::into));
|
||||
v.extend(self.bends().into_iter().map(Into::<GeometryIndex>::into));
|
||||
|
|
@ -227,7 +227,7 @@ macro_rules! impl_loose_primitive {
|
|||
};
|
||||
}
|
||||
|
||||
#[enum_dispatch(GetNet, GetWidth, GetLayout, GetConnectable, MakeShape, GetDependents)]
|
||||
#[enum_dispatch(GetNet, GetWidth, GetLayout, GetConnectable, MakeShape, GetLegs)]
|
||||
pub enum Primitive<'a> {
|
||||
FixedDot(FixedDot<'a>),
|
||||
LooseDot(LooseDot<'a>),
|
||||
|
|
@ -339,7 +339,7 @@ impl<'a> MakeShape for FixedDot<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetDependents for FixedDot<'a> {
|
||||
impl<'a> GetLegs for FixedDot<'a> {
|
||||
fn segs(&self) -> Vec<SegIndex> {
|
||||
self.adjacents()
|
||||
.into_iter()
|
||||
|
|
@ -416,7 +416,7 @@ impl<'a> MakeShape for LooseDot<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetDependents for LooseDot<'a> {
|
||||
impl<'a> GetLegs for LooseDot<'a> {
|
||||
fn segs(&self) -> Vec<SegIndex> {
|
||||
if let Some(seg) = self.seg() {
|
||||
vec![seg.into()]
|
||||
|
|
@ -444,7 +444,7 @@ impl<'a> MakeShape for FixedSeg<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetDependents for FixedSeg<'a> {}
|
||||
impl<'a> GetLegs for FixedSeg<'a> {}
|
||||
|
||||
impl<'a> GetEnds<FixedDotIndex, FixedDotIndex> for FixedSeg<'a> {
|
||||
fn ends(&self) -> (FixedDotIndex, FixedDotIndex) {
|
||||
|
|
@ -469,7 +469,7 @@ impl<'a> MakeShape for LoneLooseSeg<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetDependents for LoneLooseSeg<'a> {}
|
||||
impl<'a> GetLegs for LoneLooseSeg<'a> {}
|
||||
|
||||
impl<'a> GetWidth for LoneLooseSeg<'a> {
|
||||
fn width(&self) -> f64 {
|
||||
|
|
@ -503,7 +503,7 @@ impl<'a> MakeShape for SeqLooseSeg<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetDependents for SeqLooseSeg<'a> {}
|
||||
impl<'a> GetLegs for SeqLooseSeg<'a> {}
|
||||
|
||||
impl<'a> GetWidth for SeqLooseSeg<'a> {
|
||||
fn width(&self) -> f64 {
|
||||
|
|
@ -566,7 +566,7 @@ impl<'a> MakeShape for FixedBend<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetDependents for FixedBend<'a> {}
|
||||
impl<'a> GetLegs for FixedBend<'a> {}
|
||||
|
||||
impl<'a> GetEnds<FixedDotIndex, FixedDotIndex> for FixedBend<'a> {
|
||||
fn ends(&self) -> (FixedDotIndex, FixedDotIndex) {
|
||||
|
|
@ -627,7 +627,7 @@ impl<'a> MakeShape for LooseBend<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> GetDependents for LooseBend<'a> {}
|
||||
impl<'a> GetLegs for LooseBend<'a> {}
|
||||
|
||||
impl<'a> GetWidth for LooseBend<'a> {
|
||||
fn width(&self) -> f64 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue