use alloc::vec::Vec;
use geometry_tag::PolyhedralSurfaceTag;
use geometry_trait::{Geometry, Polygon, PolyhedralSurface as PolyhedralSurfaceTrait};
#[derive(Debug, Clone, PartialEq)]
#[repr(transparent)]
pub struct PolyhedralSurface<Pg: Polygon>(pub Vec<Pg>);
impl<Pg: Polygon> PolyhedralSurface<Pg> {
#[inline]
#[must_use]
pub const fn new() -> Self {
Self(Vec::new())
}
#[inline]
#[must_use]
pub const fn from_vec(faces: Vec<Pg>) -> Self {
Self(faces)
}
#[inline]
pub fn push(&mut self, face: Pg) {
self.0.push(face);
}
}
impl<Pg: Polygon> Default for PolyhedralSurface<Pg> {
#[inline]
fn default() -> Self {
Self::new()
}
}
impl<Pg: Polygon> Geometry for PolyhedralSurface<Pg> {
type Kind = PolyhedralSurfaceTag;
type Point = Pg::Point;
}
impl<Pg: Polygon> PolyhedralSurfaceTrait for PolyhedralSurface<Pg> {
type Face = Pg;
#[inline]
fn faces(&self) -> impl ExactSizeIterator<Item = &Self::Face> {
self.0.iter()
}
}