mirror of https://codeberg.org/topola/topola.git
geometry,layout,drawing: add accessor for node's groupings
This commit is contained in:
parent
9feb32955c
commit
13dd000dba
|
|
@ -887,4 +887,8 @@ impl<GW: Copy, R: RulesTrait> GroupingManagerTrait<GW, GenericIndex<GW>> for Dra
|
||||||
self.geometry_with_rtree
|
self.geometry_with_rtree
|
||||||
.assign_to_grouping(primitive, grouping);
|
.assign_to_grouping(primitive, grouping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn groupings<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<GW>> {
|
||||||
|
self.geometry_with_rtree.groupings(node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -500,4 +500,18 @@ impl<
|
||||||
GeometryLabel::Grouping,
|
GeometryLabel::Grouping,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn groupings<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<GW>> {
|
||||||
|
self.graph
|
||||||
|
.neighbors(node.node_index())
|
||||||
|
.filter(move |ni| {
|
||||||
|
matches!(
|
||||||
|
self.graph
|
||||||
|
.edge_weight(self.graph.find_edge(node.node_index(), *ni).unwrap())
|
||||||
|
.unwrap(),
|
||||||
|
GeometryLabel::Grouping
|
||||||
|
)
|
||||||
|
})
|
||||||
|
.map(|ni| GenericIndex::new(ni))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,4 +4,5 @@ pub trait GroupingManagerTrait<GW: Copy, GI: GetNodeIndex + Copy> {
|
||||||
fn add_grouping(&mut self, weight: GW) -> GenericIndex<GW>;
|
fn add_grouping(&mut self, weight: GW) -> GenericIndex<GW>;
|
||||||
fn remove_grouping(&mut self, grouping: GenericIndex<GW>);
|
fn remove_grouping(&mut self, grouping: GenericIndex<GW>);
|
||||||
fn assign_to_grouping<W>(&mut self, node: GenericIndex<W>, grouping: GenericIndex<GW>);
|
fn assign_to_grouping<W>(&mut self, node: GenericIndex<W>, grouping: GenericIndex<GW>);
|
||||||
|
fn groupings<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<GW>>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -410,4 +410,8 @@ impl<
|
||||||
fn assign_to_grouping<W>(&mut self, primitive: GenericIndex<W>, grouping: GenericIndex<GW>) {
|
fn assign_to_grouping<W>(&mut self, primitive: GenericIndex<W>, grouping: GenericIndex<GW>) {
|
||||||
self.geometry.assign_to_grouping(primitive, grouping);
|
self.geometry.assign_to_grouping(primitive, grouping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn groupings<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<GW>> {
|
||||||
|
self.geometry.groupings(node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -233,4 +233,11 @@ impl<R: RulesTrait> GroupingManagerTrait<ZoneWeight, GenericIndex<ZoneWeight>> f
|
||||||
) {
|
) {
|
||||||
self.drawing.assign_to_grouping(primitive, grouping);
|
self.drawing.assign_to_grouping(primitive, grouping);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn groupings<W>(
|
||||||
|
&self,
|
||||||
|
node: GenericIndex<W>,
|
||||||
|
) -> impl Iterator<Item = GenericIndex<ZoneWeight>> {
|
||||||
|
self.drawing.groupings(node)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue