ndgrid/traits/topology.rs
1//! The topology of an entity
2use std::{fmt::Debug, hash::Hash};
3
4/// The topology of an entity
5pub trait Topology {
6 /// Entity type enum
7 type EntityDescriptor: Debug + PartialEq + Eq + Clone + Copy + Hash;
8
9 /// Entity iterator
10 type EntityIndexIter<'a>: Iterator<Item = usize>
11 where
12 Self: 'a;
13
14 /// Entity iterator
15 type ConnectedEntityIndexIter<'a>: Iterator<Item = usize>
16 where
17 Self: 'a;
18
19 /// Iterator over indices of connected entities.
20 ///
21 /// This iterator returns all entities of a given type connected to this entity.
22 fn connected_entity_iter(
23 &self,
24 entity_type: Self::EntityDescriptor,
25 ) -> Self::ConnectedEntityIndexIter<'_>;
26
27 /// Iterator over sub-entities
28 ///
29 /// This iterator iterates over all subentities of a given type. It returns the index of the corresponding entity.
30 /// This index can then be used with the [Grid::entity](crate::traits::Grid::entity) to return the corresponding actual entity.
31 fn sub_entity_iter(&self, entity_type: Self::EntityDescriptor) -> Self::EntityIndexIter<'_>;
32
33 /// An index of a sub-entity of this entity
34 ///
35 /// Assume that `e` is a triangle. Then calling `e.sub_entity(ReferenceCellType::Point, 0)` returns the entity index
36 /// of the first vertex of that entity.
37 fn sub_entity(&self, entity_type: Self::EntityDescriptor, index: usize) -> usize;
38
39 /// A 32-bit integer that encodes the orientation differences between this entity and the corresponding reference entity
40 fn orientation(&self) -> i32;
41}