mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-04 02:55:54 +00:00
Tests: the saved fitted-letters design measures its closed form, its letter as conics
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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}");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user