mirror of https://codeberg.org/topola/topola.git
feat(geometry): add easy way to detect if primitive is part of compound
This commit is contained in:
parent
a16eba8891
commit
8280560b02
|
|
@ -8,7 +8,7 @@ use geo::Point;
|
|||
use petgraph::{
|
||||
stable_graph::{NodeIndex, StableDiGraph},
|
||||
visit::EdgeRef,
|
||||
Direction::{self, Incoming},
|
||||
Direction::{self, Incoming, Outgoing},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
@ -570,6 +570,13 @@ impl<
|
|||
})
|
||||
.map(|ni| self.primitive_weight(ni).retag(ni))
|
||||
}
|
||||
|
||||
pub fn is_part_of_any_compound(&self, primitive: PI) -> Option<GenericIndex<CW>> {
|
||||
self.graph
|
||||
.edges_directed(primitive.petgraph_index(), Outgoing)
|
||||
.find(|ei| ei.weight() == &GeometryLabel::Compound)
|
||||
.map(|ei| GenericIndex::new(ei.source()))
|
||||
}
|
||||
}
|
||||
|
||||
impl<PW, DW, SW, BW, CW: Copy, PI, DI, SI, BI> ManageCompounds<CW, GenericIndex<CW>>
|
||||
|
|
|
|||
Loading…
Reference in New Issue