fj_core/algorithms/bounding_volume/
edge.rs1use fj_math::{Aabb, Vector};
2
3use crate::{
4 geometry::{Geometry, SurfacePath},
5 objects::HalfEdge,
6 storage::Handle,
7};
8
9impl super::BoundingVolume<2> for Handle<HalfEdge> {
10 fn aabb(&self, geometry: &Geometry) -> Option<Aabb<2>> {
11 match geometry.of_half_edge(self).path {
12 SurfacePath::Circle(circle) => {
13 let center_to_min_max =
17 Vector::from([circle.radius(), circle.radius()]);
18
19 Some(Aabb {
20 min: circle.center() - center_to_min_max,
21 max: circle.center() + center_to_min_max,
22 })
23 }
24 SurfacePath::Line(_) => {
25 let points = self.boundary().inner.map(|point_curve| {
26 geometry
27 .of_half_edge(self)
28 .path
29 .point_from_path_coords(point_curve)
30 });
31
32 Some(Aabb::<2>::from_points(points))
33 }
34 }
35 }
36}