From af98e6a6f4a05c80a6a8dca1183d1179bdd9742c Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Jun 2023 11:14:47 +0200 Subject: [PATCH 1/2] Support AABB computation for curves faces --- .../src/algorithms/bounding_volume/face.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/crates/fj-core/src/algorithms/bounding_volume/face.rs b/crates/fj-core/src/algorithms/bounding_volume/face.rs index 86cba6a08..3a1df7a0c 100644 --- a/crates/fj-core/src/algorithms/bounding_volume/face.rs +++ b/crates/fj-core/src/algorithms/bounding_volume/face.rs @@ -8,11 +8,17 @@ impl super::BoundingVolume<3> for Face { let surface = self.surface().geometry(); match surface.u { - GlobalPath::Circle(_) => { - // I don't currently have an example model to test this - // with. This should change soon, and then this will panic - // and can be addressed. - todo!("Computing AABB of curved face is not supported yet") + GlobalPath::Circle(circle) => { + // This is not the most precise way to calculate the AABB, + // doing it for the whole circle, but it should do. + + let aabb_bottom = circle.aabb(); + let aabb_top = Aabb { + min: aabb_bottom.min + surface.v, + max: aabb_bottom.max + surface.v, + }; + + aabb_bottom.merged(&aabb_top) } GlobalPath::Line(_) => Aabb { min: surface.point_from_surface_coords(aabb2.min), From a69a65f8c75acb402efcb8b1517d3f6800ad2fcf Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Mon, 19 Jun 2023 10:21:53 +0200 Subject: [PATCH 2/2] Support AABB calculation for arcs --- .../src/algorithms/bounding_volume/edge.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/crates/fj-core/src/algorithms/bounding_volume/edge.rs b/crates/fj-core/src/algorithms/bounding_volume/edge.rs index ba6d56a09..d8f914d53 100644 --- a/crates/fj-core/src/algorithms/bounding_volume/edge.rs +++ b/crates/fj-core/src/algorithms/bounding_volume/edge.rs @@ -1,15 +1,21 @@ -use fj_math::Aabb; +use fj_math::{Aabb, Vector}; use crate::{geometry::curve::Curve, objects::HalfEdge}; impl super::BoundingVolume<2> for HalfEdge { fn aabb(&self) -> Option> { match self.curve() { - Curve::Circle(_) => { - // I don't currently have an example model to test this with. - // This should change soon, and then this will panic and can be - // addressed. - todo!("Computing AABB of arc is not supported yet") + Curve::Circle(circle) => { + // Just calculate the AABB of the whole circle. This is not the + // most precise, but it should do for now. + + let center_to_min_max = + Vector::from([circle.radius(), circle.radius()]); + + Some(Aabb { + min: circle.center() - center_to_min_max, + max: circle.center() + center_to_min_max, + }) } Curve::Line(_) => { let points = self.boundary().map(|point_curve| {