1use std::ops::Deref;
2
3use fj_interop::debug::DebugInfo;
4use fj_kernel::{
5 algorithms::sweep::Sweep, objects::Solid, operations::Insert,
6 services::Services,
7};
8use fj_math::{Aabb, Vector};
9
10use super::Shape;
11
12impl Shape for fj::Sweep {
13 type Brep = Solid;
14
15 fn compute_brep(
16 &self,
17 services: &mut Services,
18 debug_info: &mut DebugInfo,
19 ) -> Self::Brep {
20 let sketch = self
21 .shape()
22 .compute_brep(services, debug_info)
23 .insert(services);
24
25 let path = Vector::from(self.path());
26
27 let solid = sketch.sweep(path, services);
28 solid.deref().clone()
29 }
30
31 fn bounding_volume(&self) -> Aabb<3> {
32 self.shape()
33 .bounding_volume()
34 .merged(&Aabb::<3>::from_points(
35 self.shape()
36 .bounding_volume()
37 .vertices()
38 .map(|v| v + self.path()),
39 ))
40 }
41}