geometry: a partition's pieces that do not touch become separate cells (#388)

split_by_plane gives one body per side, which may hold several shells when
the side falls apart; every lump is now its own cell (B/a1, B/a2), at every
cut, as the partition docs promise.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
jyvikoandClaude Opus 5.5 authored and Irakli Kourtis committed 2026-10-15 13:43:45 -04:00
1 parent df7f7f0769
commit 92c3588099
3 files changed
+58 -1

No files matched your search

+5
View File
@@ -215,6 +215,11 @@ impl Shape {
Ok(guard("size", || Ok(self.body.size()))?)
}
/// The boundary shells of the body: one for a solid in one piece without voids.
pub fn shells(&self) -> Result<usize> {
Ok(guard("shells", || Ok(self.body.shell_count()))?)
}
pub fn measure(&self) -> Result<Measure> {
let m = guard("measure", || solidcraft_kernel::measure(&self.body))?;
Ok(Measure {
+10 -1
View File
@@ -165,11 +165,20 @@ enum Split {
/// Cut one body.
fn split(body: &Shape, plane: &Plane, n: [f64; 3], cut: &Cut) -> Result<Split> {
let parts = match guard("partition", || solidcraft_kernel::split_by_plane(&body.body, plane)) {
let sides = match guard("partition", || solidcraft_kernel::split_by_plane(&body.body, plane)) {
Ok(p) if p.len() >= 2 => p,
Ok(_) => return Ok(Split::Misses),
Err(e) => return Ok(Split::Failed(e.to_string())),
};
// Each side may fall apart into pieces that do not touch (#388): every piece is a cell.
let mut parts = Vec::with_capacity(sides.len());
for side in sides {
match guard("partition", || side.lumps()) {
Ok(pieces) if !pieces.is_empty() => parts.extend(pieces),
Ok(_) => parts.push(side),
Err(e) => return Ok(Split::Failed(e.to_string())),
}
}
let size = body.size()?;
let tol = (MATCH_TOLERANCE * size).max(1e-4);
let parent = Faces::of(body, tol)?;