Wave 16/509: brep: check_geometry, the geometric agreement of a record (and 3 more)

4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop.

- b85b51e81 Brennen Herbruck: solidcraft-smlib: blend faces come from the edge they replace
- 4a6494b48 jyviko: brep: check_geometry, the geometric agreement of a record
- 570028f31 jyviko: brep: the truck adapter checks a record's geometry before decoding it
- 30f5e617c jyviko: brep: document check_geometry in the validation section

Co-authored-by: Brennen Herbruck <brennen.herbruck@gmail.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
jyviko
2026-10-21 00:47:15 -04:00
parent af6528b420
commit d05b24fb5e
8 changed files with 403 additions and 7 deletions
+3
View File
@@ -308,8 +308,11 @@ fn compatible(body: &b::Brep) -> Result<()> {
body.faces.iter().try_for_each(|f| compatible_surface(&f.surface))
}
/// The solid of a record: validated, its geometry checked against its topology (truck builds
/// edges and faces from it unchecked), then built as the kernel built it.
pub(super) fn decode(body: b::Brep) -> Result<mt::Solid> {
body.validate().map_err(invalid)?;
body.check_geometry().map_err(invalid)?;
compatible(&body)?;
let b::Brep { shells, faces, edges, vertices, .. } = body;
let vertices: Vec<mt::Vertex> = vertices.into_iter().map(|v| mt::Vertex::new(p(v.point))).collect();
+12
View File
@@ -131,6 +131,18 @@ fn records_truck_cannot_hold_are_refused() {
assert!(decode(vertex_loop).is_err());
}
/// Truck builds edges and faces unchecked: a record whose geometry misses its topology is
/// refused before it gets there.
#[test]
fn records_whose_geometry_misses_their_topology_are_refused() {
let cube = crate::box_solid(Vec3::ZERO, Vec3::new(4., 3., 1.)).unwrap();
let mut moved = encode(&cube).unwrap();
moved.vertices[0].point[0] += 0.1;
moved.validate().unwrap();
let error = decode(moved).err().unwrap().to_string();
assert!(error.contains("misses its"), "{error}");
}
#[test]
fn intersections_and_revolutions_reload_exactly() {
let cyl = crate::cylinder(Vec3::ZERO, Vec3::Z, 5., 40.).unwrap();