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
use fj_math::{Circle, Line, Vector};
use crate::{
geometry::{
curve::{Curve, GlobalPath},
surface::SurfaceGeometry,
},
objects::{Objects, Surface},
operations::Insert,
services::Service,
storage::Handle,
};
use super::{Sweep, SweepCache};
impl Sweep for (Curve, &Surface) {
type Swept = Handle<Surface>;
fn sweep_with_cache(
self,
path: impl Into<Vector<3>>,
_: &mut SweepCache,
objects: &mut Service<Objects>,
) -> Self::Swept {
let (curve, surface) = self;
match surface.geometry().u {
GlobalPath::Circle(_) => {
todo!(
"Sweeping a curve that is defined on a curved surface is \
not supported yet."
)
}
GlobalPath::Line(_) => {
}
}
let u = match curve {
Curve::Circle(circle) => {
let center = surface
.geometry()
.point_from_surface_coords(circle.center());
let a =
surface.geometry().vector_from_surface_coords(circle.a());
let b =
surface.geometry().vector_from_surface_coords(circle.b());
let circle = Circle::new(center, a, b);
GlobalPath::Circle(circle)
}
Curve::Line(line) => {
let origin =
surface.geometry().point_from_surface_coords(line.origin());
let direction = surface
.geometry()
.vector_from_surface_coords(line.direction());
let line = Line::from_origin_and_direction(origin, direction);
GlobalPath::Line(line)
}
};
Surface::new(SurfaceGeometry { u, v: path.into() }).insert(objects)
}
}