mirror of https://codeberg.org/topola/topola.git
geometry: make compound weights accessible from `CompoundManagerTrait`
This commit is contained in:
parent
f2569c5167
commit
e5bae501ad
|
|
@ -888,6 +888,10 @@ impl<CW: Copy, R: RulesTrait> CompoundManagerTrait<CW, GenericIndex<CW>> for Dra
|
||||||
.add_to_compound(primitive, compound);
|
.add_to_compound(primitive, compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compound_weight(&self, compound: GenericIndex<CW>) -> CW {
|
||||||
|
self.geometry_with_rtree.compound_weight(compound)
|
||||||
|
}
|
||||||
|
|
||||||
fn compounds<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<CW>> {
|
fn compounds<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<CW>> {
|
||||||
self.geometry_with_rtree.compounds(node)
|
self.geometry_with_rtree.compounds(node)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,8 @@ macro_rules! impl_loose_weight {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: This enum shouldn't exist: we shouldn't be carrying the tag around like this. Instead we
|
||||||
|
// should be getting it from the graph when it's needed.
|
||||||
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
#[enum_dispatch(GetNodeIndex, MakePrimitive)]
|
||||||
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Hash, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum PrimitiveIndex {
|
pub enum PrimitiveIndex {
|
||||||
|
|
|
||||||
|
|
@ -4,5 +4,6 @@ pub trait CompoundManagerTrait<CW: Copy, GI: GetNodeIndex + Copy> {
|
||||||
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW>;
|
fn add_compound(&mut self, weight: CW) -> GenericIndex<CW>;
|
||||||
fn remove_compound(&mut self, compound: GenericIndex<CW>);
|
fn remove_compound(&mut self, compound: GenericIndex<CW>);
|
||||||
fn add_to_compound<W>(&mut self, node: GenericIndex<W>, compound: GenericIndex<CW>);
|
fn add_to_compound<W>(&mut self, node: GenericIndex<W>, compound: GenericIndex<CW>);
|
||||||
|
fn compound_weight(&self, node: GenericIndex<CW>) -> CW;
|
||||||
fn compounds<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<CW>>;
|
fn compounds<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<CW>>;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -507,6 +507,16 @@ impl<
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compound_weight(&self, compound: GenericIndex<CW>) -> CW {
|
||||||
|
if let GenericNode::Compound(weight) =
|
||||||
|
*self.graph.node_weight(compound.node_index()).unwrap()
|
||||||
|
{
|
||||||
|
weight
|
||||||
|
} else {
|
||||||
|
unreachable!()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn compounds<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<CW>> {
|
fn compounds<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<CW>> {
|
||||||
self.graph
|
self.graph
|
||||||
.neighbors(node.node_index())
|
.neighbors(node.node_index())
|
||||||
|
|
|
||||||
|
|
@ -408,6 +408,10 @@ impl<
|
||||||
self.geometry.add_to_compound(primitive, compound);
|
self.geometry.add_to_compound(primitive, compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compound_weight(&self, compound: GenericIndex<CW>) -> CW {
|
||||||
|
self.geometry.compound_weight(compound)
|
||||||
|
}
|
||||||
|
|
||||||
fn compounds<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<CW>> {
|
fn compounds<W>(&self, node: GenericIndex<W>) -> impl Iterator<Item = GenericIndex<CW>> {
|
||||||
self.geometry.compounds(node)
|
self.geometry.compounds(node)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,10 @@ impl<R: RulesTrait> CompoundManagerTrait<ZoneWeight, GenericIndex<ZoneWeight>> f
|
||||||
self.drawing.add_to_compound(primitive, compound);
|
self.drawing.add_to_compound(primitive, compound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn compound_weight(&self, compound: GenericIndex<ZoneWeight>) -> ZoneWeight {
|
||||||
|
self.drawing.compound_weight(compound)
|
||||||
|
}
|
||||||
|
|
||||||
fn compounds<W>(
|
fn compounds<W>(
|
||||||
&self,
|
&self,
|
||||||
node: GenericIndex<W>,
|
node: GenericIndex<W>,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue