feat(geometry/geometry): provide lookup of all rails around a core

This commit is contained in:
Ellen Emilia Anna Zscheile 2025-05-02 14:31:18 +02:00
parent 792f9b56ea
commit 48efd5d3d9
1 changed files with 5 additions and 1 deletions

View File

@ -506,9 +506,13 @@ impl<
> Geometry<PW, DW, SW, BW, CW, Cel, PI, DI, SI, BI>
{
pub fn first_rail(&self, node: NodeIndex<usize>) -> Option<BI> {
self.all_rails(node).next()
}
pub fn all_rails(&self, node: NodeIndex<usize>) -> impl Iterator<Item = BI> + '_ {
self.graph
.edges_directed(node, Incoming)
.find(|edge| matches!(edge.weight(), GeometryLabel::Core))
.filter(|edge| matches!(edge.weight(), GeometryLabel::Core))
.map(|edge| {
self.primitive_index(edge.source())
.try_into()