feat(layout): center_of_high_level_node (for topological navmesh generation)

This commit is contained in:
Ellen Emilia Anna Zscheile 2025-01-30 15:34:06 +01:00
parent 2fac10a8d6
commit 3c3c1d9b42
1 changed files with 31 additions and 0 deletions

View File

@ -336,6 +336,37 @@ impl<R: AccessRules> Layout<R> {
} }
} }
/// Checks if a node is "high-level", and if yes, returns its center
pub fn center_of_high_level_node(&self, node: NodeIndex) -> Option<Point> {
match node {
NodeIndex::Primitive(primitive) => {
use crate::drawing::{
graph::MakePrimitive,
primitive::{GetWeight, Primitive},
};
use crate::geometry::{compound::ManageCompounds, GetSetPos};
if self
.drawing()
.geometry()
.compounds(GenericIndex::<()>::new(primitive.petgraph_index()))
.next()
.is_some()
{
return None;
}
match primitive.primitive(self.drawing()) {
Primitive::FixedDot(dot) => Some(dot.weight().pos()),
// Primitive::LooseDot(dot) => Some(dot.weight().pos()),
_ => None,
}
}
NodeIndex::Compound(cwidx) => {
use crate::geometry::shape::AccessShape;
Some(self.node_shape(node).center())
}
}
}
pub fn rules(&self) -> &R { pub fn rules(&self) -> &R {
self.drawing.rules() self.drawing.rules()
} }