1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
use fj_math::Vector;
use crate::{
geometry::{path::GlobalPath, surface::SurfaceGeometry},
storage::{Handle, Store},
};
use super::{
Curve, Cycle, Face, GlobalCurve, GlobalEdge, GlobalVertex, HalfEdge, Shell,
Sketch, Solid, Surface, SurfaceVertex,
};
#[derive(Debug, Default)]
pub struct Objects {
pub curves: Store<Curve>,
pub cycles: Store<Cycle>,
pub faces: Store<Face>,
pub global_curves: Store<GlobalCurve>,
pub global_edges: Store<GlobalEdge>,
pub global_vertices: Store<GlobalVertex>,
pub half_edges: Store<HalfEdge>,
pub shells: Store<Shell>,
pub sketches: Store<Sketch>,
pub solids: Store<Solid>,
pub surface_vertices: Store<SurfaceVertex>,
pub surfaces: Surfaces,
}
impl Objects {
pub fn new() -> Self {
Self::default()
}
}
#[derive(Debug)]
pub struct Surfaces {
store: Store<Surface>,
xy_plane: Handle<Surface>,
xz_plane: Handle<Surface>,
yz_plane: Handle<Surface>,
}
impl Surfaces {
pub fn reserve(&self) -> Handle<Surface> {
self.store.reserve()
}
pub fn insert(&mut self, handle: Handle<Surface>, surface: Surface) {
self.store.insert(handle, surface);
}
pub fn xy_plane(&self) -> Handle<Surface> {
self.xy_plane.clone()
}
pub fn xz_plane(&self) -> Handle<Surface> {
self.xz_plane.clone()
}
pub fn yz_plane(&self) -> Handle<Surface> {
self.yz_plane.clone()
}
}
impl Default for Surfaces {
fn default() -> Self {
let mut store: Store<Surface> = Store::new();
let xy_plane = store.reserve();
store.insert(
xy_plane.clone(),
Surface::new(SurfaceGeometry {
u: GlobalPath::x_axis(),
v: Vector::unit_y(),
}),
);
let xz_plane = store.reserve();
store.insert(
xz_plane.clone(),
Surface::new(SurfaceGeometry {
u: GlobalPath::x_axis(),
v: Vector::unit_z(),
}),
);
let yz_plane = store.reserve();
store.insert(
yz_plane.clone(),
Surface::new(SurfaceGeometry {
u: GlobalPath::y_axis(),
v: Vector::unit_z(),
}),
);
Self {
store,
xy_plane,
xz_plane,
yz_plane,
}
}
}