From 23bfa1cf7348112ecd1205cfadb8e70625b35912 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Thu, 29 Oct 2026 02:00:00 -0400 Subject: [PATCH] Tests: the saved fitted-letters design measures its closed form, its letter as conics MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit a_face_sketch_saved_with_fitted_letters_reopens_and_builds_the_same compared the part with the 5916.018831 mm³ its saving build measured, to 1e-3. The part is the 30 x 20 x 10 block less the "S" 1 deep and an r 2 circle 3 deep clear of it: 6000 - 46.290121 (the letter's exact profile area, Sketch2's smaller region) - 12 pi = 5916.010767. SMLib measures 5916.010768 (1.2e-6 off); the saved figure was 8e-3 off. The test now checks that closed form to SMLib's 1e-8, and counts the letter's exact pieces as conics or splines (its quadratic Béziers come in as conics). Co-Authored-By: Claude Opus 5.5 --- crates/engine/src/cmd/sketch_project_tests.rs | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/sketch_project_tests.rs b/crates/engine/src/cmd/sketch_project_tests.rs index 0ba5016f7..66a72de6d 100644 --- a/crates/engine/src/cmd/sketch_project_tests.rs +++ b/crates/engine/src/cmd/sketch_project_tests.rs @@ -731,12 +731,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}"); }