From 8280560b02d2863b2e4c48bb12e42b5cf41bd3c4 Mon Sep 17 00:00:00 2001 From: Ellen Emilia Anna Zscheile Date: Thu, 9 Jan 2025 20:20:57 +0100 Subject: [PATCH] feat(geometry): add easy way to detect if primitive is part of compound --- src/geometry/geometry.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/geometry/geometry.rs b/src/geometry/geometry.rs index 4eb2192..0a74889 100644 --- a/src/geometry/geometry.rs +++ b/src/geometry/geometry.rs @@ -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> { + self.graph + .edges_directed(primitive.petgraph_index(), Outgoing) + .find(|ei| ei.weight() == &GeometryLabel::Compound) + .map(|ei| GenericIndex::new(ei.source())) + } } impl ManageCompounds>