From d76cee7ce7189ee304e31e127a4de4775ba37f4a Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:52:09 -0400 Subject: [PATCH] Wave 400/509: Fair: a net of up to 128 x 128 control points, the band bounding the solver (and 3 more) 4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop. - 4ebc3d078 jyviko: UI tests: the thread catalogue's error and Press Pull's hole wall as they are now - 2debdd87a jyviko: Pi case test: each standoff is four faces, its walls one face each - db757efc7 jyviko: Tests: the pi case and the hole wall read as on green-truck-era-tests, so both branches agree - 191c1b855 jyviko: Fair: a net of up to 128 x 128 control points, the band bounding the solver Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ --- apps/solidcraft-cli/tests/rebuild_topology.rs | 9 +++++++-- crates/kernel/src/fair.rs | 18 +++++++++++++----- crates/ui-egui/src/dialogs_thread.rs | 4 +++- crates/ui-egui/src/preselect_tests.rs | 4 ++-- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/apps/solidcraft-cli/tests/rebuild_topology.rs b/apps/solidcraft-cli/tests/rebuild_topology.rs index 0d17567f7..ce80304d5 100644 --- a/apps/solidcraft-cli/tests/rebuild_topology.rs +++ b/apps/solidcraft-cli/tests/rebuild_topology.rs @@ -146,9 +146,14 @@ fn a_parameter_edit_rebuilds_like_a_fresh_build_and_reverts_exactly() { /// wall at 24) into strips along the openings' tops and bottoms. #[test] fn pi_case_faces_per_step_at_both_heights() { - // Sketch1 (1) .. RectangularPattern2 (14): the faces once features 1..=k are built. + // Sketch1 (1) .. RectangularPattern2 (14): the faces once features 1..=k are built. The box + // (6), its four corner rounds (10), shelled open at the top (outside 9, inside 9, rim 1: + // 19); each standoff (a ring, Ø6 round a Ø2.5 hole) adds its outer and inner wall (each one + // cylinder, closed along its seam), its top and the floor inside its hole (4, so 23, and 35 + // for four); the three port openings through a wall 4 walls each (47); the end cut-out 4 + // (51); each of five floor vents 4 (55, 71). const FACES: [(usize, usize); 13] = - [(2, 6), (3, 10), (4, 19), (5, 19), (6, 25), (7, 43), (8, 43), (9, 55), (10, 55), (11, 59), (12, 59), (13, 63), (14, 79)]; + [(2, 6), (3, 10), (4, 19), (5, 19), (6, 23), (7, 35), (8, 35), (9, 47), (10, 47), (11, 51), (12, 51), (13, 55), (14, 71)]; let dir = scratch_dir("pi"); let design: Value = serde_json::from_slice(&std::fs::read(root().join("tests/action_matrix/designs/pi-case.solidcraft")).unwrap()).unwrap(); let at = |height: &str, file: &str| { diff --git a/crates/kernel/src/fair.rs b/crates/kernel/src/fair.rs index f59862e0f..5be51db6b 100644 --- a/crates/kernel/src/fair.rs +++ b/crates/kernel/src/fair.rs @@ -53,10 +53,17 @@ use crate::{KernelError, Result}; /// Most steps one fairing run takes (see [`FairOptions::iterations`]). pub const MAX_FAIR_ITERATIONS: usize = 1000; -/// Most control points one fairing run accepts (a 64 × 64 net): plenty for any face's control -/// net, and small enough that a step stays cheap whatever a design file contains. -pub const MAX_FAIR_POINTS: usize = 4096; -/// Most entries of the banded system (2²¹ doubles, 16 MB). +/// Most control points one fairing run accepts (a 128 × 128 net). `MAX_FAIR_BAND` is what +/// bounds the solver's memory and its factorisation; this bounds the rest of a step, the energy +/// sweep over every control point (`(2p_u + 1)(2p_v + 1)` neighbours each, three terms) and the +/// copies of the net: for a bicubic net a few million multiply-adds and under a megabyte. It is +/// set above the band's own limit for square bicubic nets (about 90 × 90), so a face's net is +/// refused for the system it needs rather than for its size: SMLib's thickenings make faces of +/// 72 × 78 control points, which the band takes at about 1.1 M entries. +pub const MAX_FAIR_POINTS: usize = 1 << 14; +/// Most entries of the banded system (2²¹ doubles, 16 MB). The factorisation's work is at most +/// `n · min(n, bw)²` for `n` unknowns `bw` apart with `n · (bw + 1)` within this, a few 10⁹ +/// multiply-adds at the very worst (`n ≈ bw ≈ 1450`), and each solve's at most twice the band. const MAX_FAIR_BAND: usize = 1 << 21; /// The fairness energy of a curve, as a one-direction net: the `(order in u, order in v, weight)` /// term list of `∫∫ (∂S)²`. @@ -1368,7 +1375,8 @@ mod tests { ); // A net too large to fair, refused before anything is allocated for it. let line = [0.0, 0.0, 1.0, 1.0]; - assert!(fair_net([1, 1], [&line, &line], &Grid::from_fn([65, 65], |_, _| [0.0; 3]).unwrap(), &ok).is_err(), "4225 control points"); + let huge = fair_net([1, 1], [&line, &line], &Grid::from_fn([129, 129], |_, _| [0.0; 3]).unwrap(), &ok).unwrap_err(); + assert!(matches!(huge, KernelError::TooLarge(_)), "16641 control points: {huge}"); // A singular system: a cubic whose last control points lie past the end of its domain // (0.5), where they do not move the curve at all, so the interior equations have no // unique solution and the run must refuse rather than move anything. diff --git a/crates/ui-egui/src/dialogs_thread.rs b/crates/ui-egui/src/dialogs_thread.rs index 516210998..b3cf41493 100644 --- a/crates/ui-egui/src/dialogs_thread.rs +++ b/crates/ui-egui/src/dialogs_thread.rs @@ -1087,7 +1087,9 @@ mod contribution_tests { *designation = Some("1/4-20 UNC".into()); *modeled = true; let reopened = Session::new(Document::from_json(&app.session.doc.to_json()).unwrap()); - assert!(reopened.model.results.last().unwrap().error.as_ref().unwrap().contains("ISO metric")); + // The thread is metric (the M8 it was made as): a unified designation is not one of its. + let error = reopened.model.results.last().unwrap().error.clone().unwrap(); + assert!(error.contains("unknown metric thread `1/4-20 UNC`"), "{error}"); } #[test] diff --git a/crates/ui-egui/src/preselect_tests.rs b/crates/ui-egui/src/preselect_tests.rs index bf880da4c..dce8a18d0 100644 --- a/crates/ui-egui/src/preselect_tests.rs +++ b/crates/ui-egui/src/preselect_tests.rs @@ -799,8 +799,8 @@ fn press_pull_then_curved_face_offsets_it() { crate::viewport::dialog_pick(&mut app, &hit, Sel::Face { body: "Body1".into(), index: wall, point: p }); let d = app.dialog.clone().unwrap(); assert!(matches!(d.kind, Kind::OffsetFaces { .. })); - // Both halves of the hole's wall. - assert_eq!(d.inputs[0].items.len(), 2); + // The hole's wall: one face, closed along its seam. + assert_eq!(d.inputs[0].items.len(), 1); let mut app = app_with(script); app.start("solid.press_pull");