census.rs
1.0 kB · rust · 36 lines
1use super::graph::edge_graph;2use super::models::CellNd;3use crate::core::error::Result;45/// Counts the filled sites of the cell.6pub fn fills<const N: usize>(cell: &CellNd<N>) -> usize {7 cell.types().count(1)8}910/// Counts the empty sites of the cell.11pub fn voids<const N: usize>(cell: &CellNd<N>) -> usize {12 cell.types().count(0)13}1415/// Counts the faces of filled sites open to emptiness or the border.16pub fn exposure<const N: usize>(cell: &CellNd<N>) -> u128 {17 cell.types().exposed()18}1920/// Counts the distinct corners the filled sites touch, the edge graph's nodes.21///22/// # Errors23///24/// Errors when the cell is neither two- nor three-dimensional.25pub fn vertices<const N: usize>(cell: &CellNd<N>) -> Result<usize> {26 Ok(edge_graph(cell)?.nodes.len())27}2829/// Counts the distinct unit edges the filled sites carry, the edge graph's branches.30///31/// # Errors32///33/// Errors when the cell is neither two- nor three-dimensional.34pub fn edges<const N: usize>(cell: &CellNd<N>) -> Result<usize> {35 Ok(edge_graph(cell)?.branches.len())36}