diff --git a/crates/kernel/src/face_source_tests.rs b/crates/kernel/src/face_source_tests.rs
index c46f0008b..2ba51f6c1 100644
--- a/crates/kernel/src/face_source_tests.rs
+++ b/crates/kernel/src/face_source_tests.rs
@@ -100,7 +100,14 @@ fn construction_planes_follow_reflected_and_sheared_affine_images() {
[[-1., 0., 0., 0.], [0.4, 2., 0., 0.], [0., 0.3, 1., 0.], [8., 9., 10., 1.]],
] {
let placed = transform_matrix(&body, m).unwrap();
- for (original, transformed) in body.face_sources().unwrap().iter().zip(placed.face_sources().unwrap()) {
+ // SMLib numbers the placed faces afresh: each is matched with the face its history names.
+ let history = placed.history().unwrap();
+ let originals = body.face_sources().unwrap();
+ for (f, transformed) in placed.face_sources().unwrap().iter().enumerate() {
+ let [crate::history::FaceOrigin::Face { operand: 0, face }] = history.faces[f].origins.as_slice() else {
+ panic!("face {f} has no one origin")
+ };
+ let original = &originals[*face];
let (
Some(FaceSource::Box { producer: a, axis: aa, high: ah, plane: ap }),
Some(FaceSource::Box { producer: b, axis: ba, high: bh, plane: bp }),
diff --git a/crates/kernel/src/issue_2005_tests.rs b/crates/kernel/src/issue_2005_tests.rs
index 532a07b43..98c67eda9 100644
--- a/crates/kernel/src/issue_2005_tests.rs
+++ b/crates/kernel/src/issue_2005_tests.rs
@@ -31,8 +31,10 @@ fn circle_path() -> [PathSeg; 2] {
fn tube(body: &Body, volume: f64, genus: usize) {
let m = measure(body).unwrap();
assert!((m.volume - volume).abs() < volume * 0.01, "{m:?}, expected {volume}");
- // A closed orientable tube has Euler characteristic 2 - 2g. Coincident caps gave 2.
- assert_eq!(m.vertices + m.faces + 2 * genus, m.edges + 2, "{m:?}");
+ // A closed orientable tube of genus g: V - E + F - (L - F) = 2 - 2g (Euler-Poincare, L the
+ // loops: an annular face has two). Coincident caps gave 2 - 2g + 2.
+ let loops: usize = body.record().faces.iter().map(|f| f.loops.len()).sum();
+ assert_eq!(m.vertices + 2 * m.faces + 2 * genus, m.edges + loops + 2, "{m:?}, {loops} loops");
// Every shell closed: each edge bounds two faces.
assert!(body.record().edges.iter().all(|e| e.uses.len() >= 2));
let h = body.history().expect("sweep provenance");
diff --git a/crates/kernel/src/ops.rs b/crates/kernel/src/ops.rs
index fe9b33ad2..053368f66 100644
--- a/crates/kernel/src/ops.rs
+++ b/crates/kernel/src/ops.rs
@@ -141,15 +141,44 @@ pub fn transform_matrix(body: &Body, m: [[f64; 4]; 4]) -> Result
{
return placed.with_history(history, &[body]);
}
let sources = body.transformed_sources(m)?;
- let placed = match Rigid::of_matrix(&m) {
+ let (placed, sources, paint) = match Rigid::of_matrix(&m) {
Some(motion) => {
let moved = Body::from_record(body.record().moved(&motion))?;
let history = History::identity(&moved);
- moved.with_history(history, &[body])?
+ (moved.with_history(history, &[body])?, sources, body.paint().cloned())
+ }
+ None => {
+ // SMLib numbers the moved body's faces afresh: each face's source and paint follow it
+ // by the history (a face whose origin is not known keeps no source; with no history
+ // the paint stays as it was).
+ let placed = transformed(body, &m)?;
+ let origin: Vec