fj_core/algorithms/bounding_volume/
edge.rs

1use 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                // Just calculate the AABB of the whole circle. This is not the
14                // most precise, but it should do for now.
15
16                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}