mirror of https://codeberg.org/topola/topola.git
geometry: rename `Index` to `GeometryIndex`
This commit is contained in:
parent
d9b94742e4
commit
9007b850c4
|
|
@ -3,16 +3,14 @@ use geo::{EuclideanLength, Point};
|
|||
use thiserror::Error;
|
||||
|
||||
use crate::{
|
||||
connectivity::{ComponentIndex, GetNet},
|
||||
geometry::{
|
||||
BendIndex, DotIndex, FixedDotIndex, FixedSegWeight, GetBandIndex, GetComponentIndex,
|
||||
LoneLooseSegWeight, LooseBendWeight, LooseDotIndex, LooseDotWeight, MakePrimitive,
|
||||
SeqLooseSegWeight, WraparoundableIndex,
|
||||
BendIndex, DotIndex, FixedDotIndex, GetBandIndex, LoneLooseSegWeight, LooseBendWeight,
|
||||
LooseDotIndex, LooseDotWeight, MakePrimitive, SeqLooseSegWeight, WraparoundableIndex,
|
||||
},
|
||||
guide::{Guide, Head, HeadTrait, SegbendHead},
|
||||
layout::{Infringement, Layout, LayoutException},
|
||||
math::{Circle, NoTangents},
|
||||
primitive::{GetOtherEnd, GetWeight},
|
||||
primitive::GetOtherEnd,
|
||||
rules::{Conditions, Rules},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use enum_dispatch::enum_dispatch;
|
|||
use petgraph::stable_graph::{NodeIndex, StableDiGraph};
|
||||
|
||||
use crate::{
|
||||
connectivity::{BandIndex, BandWeight, ComponentIndex, ComponentWeight, ConnectivityWeight},
|
||||
connectivity::{BandIndex, ComponentIndex},
|
||||
graph::GenericIndex,
|
||||
layout::Layout,
|
||||
math::Circle,
|
||||
|
|
@ -11,7 +11,7 @@ use crate::{
|
|||
|
||||
#[enum_dispatch]
|
||||
pub trait Retag {
|
||||
fn retag(&self, index: NodeIndex<usize>) -> Index;
|
||||
fn retag(&self, index: NodeIndex<usize>) -> GeometryIndex;
|
||||
}
|
||||
|
||||
#[enum_dispatch]
|
||||
|
|
@ -39,8 +39,8 @@ pub trait GetOffset {
|
|||
macro_rules! impl_weight {
|
||||
($weight_struct:ident, $weight_variant:ident, $index_struct:ident) => {
|
||||
impl Retag for $weight_struct {
|
||||
fn retag(&self, index: NodeIndex<usize>) -> Index {
|
||||
Index::$weight_variant($index_struct::new(index))
|
||||
fn retag(&self, index: NodeIndex<usize>) -> GeometryIndex {
|
||||
GeometryIndex::$weight_variant($index_struct::new(index))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ pub enum GeometryWeight {
|
|||
|
||||
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum Index {
|
||||
pub enum GeometryIndex {
|
||||
FixedDot(FixedDotIndex),
|
||||
LooseDot(LooseDotIndex),
|
||||
FixedSeg(FixedSegIndex),
|
||||
|
|
@ -117,11 +117,11 @@ pub enum DotIndex {
|
|||
Loose(LooseDotIndex),
|
||||
}
|
||||
|
||||
impl From<DotIndex> for Index {
|
||||
impl From<DotIndex> for GeometryIndex {
|
||||
fn from(dot: DotIndex) -> Self {
|
||||
match dot {
|
||||
DotIndex::Fixed(fixed) => Index::FixedDot(fixed),
|
||||
DotIndex::Loose(loose) => Index::LooseDot(loose),
|
||||
DotIndex::Fixed(fixed) => GeometryIndex::FixedDot(fixed),
|
||||
DotIndex::Loose(loose) => GeometryIndex::LooseDot(loose),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -134,12 +134,12 @@ pub enum SegIndex {
|
|||
SeqLoose(SeqLooseSegIndex),
|
||||
}
|
||||
|
||||
impl From<SegIndex> for Index {
|
||||
impl From<SegIndex> for GeometryIndex {
|
||||
fn from(seg: SegIndex) -> Self {
|
||||
match seg {
|
||||
SegIndex::Fixed(seg) => Index::FixedSeg(seg),
|
||||
SegIndex::LoneLoose(seg) => Index::LoneLooseSeg(seg),
|
||||
SegIndex::SeqLoose(seg) => Index::SeqLooseSeg(seg),
|
||||
SegIndex::Fixed(seg) => GeometryIndex::FixedSeg(seg),
|
||||
SegIndex::LoneLoose(seg) => GeometryIndex::LoneLooseSeg(seg),
|
||||
SegIndex::SeqLoose(seg) => GeometryIndex::SeqLooseSeg(seg),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -151,11 +151,11 @@ pub enum BendIndex {
|
|||
Loose(LooseBendIndex),
|
||||
}
|
||||
|
||||
impl From<BendIndex> for Index {
|
||||
impl From<BendIndex> for GeometryIndex {
|
||||
fn from(bend: BendIndex) -> Self {
|
||||
match bend {
|
||||
BendIndex::Fixed(bend) => Index::FixedBend(bend),
|
||||
BendIndex::Loose(bend) => Index::LooseBend(bend),
|
||||
BendIndex::Fixed(bend) => GeometryIndex::FixedBend(bend),
|
||||
BendIndex::Loose(bend) => GeometryIndex::LooseBend(bend),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -177,12 +177,12 @@ pub enum WraparoundableIndex {
|
|||
LooseBend(LooseBendIndex),
|
||||
}
|
||||
|
||||
impl From<WraparoundableIndex> for Index {
|
||||
impl From<WraparoundableIndex> for GeometryIndex {
|
||||
fn from(wraparoundable: WraparoundableIndex) -> Self {
|
||||
match wraparoundable {
|
||||
WraparoundableIndex::FixedDot(dot) => Index::FixedDot(dot),
|
||||
WraparoundableIndex::FixedBend(bend) => Index::FixedBend(bend),
|
||||
WraparoundableIndex::LooseBend(bend) => Index::LooseBend(bend),
|
||||
WraparoundableIndex::FixedDot(dot) => GeometryIndex::FixedDot(dot),
|
||||
WraparoundableIndex::FixedBend(bend) => GeometryIndex::FixedBend(bend),
|
||||
WraparoundableIndex::LooseBend(bend) => GeometryIndex::LooseBend(bend),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ use petgraph::stable_graph::NodeIndex;
|
|||
|
||||
// Due to apparent limitations of enum_dispatch we're forced to import some types backwards.
|
||||
|
||||
use crate::geometry::{BendIndex, DotIndex, Index, SegIndex, WraparoundableIndex};
|
||||
use crate::geometry::{BendIndex, DotIndex, GeometryIndex, SegIndex, WraparoundableIndex};
|
||||
|
||||
#[enum_dispatch]
|
||||
pub trait GetNodeIndex {
|
||||
|
|
|
|||
111
src/layout.rs
111
src/layout.rs
|
|
@ -14,10 +14,9 @@ use crate::connectivity::{
|
|||
};
|
||||
use crate::geometry::{
|
||||
BendWeight, DotIndex, DotWeight, FixedBendIndex, FixedDotIndex, FixedDotWeight, FixedSegIndex,
|
||||
FixedSegWeight, GeometryGraph, GeometryLabel, GeometryWeight, GetComponentIndex, Index,
|
||||
LoneLooseSegIndex, LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex,
|
||||
LooseDotWeight, MakePrimitive, Retag, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight,
|
||||
WraparoundableIndex,
|
||||
FixedSegWeight, GeometryGraph, GeometryIndex, GeometryLabel, GeometryWeight, LoneLooseSegIndex,
|
||||
LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex, LooseDotWeight,
|
||||
MakePrimitive, Retag, SegWeight, SeqLooseSegIndex, SeqLooseSegWeight, WraparoundableIndex,
|
||||
};
|
||||
use crate::graph::{GenericIndex, GetNodeIndex};
|
||||
use crate::guide::Guide;
|
||||
|
|
@ -29,7 +28,7 @@ use crate::primitive::{
|
|||
use crate::segbend::Segbend;
|
||||
use crate::shape::{Shape, ShapeTrait};
|
||||
|
||||
pub type RTreeWrapper = GeomWithData<Shape, Index>;
|
||||
pub type RTreeWrapper = GeomWithData<Shape, GeometryIndex>;
|
||||
|
||||
#[enum_dispatch]
|
||||
#[derive(Error, Debug, Clone, Copy)]
|
||||
|
|
@ -47,15 +46,15 @@ pub enum LayoutException {
|
|||
// TODO add real error messages + these should eventually use Display
|
||||
#[derive(Error, Debug, Clone, Copy)]
|
||||
#[error("{0:?} infringes on {1:?}")]
|
||||
pub struct Infringement(pub Shape, pub Index);
|
||||
pub struct Infringement(pub Shape, pub GeometryIndex);
|
||||
|
||||
#[derive(Error, Debug, Clone, Copy)]
|
||||
#[error("{0:?} collides with {1:?}")]
|
||||
pub struct Collision(pub Shape, pub Index);
|
||||
pub struct Collision(pub Shape, pub GeometryIndex);
|
||||
|
||||
#[derive(Error, Debug, Clone, Copy)]
|
||||
#[error("{1:?} is already connected to net {0}")]
|
||||
pub struct AlreadyConnected(pub i64, pub Index);
|
||||
pub struct AlreadyConnected(pub i64, pub GeometryIndex);
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct Layout {
|
||||
|
|
@ -99,12 +98,12 @@ impl Layout {
|
|||
}
|
||||
|
||||
#[debug_ensures(self.geometry.node_count() == old(self.geometry.node_count() - 1))]
|
||||
fn remove(&mut self, index: Index) {
|
||||
fn remove(&mut self, node: GeometryIndex) {
|
||||
// Unnecessary retag. It should be possible to elide it.
|
||||
let weight = *self.geometry.node_weight(index.node_index()).unwrap();
|
||||
let weight = *self.geometry.node_weight(node.node_index()).unwrap();
|
||||
|
||||
self.remove_from_rtree(weight.retag(index.node_index()));
|
||||
self.geometry.remove_node(index.node_index());
|
||||
self.remove_from_rtree(weight.retag(node.node_index()));
|
||||
self.geometry.remove_node(node.node_index());
|
||||
}
|
||||
|
||||
// TODO: This method shouldn't be public.
|
||||
|
|
@ -149,10 +148,10 @@ impl Layout {
|
|||
fn add_dot_infringably<W: DotWeight>(
|
||||
&mut self,
|
||||
weight: W,
|
||||
infringables: &[Index],
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<GenericIndex<W>, Infringement>
|
||||
where
|
||||
GenericIndex<W>: Into<Index> + Copy,
|
||||
GenericIndex<W>: Into<GeometryIndex> + Copy,
|
||||
{
|
||||
let dot = GenericIndex::<W>::new(self.geometry.add_node(weight.into()));
|
||||
|
||||
|
|
@ -228,7 +227,7 @@ 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 inner_bow_and_outer_bow(&self, bend: LooseBendIndex) -> Vec<Index> {
|
||||
fn inner_bow_and_outer_bow(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
||||
let bend_primitive = self.primitive(bend);
|
||||
let mut v = vec![];
|
||||
|
||||
|
|
@ -248,7 +247,7 @@ 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 inner_bow_and_outer_bows(&self, bend: LooseBendIndex) -> Vec<Index> {
|
||||
fn inner_bow_and_outer_bows(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
||||
let bend_primitive = self.primitive(bend);
|
||||
let mut v = vec![];
|
||||
|
||||
|
|
@ -271,7 +270,7 @@ 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 this_and_wraparound_bow(&self, around: WraparoundableIndex) -> Vec<Index> {
|
||||
fn this_and_wraparound_bow(&self, around: WraparoundableIndex) -> Vec<GeometryIndex> {
|
||||
match around {
|
||||
WraparoundableIndex::FixedDot(dot) => {
|
||||
let mut v = vec![around.into()];
|
||||
|
|
@ -300,8 +299,8 @@ impl Layout {
|
|||
// XXX: Move this to primitives?
|
||||
#[debug_ensures(self.geometry.node_count() == old(self.geometry.node_count()))]
|
||||
#[debug_ensures(self.geometry.edge_count() == old(self.geometry.edge_count()))]
|
||||
fn bow(&self, bend: LooseBendIndex) -> Vec<Index> {
|
||||
let mut bow: Vec<Index> = vec![];
|
||||
fn bow(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
||||
let mut bow: Vec<GeometryIndex> = vec![];
|
||||
bow.push(bend.into());
|
||||
|
||||
let ends = self.primitive(bend).ends();
|
||||
|
|
@ -321,7 +320,7 @@ 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 outer_bows(&self, bend: LooseBendIndex) -> Vec<Index> {
|
||||
fn outer_bows(&self, bend: LooseBendIndex) -> Vec<GeometryIndex> {
|
||||
let mut outer_bows = vec![];
|
||||
let mut rail = bend;
|
||||
|
||||
|
|
@ -473,7 +472,7 @@ impl Layout {
|
|||
dot_weight: LooseDotWeight,
|
||||
seg_weight: SeqLooseSegWeight,
|
||||
bend_weight: LooseBendWeight,
|
||||
infringables: &[Index],
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<Segbend, LayoutException> {
|
||||
let seg_to = self.add_dot_infringably(dot_weight, infringables)?;
|
||||
let seg = self
|
||||
|
|
@ -541,10 +540,10 @@ impl Layout {
|
|||
from: impl GetNodeIndex,
|
||||
to: impl GetNodeIndex,
|
||||
weight: W,
|
||||
infringables: &[Index],
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<GenericIndex<W>, Infringement>
|
||||
where
|
||||
GenericIndex<W>: Into<Index> + Copy,
|
||||
GenericIndex<W>: Into<GeometryIndex> + Copy,
|
||||
{
|
||||
let seg = GenericIndex::<W>::new(self.geometry.add_node(weight.into()));
|
||||
|
||||
|
|
@ -565,12 +564,12 @@ impl Layout {
|
|||
&mut self,
|
||||
from: FixedDotIndex,
|
||||
to: FixedDotIndex,
|
||||
around: Index,
|
||||
around: GeometryIndex,
|
||||
weight: FixedBendWeight,
|
||||
) -> Result<FixedBendIndex, ()> {
|
||||
match around {
|
||||
Index::FixedDot(core) => self.add_core_bend(from, to, core, weight),
|
||||
Index::FixedBend(around) => self.add_outer_bend(from, to, around, weight),
|
||||
GeometryIndex::FixedDot(core) => self.add_core_bend(from, to, core, weight),
|
||||
GeometryIndex::FixedBend(around) => self.add_outer_bend(from, to, around, weight),
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}*/
|
||||
|
|
@ -586,7 +585,7 @@ impl Layout {
|
|||
to: LooseDotIndex,
|
||||
around: WraparoundableIndex,
|
||||
weight: LooseBendWeight,
|
||||
infringables: &[Index],
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<LooseBendIndex, LayoutException> {
|
||||
// It makes no sense to wrap something around or under one of its connectables.
|
||||
let net = self
|
||||
|
|
@ -632,10 +631,10 @@ impl Layout {
|
|||
to: impl GetNodeIndex,
|
||||
core: FixedDotIndex,
|
||||
weight: W,
|
||||
infringables: &[Index],
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<LooseBendIndex, Infringement>
|
||||
where
|
||||
GenericIndex<W>: Into<Index> + Copy,
|
||||
GenericIndex<W>: Into<GeometryIndex> + Copy,
|
||||
{
|
||||
let bend = LooseBendIndex::new(self.geometry.add_node(weight.into()));
|
||||
|
||||
|
|
@ -664,7 +663,7 @@ impl Layout {
|
|||
to: impl GetNodeIndex,
|
||||
inner: impl GetNodeIndex,
|
||||
weight: W,
|
||||
infringables: &[Index],
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<LooseBendIndex, Infringement> {
|
||||
let core = *self
|
||||
.geometry
|
||||
|
|
@ -730,17 +729,17 @@ impl Layout {
|
|||
#[debug_ensures(ret.is_err() -> self.geometry.node_count() == old(self.geometry.node_count() - 1))]
|
||||
fn fail_and_remove_if_infringes_except(
|
||||
&mut self,
|
||||
index: Index,
|
||||
except: &[Index],
|
||||
node: GeometryIndex,
|
||||
except: &[GeometryIndex],
|
||||
) -> Result<(), Infringement> {
|
||||
if let Some(infringement) = self.detect_infringement_except(index, except) {
|
||||
self.remove(index);
|
||||
if let Some(infringement) = self.detect_infringement_except(node, except) {
|
||||
self.remove(node);
|
||||
return Err(infringement);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn nodes(&self) -> impl Iterator<Item = Index> + '_ {
|
||||
pub fn nodes(&self) -> impl Iterator<Item = GeometryIndex> + '_ {
|
||||
self.rtree.iter().map(|wrapper| wrapper.data)
|
||||
}
|
||||
|
||||
|
|
@ -752,7 +751,7 @@ impl Layout {
|
|||
self.geometry.node_count()
|
||||
}
|
||||
|
||||
fn node_indices(&self) -> impl Iterator<Item = Index> + '_ {
|
||||
fn node_indices(&self) -> impl Iterator<Item = GeometryIndex> + '_ {
|
||||
self.rtree.iter().map(|wrapper| wrapper.data)
|
||||
}
|
||||
}
|
||||
|
|
@ -773,7 +772,7 @@ impl Layout {
|
|||
&mut self,
|
||||
dot: LooseDotIndex,
|
||||
to: Point,
|
||||
infringables: &[Index],
|
||||
infringables: &[GeometryIndex],
|
||||
) -> Result<(), Infringement> {
|
||||
self.primitive(dot)
|
||||
.seg()
|
||||
|
|
@ -812,14 +811,18 @@ 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 detect_infringement_except(&self, index: Index, except: &[Index]) -> Option<Infringement> {
|
||||
let shape = index.primitive(self).shape();
|
||||
fn detect_infringement_except(
|
||||
&self,
|
||||
node: GeometryIndex,
|
||||
except: &[GeometryIndex],
|
||||
) -> Option<Infringement> {
|
||||
let shape = node.primitive(self).shape();
|
||||
|
||||
self.rtree
|
||||
.locate_in_envelope_intersecting(&RTreeObject::envelope(&shape))
|
||||
.filter(|wrapper| {
|
||||
let other_index = wrapper.data;
|
||||
!index.primitive(self).connectable(other_index)
|
||||
!node.primitive(self).connectable(other_index)
|
||||
})
|
||||
.filter(|wrapper| !except.contains(&wrapper.data))
|
||||
.filter(|wrapper| shape.intersects(wrapper.geom()))
|
||||
|
|
@ -831,14 +834,14 @@ impl Layout {
|
|||
// TODO: Collision and infringement are the same for now. Change this.
|
||||
#[debug_ensures(self.geometry.node_count() == old(self.geometry.node_count()))]
|
||||
#[debug_ensures(self.geometry.edge_count() == old(self.geometry.edge_count()))]
|
||||
fn detect_collision(&self, index: Index) -> Option<Collision> {
|
||||
let shape = index.primitive(self).shape();
|
||||
fn detect_collision(&self, node: GeometryIndex) -> Option<Collision> {
|
||||
let shape = node.primitive(self).shape();
|
||||
|
||||
self.rtree
|
||||
.locate_in_envelope_intersecting(&RTreeObject::envelope(&shape))
|
||||
.filter(|wrapper| {
|
||||
let other_index = wrapper.data;
|
||||
!index.primitive(self).connectable(other_index)
|
||||
!node.primitive(self).connectable(other_index)
|
||||
})
|
||||
.filter(|wrapper| shape.intersects(wrapper.geom()))
|
||||
.map(|wrapper| wrapper.data)
|
||||
|
|
@ -848,16 +851,16 @@ 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(&mut self, index: Index) {
|
||||
let shape = index.primitive(self).shape();
|
||||
self.rtree.insert(RTreeWrapper::new(shape, index));
|
||||
fn insert_into_rtree(&mut self, node: GeometryIndex) {
|
||||
let shape = node.primitive(self).shape();
|
||||
self.rtree.insert(RTreeWrapper::new(shape, node));
|
||||
}
|
||||
|
||||
#[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(&mut self, index: Index) {
|
||||
let shape = index.primitive(self).shape();
|
||||
let removed_element = self.rtree.remove(&RTreeWrapper::new(shape, index));
|
||||
fn remove_from_rtree(&mut self, node: GeometryIndex) {
|
||||
let shape = node.primitive(self).shape();
|
||||
let removed_element = self.rtree.remove(&RTreeWrapper::new(shape, node));
|
||||
debug_assert!(removed_element.is_some());
|
||||
}
|
||||
}
|
||||
|
|
@ -877,15 +880,15 @@ impl Layout {
|
|||
|
||||
#[debug_ensures(self.geometry.node_count() == old(self.geometry.node_count()))]
|
||||
#[debug_ensures(self.geometry.edge_count() == old(self.geometry.edge_count()))]
|
||||
pub fn primitive<W>(&self, index: GenericIndex<W>) -> GenericPrimitive<W> {
|
||||
GenericPrimitive::new(index, self)
|
||||
pub fn primitive<W>(&self, node: GenericIndex<W>) -> GenericPrimitive<W> {
|
||||
GenericPrimitive::new(node, self)
|
||||
}
|
||||
|
||||
fn test_envelopes(&self) -> bool {
|
||||
!self.rtree.iter().any(|wrapper| {
|
||||
let index = wrapper.data;
|
||||
let shape = index.primitive(self).shape();
|
||||
let wrapper = RTreeWrapper::new(shape, index);
|
||||
let node = wrapper.data;
|
||||
let shape = node.primitive(self).shape();
|
||||
let wrapper = RTreeWrapper::new(shape, node);
|
||||
!self
|
||||
.rtree
|
||||
.locate_in_envelope(&RTreeObject::envelope(&shape))
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ mod triangulation;
|
|||
|
||||
use draw::DrawException;
|
||||
use geo::point;
|
||||
use geometry::{FixedDotIndex, FixedSegWeight, Index, LooseDotIndex, MakePrimitive};
|
||||
use geometry::{FixedDotIndex, FixedSegWeight, GeometryIndex, LooseDotIndex, MakePrimitive};
|
||||
use layout::{Infringement, Layout, LayoutException};
|
||||
use mesh::{Mesh, MeshEdgeReference, VertexIndex};
|
||||
use petgraph::visit::{EdgeRef, IntoEdgeReferences};
|
||||
|
|
@ -582,7 +582,7 @@ fn render_times(
|
|||
mut mesh: Option<Mesh>,
|
||||
path: &[VertexIndex],
|
||||
ghosts: &[Shape],
|
||||
highlighteds: &[Index],
|
||||
highlighteds: &[GeometryIndex],
|
||||
times: i64,
|
||||
) {
|
||||
let mut i = 0;
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ use spade::{HasPosition, InsertionError, Point2};
|
|||
use crate::primitive::{GetCore, Primitive};
|
||||
use crate::triangulation::TriangulationEdgeReference;
|
||||
use crate::{
|
||||
geometry::{FixedBendIndex, FixedDotIndex, Index, LooseBendIndex, MakePrimitive},
|
||||
geometry::{FixedBendIndex, FixedDotIndex, GeometryIndex, LooseBendIndex, MakePrimitive},
|
||||
graph::GetNodeIndex,
|
||||
layout::Layout,
|
||||
primitive::MakeShape,
|
||||
|
|
@ -84,14 +84,14 @@ impl Mesh {
|
|||
let center = node.primitive(layout).shape().center();
|
||||
|
||||
match node {
|
||||
Index::FixedDot(dot) => {
|
||||
GeometryIndex::FixedDot(dot) => {
|
||||
self.triangulation.add_vertex(TriangulationWeight {
|
||||
vertex: dot.into(),
|
||||
rails: vec![],
|
||||
pos: center,
|
||||
})?;
|
||||
}
|
||||
Index::FixedBend(bend) => {
|
||||
GeometryIndex::FixedBend(bend) => {
|
||||
self.triangulation.add_vertex(TriangulationWeight {
|
||||
vertex: bend.into(),
|
||||
rails: vec![],
|
||||
|
|
@ -105,7 +105,7 @@ impl Mesh {
|
|||
for node in layout.nodes() {
|
||||
// Add rails as vertices. This is how the mesh differs from the triangulation.
|
||||
match node {
|
||||
Index::LooseBend(bend) => {
|
||||
GeometryIndex::LooseBend(bend) => {
|
||||
self.triangulation
|
||||
.weight_mut(layout.primitive(bend).core().into())
|
||||
.rails
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ use petgraph::Direction::{Incoming, Outgoing};
|
|||
|
||||
use crate::connectivity::GetNet;
|
||||
use crate::geometry::{
|
||||
DotIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight, FixedSegWeight, GeometryLabel,
|
||||
GeometryWeight, GetBandIndex, GetComponentIndex, GetOffset, GetWidth, Index,
|
||||
DotIndex, FixedBendWeight, FixedDotIndex, FixedDotWeight, FixedSegWeight, GeometryIndex,
|
||||
GeometryLabel, GeometryWeight, GetBandIndex, GetComponentIndex, GetOffset, GetWidth,
|
||||
LoneLooseSegWeight, LooseBendIndex, LooseBendWeight, LooseDotIndex, LooseDotWeight,
|
||||
MakePrimitive, Retag, SeqLooseSegIndex, SeqLooseSegWeight,
|
||||
};
|
||||
|
|
@ -23,9 +23,9 @@ pub trait GetLayout {
|
|||
|
||||
#[enum_dispatch]
|
||||
pub trait GetConnectable: GetNet + GetLayout {
|
||||
fn connectable(&self, index: Index) -> bool {
|
||||
fn connectable(&self, node: GeometryIndex) -> bool {
|
||||
let this = self.net();
|
||||
let other = index.primitive(self.layout()).net();
|
||||
let other = node.primitive(self.layout()).net();
|
||||
|
||||
(this == other) || this == -1 || other == -1
|
||||
}
|
||||
|
|
@ -262,8 +262,8 @@ impl<'a, W> GenericPrimitive<'a, W> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a, W> GetInterior<Index> for GenericPrimitive<'a, W> {
|
||||
fn interior(&self) -> Vec<Index> {
|
||||
impl<'a, W> GetInterior<GeometryIndex> for GenericPrimitive<'a, W> {
|
||||
fn interior(&self) -> Vec<GeometryIndex> {
|
||||
vec![self.tagged_weight().retag(self.index.node_index())]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::{
|
||||
geometry::{Index, LooseBendIndex, LooseDotIndex, SeqLooseSegIndex},
|
||||
geometry::{GeometryIndex, LooseBendIndex, LooseDotIndex, SeqLooseSegIndex},
|
||||
layout::Layout,
|
||||
primitive::{GetEnds, GetInterior, GetOtherEnd, LooseBend, LooseDot},
|
||||
};
|
||||
|
|
@ -20,8 +20,8 @@ impl Segbend {
|
|||
}
|
||||
}
|
||||
|
||||
impl GetInterior<Index> for Segbend {
|
||||
fn interior(&self) -> Vec<Index> {
|
||||
impl GetInterior<GeometryIndex> for Segbend {
|
||||
fn interior(&self) -> Vec<GeometryIndex> {
|
||||
vec![self.bend.into(), self.dot.into(), self.seg.into()]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue