geometry_model/
polyhedral_surface.rs1use alloc::vec::Vec;
7
8use geometry_tag::PolyhedralSurfaceTag;
9use geometry_trait::{Geometry, Polygon, PolyhedralSurface as PolyhedralSurfaceTrait};
10
11#[derive(Debug, Clone, PartialEq)]
18#[repr(transparent)]
19pub struct PolyhedralSurface<Pg: Polygon>(pub Vec<Pg>);
20
21impl<Pg: Polygon> PolyhedralSurface<Pg> {
22 #[inline]
27 #[must_use]
28 pub const fn new() -> Self {
29 Self(Vec::new())
30 }
31
32 #[inline]
37 #[must_use]
38 pub const fn from_vec(faces: Vec<Pg>) -> Self {
39 Self(faces)
40 }
41
42 #[inline]
44 pub fn push(&mut self, face: Pg) {
45 self.0.push(face);
46 }
47}
48
49impl<Pg: Polygon> Default for PolyhedralSurface<Pg> {
50 #[inline]
51 fn default() -> Self {
52 Self::new()
53 }
54}
55
56impl<Pg: Polygon> Geometry for PolyhedralSurface<Pg> {
57 type Kind = PolyhedralSurfaceTag;
58 type Point = Pg::Point;
59}
60
61impl<Pg: Polygon> PolyhedralSurfaceTrait for PolyhedralSurface<Pg> {
62 type Face = Pg;
63
64 #[inline]
65 fn faces(&self) -> impl ExactSizeIterator<Item = &Self::Face> {
66 self.0.iter()
67 }
68}