Skip to content

Commit

Permalink
Compute AABB from boundary representation
Browse files Browse the repository at this point in the history
This is required for computing the tolerance automatically, as the AABB
is required for that. With the previous approach of computing the AABB
from the mesh, we would have needed the tolerance for the mesh and the
mesh for the AABB, forming a circular dependency.
  • Loading branch information
hannobraun committed Jun 12, 2023
1 parent 363b6d2 commit d720fbb
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions crates/fj/src/handle_model.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
use std::ops::Deref;

use fj_core::algorithms::{approx::Tolerance, triangulate::Triangulate};
use fj_core::algorithms::{
approx::Tolerance, bounding_volume::BoundingVolume,
triangulate::Triangulate,
};
use fj_interop::model::Model;
use fj_math::Aabb;
use fj_math::{Aabb, Point};

use crate::Args;

Expand All @@ -20,7 +23,12 @@ pub fn handle_model<M>(
) -> Result
where
for<'r> (&'r M, Tolerance): Triangulate,
M: BoundingVolume<3>,
{
let aabb = model.aabb().unwrap_or(Aabb {
min: Point::origin(),
max: Point::origin(),
});
let mesh = (model.deref(), tolerance.into()).triangulate();

let args = Args::parse();
Expand All @@ -29,7 +37,6 @@ where
return Ok(());
}

let aabb = Aabb::<3>::from_points(mesh.vertices());
let model = Model { mesh, aabb };

crate::window::display(model, false)?;
Expand Down

0 comments on commit d720fbb

Please sign in to comment.