Skip to main content

msh_rw/
mesh.rs

1use crate::Node;
2
3// pub trait MeshElt?
4
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6#[derive(Debug, Copy, Clone)]
7pub struct Point {
8    point: Node,
9}
10
11impl Point {
12    pub fn from_points(p: Node) -> Point {
13        Point { point: p }
14    }
15}
16
17#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
18#[derive(Debug, Copy, Clone)]
19pub struct Line {
20    points: (Node, Node),
21}
22
23impl Line {
24    pub fn from_points(a: Node, b: Node) -> Line {
25        Line { points: (a, b) }
26    }
27}
28
29#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
30#[derive(Debug, Copy, Clone)]
31pub struct Tri {
32    points: (Node, Node, Node),
33}
34
35impl Tri {
36    pub fn from_points(a: Node, b: Node, c: Node) -> Tri {
37        Tri { points: (a, b, c) }
38    }
39}
40
41#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
42#[derive(Debug, Copy, Clone)]
43pub struct Quad {
44    points: (Node, Node, Node, Node),
45}
46
47impl Quad {
48    pub fn from_points(a: Node, b: Node, c: Node, d: Node) -> Option<Quad> {
49        todo!()
50    }
51
52    /// Not all point configurations are correct.
53    pub fn from_points_unchecked(a: Node, b: Node, c: Node, d: Node) -> Quad {
54        Quad { points: (a, b, c, d) }
55    }
56}
57
58#[cfg(test)]
59mod tests {
60    use super::*;
61}