brep: working tolerance, golden v5 records, cache producer 4

Edges, vertices and the body carry the face tolerance (10^-6 of the
body's size, at least 10^-5 mm): truck's traced intersection edges sit
about 1e-6 mm off their surfaces, so the linear tolerance is too tight for
a pcurve to lift onto them. The box-and-fillet golden fixture is the
schema 4 envelope now (NATIVE_BREP_BLESS=1 rewrites it), and the adapter
tests cover a pair of lumps. The model cache's producer revision becomes
solidcraft-truck-adapter/4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01QWhMwdqJYQKQq8RCLSL1LT
This commit is contained in:
jyviko
2026-10-20 23:11:19 -04:00
parent 445fb23859
commit 2f4d6acacb
6 changed files with 3314 additions and 1264 deletions
+1 -1
View File
@@ -6,7 +6,7 @@ use super::*;
use solidcraft_doc::{ModelState, SavedModel};
const FORMAT: &str = "solidcraft-model-cache/4";
const PRODUCER: &str = "solidcraft-truck-adapter/3";
const PRODUCER: &str = "solidcraft-truck-adapter/4";
const MANIFEST: &str = "cache/model.json";
const PAYLOAD: &str = "cache/bodies.bin";
/// Body records (a placed copy is one record; its part is stored once).
+5
View File
@@ -263,6 +263,11 @@ mod tests {
})
.collect();
let actual = serde_json::json!(records);
// An intended change to the wire records rewrites the fixture with NATIVE_BREP_BLESS=1.
if std::env::var_os("NATIVE_BREP_BLESS").is_some() {
let path = concat!(env!("CARGO_MANIFEST_DIR"), "/src/native/fixtures/box-fillet-v5.json");
std::fs::write(path, serde_json::to_string_pretty(&actual).unwrap() + "\n").unwrap();
}
let expected: Value = serde_json::from_str(include_str!("native/fixtures/box-fillet-v5.json")).unwrap();
compare_wire(&expected, &actual);
}
+5 -2
View File
@@ -86,9 +86,12 @@ fn compatible_surface(s: &b::Surface) -> Result<()> {
}
}
/// The body's working tolerance, mm: its "same point" tolerance (`fill::planarity_tolerance`).
/// The body's working tolerance, mm: how far later operations take its faces to be from its
/// edges (`fill::face_tolerance`, 10⁻⁶ of its size, at least 10⁻⁵ mm). Truck's own edges sit
/// that far off their surfaces (a traced intersection, an imported edge), so a pcurve lifts
/// onto the edge within it and SMLib can check the edge against the face with it.
fn working_tolerance(body: &Body) -> f64 {
crate::fill::planarity_tolerance(body)
crate::fill::face_tolerance(body)
}
/// The record of `body`'s solid, with each face's pcurves from `pcurves` (the face, then the
+13 -2
View File
@@ -82,8 +82,11 @@ fn planar_bodies_encode_in_the_kernels_order_and_decode_exactly() {
let sheet = crate::copy_faces(&cube, &[Vec3::new(20., 15., 10.)]).unwrap();
let inner = crate::box_solid(Vec3::new(5., 5., 2.), Vec3::new(10., 10., 6.)).unwrap();
let hollow = crate::boolean(&cube, &inner, crate::BoolOp::Cut).unwrap().unwrap();
for (name, body) in [("cube", cube), ("notched", notched), ("sheet", sheet), ("hollow", hollow)] {
assert!(body.solid.face_iter().any(|f| !f.orientation()) || name == "sheet", "{name}: a reversed face is walked");
let far = crate::box_solid(Vec3::new(60., 0., 0.), Vec3::new(70., 10., 10.)).unwrap();
let pair = crate::boolean(&cube, &far, crate::BoolOp::Union).unwrap().unwrap();
let bodies = [("cube", cube), ("notched", notched), ("sheet", sheet), ("hollow", hollow), ("pair", pair)];
assert!(bodies.iter().any(|(_, b)| b.solid.face_iter().any(|f| !f.orientation())), "reversed faces are walked");
for (name, body) in bodies {
let record = encode(&body, super::super::pcurve::pcurves).unwrap_or_else(|e| panic!("{name}: {e}"));
same_indices(&body, &record);
let decoded = decode(record.clone()).unwrap();
@@ -103,6 +106,14 @@ fn planar_bodies_encode_in_the_kernels_order_and_decode_exactly() {
]
);
}
"pair" => assert_eq!(
record.regions,
vec![
b::Region { shells: vec![0, 1], void: false },
b::Region { shells: vec![0], void: false },
b::Region { shells: vec![1], void: false },
]
),
_ => assert_eq!(record.regions, vec![b::Region { shells: vec![0], void: false }, b::Region { shells: vec![0], void: false }]),
}
}
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -148,7 +148,7 @@ a STEP assembly) records the part and its matrix, so it shows that part's displa
again instead of being meshed on its own.
`cache/model.json` records `solidcraft-model-cache/4`, the producer revision
`solidcraft-truck-adapter/3`, the application version, the build (source commit,
`solidcraft-truck-adapter/4`, the application version, the build (source commit,
CPU architecture and OS), the SHA-256 of the exact `document.json` (whose blob
references pin every STEP, mesh and image payload) and of `cache/bodies.bin`, the
slices, each kernel body's slice and display share, and the model's records. A