From 845ada6ecf5089d72115e0e0cdaacd84b3508a7d Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 13:21:48 +0200 Subject: [PATCH 1/4] Refactor to prepare for follow-on change --- crates/fj/src/handle_model.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/fj/src/handle_model.rs b/crates/fj/src/handle_model.rs index 93015a74c..e5684a60e 100644 --- a/crates/fj/src/handle_model.rs +++ b/crates/fj/src/handle_model.rs @@ -24,10 +24,11 @@ where let args = Args::parse(); if let Some(path) = args.export { crate::export::export(&mesh, &path)?; - } else { - crate::window::display(mesh, false)?; + return Ok(()); } + crate::window::display(mesh, false)?; + Ok(()) } From a1e6a013ca8df102a4cf497c7de14083c145aa93 Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 13:22:49 +0200 Subject: [PATCH 2/4] Rename type parameter to prevent name collision --- crates/fj/src/handle_model.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/fj/src/handle_model.rs b/crates/fj/src/handle_model.rs index e5684a60e..c99433e74 100644 --- a/crates/fj/src/handle_model.rs +++ b/crates/fj/src/handle_model.rs @@ -12,12 +12,12 @@ 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(); From 437a1f17bea14c75aa34283228d648d012a11dbe Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 13:26:25 +0200 Subject: [PATCH 3/4] Expect `Model` in `fj_window::display` --- crates/fj-window/src/display.rs | 10 +++------- crates/fj/src/handle_model.rs | 7 ++++++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index 209a9bca9..9f3426c8b 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(mesh: 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(mesh); 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 c99433e74..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; @@ -27,7 +29,10 @@ where return Ok(()); } - crate::window::display(mesh, false)?; + let aabb = Aabb::<3>::from_points(mesh.vertices()); + let model = Model { mesh, aabb }; + + crate::window::display(model, false)?; Ok(()) } From 8b5709e5237c2113777e499b61feb893e826236e Mon Sep 17 00:00:00 2001 From: Hanno Braun Date: Tue, 6 Jun 2023 13:26:46 +0200 Subject: [PATCH 4/4] Update model name --- crates/fj-window/src/display.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/fj-window/src/display.rs b/crates/fj-window/src/display.rs index 9f3426c8b..9a665f0db 100644 --- a/crates/fj-window/src/display.rs +++ b/crates/fj-window/src/display.rs @@ -16,12 +16,12 @@ use winit::{ use crate::window::{self, Window}; /// Display the provided mesh in a window that processes input -pub fn display(mesh: Model, 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(mesh); + viewer.handle_model_update(model); let mut held_mouse_button = None; let mut new_size = None;