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
use crate::{
objects::{
Cycle, Face, GlobalEdge, HalfEdge, Objects, Shell, Sketch, Solid,
Surface, Vertex,
},
services::{Service, ServiceObjectsExt},
storage::Handle,
validate::Validate,
};
pub trait Insert: Sized + Validate {
fn insert(self, objects: &mut Service<Objects>) -> Handle<Self>;
}
macro_rules! impl_insert {
($($ty:ty, $store:ident;)*) => {
$(
impl Insert for $ty {
fn insert(self, objects: &mut Service<Objects>) -> Handle<Self>
{
let handle = objects.$store.reserve();
objects.insert(handle.clone(), self);
handle
}
}
)*
};
}
impl_insert!(
Cycle, cycles;
Face, faces;
GlobalEdge, global_edges;
HalfEdge, half_edges;
Shell, shells;
Sketch, sketches;
Solid, solids;
Surface, surfaces;
Vertex, vertices;
);