diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index 209a9bca9..9a665f0db 100644 --- a/crates/fj-window/src/display.rs +++ b/crates/fj-window/src/display.rs @@ -1,5 +1,4 @@ -use fj_interop::{mesh::Mesh, model::Model}; -use fj_math::{Aabb, Point}; +use fj_interop::model::Model; use fj_viewer::{ InputEvent, NormalizedScreenPosition, RendererInitError, Screen, ScreenSize, Viewer, @@ -17,15 +16,12 @@ use winit::{ use crate::window::{self, Window}; /// Display the provided mesh in a window that processes input -pub fn display(mesh: Mesh>, invert_zoom: bool) -> Result<(), Error> { +pub fn display(model: Model, invert_zoom: bool) -> Result<(), Error> { let event_loop = EventLoop::new(); let window = Window::new(&event_loop)?; let mut viewer = block_on(Viewer::new(&window))?; - viewer.handle_model_update(Model { - aabb: Aabb::<3>::from_points(mesh.vertices()), - mesh, - }); + viewer.handle_model_update(model); let mut held_mouse_button = None; let mut new_size = None; diff --git a/crates/fj/src/handle_model.rs b/crates/fj/src/handle_model.rs index 93015a74c..be9ccbbbc 100644 --- a/crates/fj/src/handle_model.rs +++ b/crates/fj/src/handle_model.rs @@ -1,6 +1,8 @@ use std::ops::Deref; use fj_core::algorithms::{approx::Tolerance, triangulate::Triangulate}; +use fj_interop::model::Model; +use fj_math::Aabb; use crate::Args; @@ -12,22 +14,26 @@ use crate::Args; /// /// This function is used by Fornjot's own testing infrastructure, but is useful /// beyond that, when using Fornjot directly to define a model. -pub fn handle_model( - model: impl Deref, +pub fn handle_model( + model: impl Deref, tolerance: impl Into, ) -> Result where - for<'r> (&'r Model, Tolerance): Triangulate, + for<'r> (&'r M, Tolerance): Triangulate, { let mesh = (model.deref(), tolerance.into()).triangulate(); let args = Args::parse(); if let Some(path) = args.export { crate::export::export(&mesh, &path)?; - } else { - crate::window::display(mesh, false)?; + return Ok(()); } + let aabb = Aabb::<3>::from_points(mesh.vertices()); + let model = Model { mesh, aabb }; + + crate::window::display(model, false)?; + Ok(()) }