mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-04 02:55:54 +00:00
solidcraft-smlib: Brep::face_points, a point inside each face (smlib_face_points)
Each face's point from SmFace::CalculateAnInternalPoint, in SMLib's face order; the fork at 89a1933 (also: smlib_extend_sheet extends every surface as SMLib's B-spline, its analytic kind given back). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017itGh5fpMEousnZ91cYcVt
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user