1use crate::core::*;
2
3pub enum MeshRecipe<'a> {
4    Basic {
5        data: &'a BasicMesh,
6    },
7    Simple {
8        data: &'a SimpleMesh,
9    },
10    Complex {
11        data: &'a ComplexMesh,
12    }
13}
14
15pub type Mesh = Box<dyn MeshProto>;
16
17pub trait MeshProto {
18    fn cook(&self) -> MeshRecipe;
19}
20
21#[derive(Clone)]
23pub struct BasicMesh {
24    pub vertices: Vec<Point3<f32>>,
25    pub breaks: Vec<usize>,
26}
27
28impl BasicMesh {
29    pub fn new(vertices: Vec<Point3<f32>>, breaks: Vec<usize>) -> Mesh {
30        Box::new(Self {
31            vertices,
32            breaks,
33        })
34    }
35}
36
37impl MeshProto for BasicMesh {
38    fn cook(&self) -> MeshRecipe {
39        MeshRecipe::Basic { data: &self }
40    }
41}
42
43#[derive(Clone)]
45pub struct SimpleMesh {
46    pub vertices: Vec<Point3<f32>>,
47    pub polygons: Vec<(usize, usize, usize, String)>, 
49}
50
51impl SimpleMesh {
52
53    pub fn new(vertices: Vec<Point3<f32>>, polygons: Vec<(usize, usize, usize, String)>) -> Mesh {
54        Box::new(Self {
55            vertices,
56            polygons
57        })
58    }
59}
60
61impl MeshProto for SimpleMesh {
62    fn cook(&self) -> MeshRecipe {
63        MeshRecipe::Simple { data: &self }
64    }
65}
66
67#[derive(Clone)]
68pub enum Brush {
69    Lines {
70        stroke: Option<String>,
71        fill: Option<String>,
72        vertices: Vec<Point3<f32>>,
73        action: u8, },
75    Circle {
76        stroke: Option<String>,
77        fill: Option<String>,
78        center: Point3<f32>,
79        radius: f32,
80        action: u8, },
82    Sphere {
83        stroke: Option<String>,
84        fill: Option<String>,
85        center: Point3<f32>,
86        radius: f32,
87        action: u8, },
89    Cube {
90        stroke: Option<String>,
91        center: Point3<f32>,
92        size: f32,
93    }
94}
95
96
97#[derive(Clone)]
99pub struct ComplexMesh {
100    pub brushes: Vec<Brush>,
101}
102
103impl ComplexMesh {
104    pub fn new() -> Self {
105        Self {
106            brushes: Vec::new()
107        }
108    }
109}
110
111impl MeshProto for ComplexMesh {
112    fn cook(&self) -> MeshRecipe {
113        MeshRecipe::Complex { data: &self }
114    }
115}
116
117