SolidCraft: an open-source parametric 3D CAD application built in pure Rust. Desktop, web, and automation through MCP.
Wave 338/509: Tests: the saved fitted-letters design measures its closed form, its letter as conics (and 3 more)
jyviko74a97586a887
diff --git a/crates/engine/src/cmd/features_more_tests.rs b/crates/engine/src/cmd/features_more_tests.rsindex 53db16ec3b..aeb96898db 100644--- a/crates/engine/src/cmd/features_more_tests.rs+++ b/crates/engine/src/cmd/features_more_tests.rs@@ -968,7 +968,14 @@ fn loft_cut_through_a_shelled_basin_in_either_order() {assert!(r.is_ok(), "{pad:?} reverse {reverse}: {r:?}");let v = volume(&mut s);assert!((v - want).abs() < 1.0, "{pad:?} reverse {reverse}: {v} vs {want}");- assert_eq!(measure(&mut s)["body_count"], 1);+ // The loft's top section is the basin's whole outline at z = 10, so the cut leaves the+ // walls above it touching the rest only along their outer rim: two bodies, as a cut's+ // pieces are (18480 mm³ of walls from z = 10 to 30, and the floor part below).+ let m = measure(&mut s);+ assert_eq!(m["body_count"], 2, "{m}");+ let upper =+ m["bodies"].as_array().unwrap().iter().find(|b| b["bbox"]["min"][2].as_f64().is_some_and(|z| (z - 10.0).abs() < 1e-9)).unwrap();+ assert!((upper["volume_mm3"].as_f64().unwrap() - 18480.0).abs() < 1e-6, "{upper}");}}// As a new body and joined: a valid solid of positive volume either way.diff --git a/crates/engine/src/cmd/sketch_project_tests.rs b/crates/engine/src/cmd/sketch_project_tests.rsindex 0ba5016f79..000d367591 100644--- a/crates/engine/src/cmd/sketch_project_tests.rs+++ b/crates/engine/src/cmd/sketch_project_tests.rs@@ -709,11 +709,18 @@ fn a_face_engraved_with_text_projects_its_letters_exactly_and_extrudes() {assert!(r.error.is_none(), "{r:?}");let face = before - volume(&mut s);assert!((face - taken).abs() < 1e-6 * before, "{face} {taken}");- // Its sketch got the letters as Bézier pieces.+ // Its sketch got the letters as their exact pieces: the outline's quadratic Béziers, which are+ // parabolic arcs, come in as conics (or as control-point splines).let st = s.model.state();let sketch = &st.sketches.last().unwrap().sketch;- let pieces =- sketch.curves.iter().filter(|c| c.link.is_some() && matches!(c.kind, solidcraft_sketch::CurveKind::Spline { control: true, .. })).count();+ let pieces = sketch+ .curves+ .iter()+ .filter(|c| {+ c.link.is_some()+ && matches!(c.kind, solidcraft_sketch::CurveKind::Spline { control: true, .. } | solidcraft_sketch::CurveKind::Conic { .. })+ })+ .count();assert!(pieces > 100, "{pieces}");}@@ -731,12 +738,23 @@ fn a_face_sketch_saved_with_fitted_letters_reopens_and_builds_the_same() {let r = s.model.result(id).unwrap();assert!(r.error.is_none(), "{name}: {:?}", r.error);}- // The build that saved it measured 5916.018831 mm³.- assert!((volume - 5916.018830904924).abs() < 1e-3, "{volume}");+ // The 30 x 20 x 10 block less the "S" 1 deep (its profile's exact area, Sketch2's smaller+ // region) and the r 2 circle 3 deep, clear of the letter: 5916.010767. (The build that saved+ // it measured 5916.018831, 8e-3 off; SMLib's integral is within 1e-8 of the closed form.)+ let letter = s.model.state().sketches.iter().find(|k| k.name == "Sketch2").unwrap().profiles.iter().map(|p| p.area).fold(f64::INFINITY, f64::min);+ let want = 6000.0 - letter - 3.0 * std::f64::consts::PI * 4.0;+ assert!((volume - want).abs() < 1e-8 * 6000.0, "{volume} vs {want}");+ // The letter's exact pieces in the face's link: its quadratic Béziers, as conics (or splines).let st = s.model.state();let sketch = &st.sketches.last().unwrap().sketch;- let pieces =- sketch.curves.iter().filter(|c| c.link.is_some() && matches!(c.kind, solidcraft_sketch::CurveKind::Spline { control: true, .. })).count();+ let pieces = sketch+ .curves+ .iter()+ .filter(|c| {+ c.link.is_some()+ && matches!(c.kind, solidcraft_sketch::CurveKind::Spline { control: true, .. } | solidcraft_sketch::CurveKind::Conic { .. })+ })+ .count();assert!(pieces > 0, "{pieces}");}diff --git a/crates/ui-egui/src/viewport.rs b/crates/ui-egui/src/viewport.rsindex 86eeba081a..a9292ccf77 100644--- a/crates/ui-egui/src/viewport.rs+++ b/crates/ui-egui/src/viewport.rs@@ -2642,9 +2642,6 @@ fn analysis_uniform(app: &SolveApp) -> [f32; 8] {solidcraft_gpu::view::analysis_uniform(app.session.analysis.map(|a| a.mode()), crate::access::map(app).as_ref())}-/// While Draft, Accessibility or Curvature Map analysis is on, what each of its colours means and-/// the values it stands for, at the bottom left of the viewport (#973). The colours alone don't-/// say, and with colour vision loss they can be hard to tell apart./// Why the model cannot be placed, across the bottom of the viewport, while it cannot: the/// viewport then shows no placed bodies (see `open_meshing::session_world`).fn placement_note(app: &SolveApp, painter: &egui::Painter, rect: Rect) {@@ -2654,6 +2651,9 @@ fn placement_note(app: &SolveApp, painter: &egui::Painter, rect: Rect) {painter.text(pos2(rect.center().x, rect.bottom() - 24.0), Align2::CENTER_BOTTOM, text, FontId::proportional(t.font_button), t.error);}+/// While Draft, Accessibility or Curvature Map analysis is on, what each of its colours means and+/// the values it stands for, at the bottom left of the viewport (#973). The colours alone don't+/// say, and with colour vision loss they can be hard to tell apart.fn analysis_legend(app: &SolveApp, painter: &egui::Painter, rect: Rect) {use solidcraft_engine::SurfaceAnalysis as A;let t = Tokens::get();@@ -3967,7 +3967,7 @@ pub fn show(app: &mut SolveApp, ui: &mut egui::Ui) {painter.add(egui_wgpu::Callback::new_paint_callback(rect, cb));}let overlay_rect = crate::shell::bottom_overlay_rect(app, rect);- analysis_legend(app, &painter, rect);+ analysis_legend(app, &painter, overlay_rect);placement_note(app, &painter, overlay_rect);crate::frame_rate::paint(app, ui, &painter, overlay_rect);