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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
use fj_math::Point;
use crate::{
get::Get,
objects::{Curve, GlobalCurve, Surface},
storage::Handle,
};
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct Vertex {
position: Point<1>,
curve: Handle<Curve>,
surface_form: Handle<SurfaceVertex>,
}
impl Vertex {
pub fn new(
position: impl Into<Point<1>>,
curve: Handle<Curve>,
surface_form: Handle<SurfaceVertex>,
) -> Self {
let position = position.into();
Self {
position,
curve,
surface_form,
}
}
pub fn position(&self) -> Point<1> {
self.position
}
pub fn curve(&self) -> &Handle<Curve> {
&self.curve
}
pub fn surface_form(&self) -> &Handle<SurfaceVertex> {
&self.surface_form
}
pub fn global_form(&self) -> &Handle<GlobalVertex> {
self.surface_form.global_form()
}
}
impl Get<Curve> for Vertex {
fn get(&self) -> Handle<Curve> {
self.curve().clone()
}
}
impl Get<SurfaceVertex> for Vertex {
fn get(&self) -> Handle<SurfaceVertex> {
self.surface_form().clone()
}
}
impl Get<Surface> for Vertex {
fn get(&self) -> Handle<Surface> {
self.curve().surface().clone()
}
}
impl Get<GlobalCurve> for Vertex {
fn get(&self) -> Handle<GlobalCurve> {
self.curve().global_form().clone()
}
}
impl Get<GlobalVertex> for Vertex {
fn get(&self) -> Handle<GlobalVertex> {
self.surface_form().global_form().clone()
}
}
#[derive(Clone, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct SurfaceVertex {
position: Point<2>,
surface: Handle<Surface>,
global_form: Handle<GlobalVertex>,
}
impl SurfaceVertex {
pub fn new(
position: impl Into<Point<2>>,
surface: Handle<Surface>,
global_form: Handle<GlobalVertex>,
) -> Self {
let position = position.into();
Self {
position,
surface,
global_form,
}
}
pub fn position(&self) -> Point<2> {
self.position
}
pub fn surface(&self) -> &Handle<Surface> {
&self.surface
}
pub fn global_form(&self) -> &Handle<GlobalVertex> {
&self.global_form
}
}
impl Get<Surface> for SurfaceVertex {
fn get(&self) -> Handle<Surface> {
self.surface().clone()
}
}
impl Get<GlobalVertex> for SurfaceVertex {
fn get(&self) -> Handle<GlobalVertex> {
self.global_form().clone()
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Hash, Ord, PartialOrd)]
pub struct GlobalVertex {
position: Point<3>,
}
impl GlobalVertex {
pub fn new(position: impl Into<Point<3>>) -> Self {
let position = position.into();
Self { position }
}
pub fn position(&self) -> Point<3> {
self.position
}
}