procedural_modelling/extensions/nalgebra/
mesh_nd.rs

1use crate::{
2    halfedge::{
3        HalfEdgeFaceImpl, HalfEdgeImpl, HalfEdgeImplMeshType, HalfEdgeMeshImpl, HalfEdgeVertexImpl,
4    },
5    mesh::{
6        EmptyEdgePayload, EmptyFacePayload, EmptyMeshPayload, EuclideanMeshType, MeshType,
7        MeshType3D, MeshTypeHalfEdge,
8    },
9};
10
11use super::{NdAffine, NdRotate, Polygon2d, VecN, VertexPayloadPNU};
12
13/// A mesh type for nalgebra with
14/// - nd vertices,
15/// - usize indices,
16/// - no face or edge payload,
17/// - f64 vertex positions, normals, and uv coordinates
18#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
19pub struct MeshTypeNd64PNU<const D: usize>;
20
21/// 2d variant of MeshTypeNd64PNU
22pub type MeshType2d64PNU = MeshTypeNd64PNU<2>;
23/// 3d variant of MeshTypeNd64PNU
24pub type MeshType3d64PNU = MeshTypeNd64PNU<3>;
25/// 4d variant of MeshTypeNd64PNU
26pub type MeshType4d64PNU = MeshTypeNd64PNU<4>;
27
28impl<const D: usize> MeshType for MeshTypeNd64PNU<D> {
29    type E = usize;
30    type V = usize;
31    type F = usize;
32    type EP = EmptyEdgePayload<Self>;
33    type VP = VertexPayloadPNU<f64, D>;
34    type FP = EmptyFacePayload<Self>;
35    type MP = EmptyMeshPayload<Self>;
36    type Mesh = MeshNd64<D>;
37    type Face = HalfEdgeFaceImpl<Self>;
38    type Edge = HalfEdgeImpl<Self>;
39    type Vertex = HalfEdgeVertexImpl<Self>;
40}
41impl<const D: usize> EuclideanMeshType<D> for MeshTypeNd64PNU<D> {
42    type S = f64;
43    type Vec = VecN<f64, D>;
44    type Vec2 = VecN<f64, 2>;
45    type Trans = NdAffine<f64, D>;
46    type Rot = NdRotate<f64, D>;
47    type Poly = Polygon2d<f64>;
48}
49impl<const D: usize> HalfEdgeImplMeshType for MeshTypeNd64PNU<D> {}
50impl<const D: usize> MeshTypeHalfEdge for MeshTypeNd64PNU<D> {}
51impl MeshType3D for MeshTypeNd64PNU<3> {}
52
53/// A mesh with
54/// - nalgebra nd vertices,
55/// - usize indices,
56/// - f64 positions, normals, and uv coordinates
57pub type MeshNd64<const D: usize> = HalfEdgeMeshImpl<MeshTypeNd64PNU<D>>;
58/// 2d variant of MeshNd64
59pub type Mesh2d64 = MeshNd64<2>;
60/// 3d variant of MeshNd64
61pub type Mesh3d64 = MeshNd64<3>;
62/// 4d variant of MeshNd64
63pub type Mesh4d64 = MeshNd64<4>;
64
65/// 64-bit 3d variant of the half-edge vertex
66pub type Mesh3d64Vertex = HalfEdgeVertexImpl<MeshTypeNd64PNU<3>>;
67
68/// 64-bit 3d variant of the half-edge edge
69pub type Mesh3d64Edge = HalfEdgeImpl<MeshTypeNd64PNU<3>>;
70
71/// 64-bit 3d variant of the half-edge face
72pub type Mesh3d64Face = HalfEdgeFaceImpl<MeshTypeNd64PNU<3>>;