Wave 39/45: diagnostics.kernel takes a typed contract, as main's other diagnostics commands do
1 commits, squashed; the originals stay reachable from branch jyviko/merge-main-develop-solidcore (#11360). - 7ad1d3e12 jyviko: diagnostics.kernel takes a typed contract, as main's other diagnostics commands do Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
//! taken over its whole domain.
|
||||
|
||||
use crate::ssi::Surface;
|
||||
use crate::{Brep, Error, Result, error, ffi, init};
|
||||
use crate::{Brep, Error, Result, core, error, ffi, init, route};
|
||||
|
||||
impl Brep {
|
||||
/// `self` with faces `faces` (indices in SMLib's face order, distinct) cut where each of
|
||||
@@ -11,14 +11,18 @@ impl Brep {
|
||||
/// for each face how many faces it became besides itself (0: no tool split it). `None` when
|
||||
/// no face is split. Tagged operands ([`Brep::tagged`]) give the pieces' history.
|
||||
pub fn split_faces(&self, faces: &[usize], tools: &[&Surface]) -> Result<Option<(Brep, Vec<usize>)>> {
|
||||
init()?;
|
||||
if faces.is_empty() || faces.len() > ffi::split::MAX_FACES || tools.is_empty() || tools.len() > ffi::split::MAX_TOOLS {
|
||||
return Err(Error::Argument);
|
||||
}
|
||||
if route::backend() == route::Backend::Solidcore {
|
||||
let specs: Vec<&crate::ssi::Spec> = tools.iter().map(|t| t.spec()).collect();
|
||||
return core::split::split_faces(self.core()?, faces, &specs).map(|r| r.map(|(b, made)| (Brep::made_core(b), made)));
|
||||
}
|
||||
init()?;
|
||||
let faces: Vec<i64> = faces.iter().map(|f| i64::try_from(*f).map_err(|_| Error::Argument)).collect::<Result<_>>()?;
|
||||
let handles: Vec<&ffi::ssi::SurfaceHandle> = tools.iter().map(|t| t.handle()).collect();
|
||||
match ffi::split::split_faces(&self.0, &faces, &handles) {
|
||||
Ok((h, made)) => Ok(Some((Brep(h), made.into_iter().map(|m| usize::try_from(m).unwrap_or(0)).collect()))),
|
||||
let handles: Vec<&ffi::ssi::SurfaceHandle> = tools.iter().map(|t| t.handle()).collect::<Result<_>>()?;
|
||||
match ffi::split::split_faces(self.cpp()?, &faces, &handles) {
|
||||
Ok((h, made)) => Ok(Some((Brep::made(h), made.into_iter().map(|m| usize::try_from(m).unwrap_or(0)).collect()))),
|
||||
Err(ffi::ops::ERR_NO_CUT) => Ok(None),
|
||||
Err(s) => Err(error(s)),
|
||||
}
|
||||
@@ -30,9 +34,12 @@ impl Brep {
|
||||
/// leaves both parts the whole body, with no face from the tool (tag `self` to tell); `None`
|
||||
/// when a side is left empty.
|
||||
pub fn split_body(&self, tool: &Surface) -> Result<Option<(Brep, Brep)>> {
|
||||
if route::backend() == route::Backend::Solidcore {
|
||||
return core::split::split_body(self.core()?, tool.spec()).map(|r| r.map(|(b, f)| (Brep::made_core(b), Brep::made_core(f))));
|
||||
}
|
||||
init()?;
|
||||
match ffi::split::split_body(&self.0, tool.handle()) {
|
||||
Ok((b, f)) => Ok(Some((Brep(b), Brep(f)))),
|
||||
match ffi::split::split_body(self.cpp()?, tool.handle()?) {
|
||||
Ok((b, f)) => Ok(Some((Brep::made(b), Brep::made(f)))),
|
||||
Err(ffi::ops::ERR_NO_CUT) => Ok(None),
|
||||
Err(s) => Err(error(s)),
|
||||
}
|
||||
@@ -44,10 +51,14 @@ impl Brep {
|
||||
/// normal and the part in front. A `sheet` that is no sheet, or a `face` it does not have, is
|
||||
/// [`Error::Argument`].
|
||||
pub fn split_body_by_sheet(&self, sheet: &Brep, face: usize) -> Result<Option<(Brep, Brep)>> {
|
||||
if route::backend() == route::Backend::Solidcore {
|
||||
return core::split::split_body_by_sheet(self.core()?, sheet.core()?, face)
|
||||
.map(|r| r.map(|(b, f)| (Brep::made_core(b), Brep::made_core(f))));
|
||||
}
|
||||
init()?;
|
||||
let face = i64::try_from(face).map_err(|_| Error::Argument)?;
|
||||
match ffi::split::split_body_by_sheet(&self.0, &sheet.0, face) {
|
||||
Ok((b, f)) => Ok(Some((Brep(b), Brep(f)))),
|
||||
match ffi::split::split_body_by_sheet(self.cpp()?, sheet.cpp()?, face) {
|
||||
Ok((b, f)) => Ok(Some((Brep::made(b), Brep::made(f)))),
|
||||
Err(ffi::ops::ERR_NO_CUT) => Ok(None),
|
||||
Err(s) => Err(error(s)),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user