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
use crate;
use crate*;
use crate*;
use Serialize;
use ;
use fs;
// top level load metho that pass a file path in str
// pub fn deserialize_geometric_primitive(v: &Value) -> impl GeometricPrimitive {
// let type_str = v["type"].as_str().unwrap();
// deserialize_match(&v, &type_str)
// }
// pub fn deserialize_match<A, B>(v: &Value, type_str: &str) -> AllPrimitives<A, B>
// where A: GeometricPrimitive,
// B: GeometricPrimitive {
// println!("{:?}", type_str);
// match type_str {
// // Booleans
// // "Difference" => deserialize_boolean(&v["left"], &v["right"], type_str),
// // "Intersection" => deserialize_boolean(&v["left"], &v["right"], type_str),
// "Union" => deserialize_boolean(&v["left"], &v["right"], type_str),
// // Primitives
// // "Torus" => serde_json::
// // "Torus" => Torus::new(v["a"].as_f64().unwrap(), v["c"].as_f64().unwrap()),
// "Torus" => deserialize_primitive(v, type_str),
// _ => panic!("wtf")
// }
// }
// pub fn deserialize_boolean<A, B>(left: &Value, right: &Value, type_str: &str) -> AllPrimitives<A, B>
// where A: GeometricPrimitive,
// B: GeometricPrimitive {
// let left_type_str = left["type"].as_str().unwrap();
// let right_type_str = right["type"].as_str().unwrap();
// let left = deserialize_match(left, &left_type_str);
// let right = deserialize_match(right, &right_type_str);
// match type_str {
// // "Difference" => Difference::new(left, right),
// // "Intersection" => Intersection::new(left, right),
// "Union" => Union::new(left, right),
// _ => panic!("wtf")
// }
// }
// pub fn deserialize_primitive<A, B>(v: &Value, type_str: &str) -> AllPrimitives<A, B>
// where A: GeometricPrimitive,
// B: GeometricPrimitive {
// match type_str {
// "Torus" => {
// Primitives::Torus(
// Torus::new(v["a"].as_f64().unwrap(), v["c"].as_f64().unwrap())
// )
// },
// _ => panic!("wtf")
// }
// }