Lumps: a face-source table of another length is refused, never sliced

Body::parts (and so Body::lumps) mapped each piece's faces through the
body's face-source table with a silent `get`, so a table shorter or longer
than the body's faces gave its pieces sources of other faces, or none. The
table is by face position: one whose length is not the body's face count
belongs to another body. The pieces are now refused with "lumps: face
source table does not match the body", as before the SMLib port (the check
went with the old lumps_with_clearance in 66e31bede).

Fixes kernel body::lump_tests::grouping_lumps_does_not_infer_absent_or_misaligned_sources.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jyviko
2026-10-29 21:51:09 -04:00
committed by Irakli Kourtis
parent 15c31a96fc
commit 049b2bc405
+4
View File
@@ -1351,6 +1351,10 @@ impl Body {
pub fn parts(&self, groups: &[Vec<usize>]) -> Result<Vec<Body>> {
let regions = self.record.material_regions();
let counts = [(self.face_count(), self.edge_count())];
// Sources are by face position: a table of another length belongs to another body.
if self.face_sources.as_ref().is_some_and(|all| all.len() != self.face_count()) {
return Err(KernelError::Invalid("lumps: face source table does not match the body".into()));
}
groups
.iter()
.map(|group| {