Wave 161/509: kernel: planar source lineage on the record, coplanar faces joined by SMLib (and 3 more)

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

- 585334a29 jyviko: kernel: planar source lineage on the record, coplanar faces joined by SMLib
- 5c16e8dd1 jyviko: kernel: coplanar faces joined by SMLib's merge_faces, the record read from the body
- c802458ef jyviko: solidcraft-smlib: Brep::face_points, a point inside each face (smlib_face_points)
- 453a4dec7 jyviko: kernel: a trimmed piece's side is read at a point inside it, exactly

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-22 07:17:16 -04:00
parent 5fded8864a
commit 739c9d8f5b
6 changed files with 320 additions and 346 deletions
+16 -2
View File
@@ -1,6 +1,6 @@
//! The untrim and extend blocks of `capi/include/smlib.h` (`smlib_untrim_face`,
//! `smlib_extend_sheet`; the fork's `capi/src/smlib_untrim.cpp` and `smlib_extend.cpp`), declared
//! by hand. Part of the FFI boundary, like its parent: called only through [`crate::trim`].
//! `smlib_extend_sheet`; the fork's `capi/src/smlib_untrim.cpp` and `smlib_extend.cpp`) and
//! `smlib_face_points` (`smlib_imprint.cpp`, the pieces a trim chooses from), declared by hand. Part of the FFI boundary, like its parent: called only through [`crate::trim`].
#![allow(unsafe_code)]
@@ -29,6 +29,7 @@ unsafe extern "C" {
in_place: i32,
out: *mut *mut RawBrep,
) -> i32;
fn smlib_face_points(body: *const RawBrep, out: *mut f64, n_faces: i64) -> i32;
fn smlib_extend_sheet(sheet: *const RawBrep, point: *const f64, tol: f64, distance: f64, mode: i32, out: *mut *mut RawBrep) -> i32;
}
@@ -56,3 +57,16 @@ pub fn untrim_face(body: &Handle, point: &[f64; 3], tol: f64, holes: Option<&[[f
pub fn untrim_face(_: &Handle, _: &[f64; 3], _: f64, _: Option<&[[f64; 3]]>, _: bool, _: bool) -> Result<Handle, i32> {
Err(NOT_BUILT)
}
#[cfg(feature = "native")]
pub fn face_points(body: &Handle, n_faces: usize) -> Result<Vec<[f64; 3]>, i32> {
let n = i64::try_from(n_faces).map_err(|_| super::ERR_ARG)?;
let mut out = vec![[0.0f64; 3]; n_faces];
let s = unsafe { smlib_face_points(body.raw(), out.as_mut_ptr().cast::<f64>(), n) };
if s == super::OK { Ok(out) } else { Err(s) }
}
#[cfg(not(feature = "native"))]
pub fn face_points(_: &Handle, _: usize) -> Result<Vec<[f64; 3]>, i32> {
Err(NOT_BUILT)
}
+8
View File
@@ -56,4 +56,12 @@ impl Brep {
s => error(s),
})
}
/// A point inside each face, in SMLib's face order: on the face's surface, inside its trims
/// (`SmFace::CalculateAnInternalPoint`).
pub fn face_points(&self) -> Result<Vec<[f64; 3]>> {
init()?;
let [faces, _, _] = self.counts()?;
ffi::trim::face_points(&self.0, faces).map_err(error)
}
}