census.rs

928 B · rust · 29 lines

1use super::graph::edge_graph;2use super::models::CellNd;3use mrlycore::errors::Result;4use mrlynum::census::{count, exposed};56/// Counts the filled sites of the cell.7pub fn fills<const N: usize>(cell: &CellNd<N>) -> usize {8    count(cell.types(), 1)9}1011/// Counts the empty sites of the cell.12pub fn voids<const N: usize>(cell: &CellNd<N>) -> usize {13    count(cell.types(), 0)14}1516/// Counts the faces of filled sites open to emptiness or the border.17pub fn exposure<const N: usize>(cell: &CellNd<N>) -> u128 {18    exposed(cell.types())19}2021/// Counts the distinct corners the filled sites touch, the edge graph's nodes.22pub fn vertices<const N: usize>(cell: &CellNd<N>) -> Result<usize> {23    Ok(edge_graph(cell)?.nodes.len())24}2526/// Counts the distinct unit edges the filled sites carry, the edge graph's branches.27pub fn edges<const N: usize>(cell: &CellNd<N>) -> Result<usize> {28    Ok(edge_graph(cell)?.branches.len())29}