7b0906b918
- Picks run on a copy of the operand: a pick builds query caches on the body it reads, so the traced body stays as an untraced run leaves it. - An untrim and an extension record their picks with the pickers they run (`face_at`, `nearest_edge`). - A final body matches the newest export of its record that an operation made. - A stopped run is the kernel's when the last failed operation is followed by copies only. - A re-export removes each case's old entry first; fixes.json is written whole. - The manifest names no commit for a copy without git, never an empty one. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
72 lines
3.2 KiB
Rust
72 lines
3.2 KiB
Rust
//! Untrim and extend of a sheet's faces. Each returns a new body and leaves its input unchanged;
|
|
//! faces and holes are chosen by points, as [`crate::ops`] chooses them.
|
|
|
|
use serde_json::json;
|
|
|
|
use crate::trace;
|
|
use crate::{Brep, Result, core};
|
|
|
|
/// How [`Brep::extend_sheet`] continues a surface past its side.
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
|
pub enum Continuation {
|
|
/// The surface's own geometry (a B-spline's end spans continued).
|
|
Natural,
|
|
/// A run-off tangent to the surface across the side (G1).
|
|
Tangent,
|
|
/// A run-off that also keeps the surface's curvature across the side (G2).
|
|
Curvature,
|
|
}
|
|
|
|
/// The inner loops [`Brep::untrim_face`] takes away.
|
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
|
pub enum Holes<'a> {
|
|
All,
|
|
/// The inner loop nearest each point (within the tolerance, else [`crate::Error::NoMatch`]).
|
|
At(&'a [[f64; 3]]),
|
|
}
|
|
|
|
impl Brep {
|
|
/// The face nearest `point` (within `tolerance`) restored towards its surface: the holes
|
|
/// `holes` names taken away and, with `outer`, its outer boundary back on the surface's
|
|
/// parameter box (a free-form surface's own, an analytic one's the box of the face's span; one
|
|
/// all the way round closes on the surface's seam). The face alone, or
|
|
/// with `in_place` the whole body with it replaced. Tags follow the face and its edges.
|
|
pub fn untrim_face(&self, point: [f64; 3], tolerance: f64, holes: Holes, outer: bool, in_place: bool) -> Result<Brep> {
|
|
let holes = match holes {
|
|
Holes::All => None,
|
|
Holes::At(at) => Some(at),
|
|
};
|
|
let r = core::trim::untrim_face(self.core(), point, tolerance, holes, outer, in_place).map(Brep::made_core);
|
|
trace::made(
|
|
"untrim_face",
|
|
&[self],
|
|
&r,
|
|
|| json!({"face": trace::picks(self, trace::PickKind::NearestFace, &[point], tolerance), "holes": holes, "outer": outer, "in_place": in_place}),
|
|
);
|
|
r
|
|
}
|
|
|
|
/// The one-face sheet `self`, whose face is its surface's whole parameter box, continued
|
|
/// `distance` past the side its edge nearest `point` (within `tolerance`) runs along, as
|
|
/// `how` says: SMLib's extended surface over the grown box, the face and its sides carrying
|
|
/// the tags of those they continue. A sheet of another shape is [`crate::Error::Unsupported`].
|
|
pub fn extend_sheet(&self, point: [f64; 3], tolerance: f64, distance: f64, how: Continuation) -> Result<Brep> {
|
|
let r = core::trim::extend_sheet(self.core(), point, tolerance, distance, how).map(Brep::made_core);
|
|
trace::made("extend_sheet", &[self], &r, || {
|
|
let how = match how {
|
|
Continuation::Natural => "natural",
|
|
Continuation::Tangent => "tangent",
|
|
Continuation::Curvature => "curvature",
|
|
};
|
|
json!({"edge": trace::picks(self, trace::PickKind::NearestEdge, &[point], tolerance), "distance": distance, "how": how})
|
|
});
|
|
r
|
|
}
|
|
|
|
/// 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]>> {
|
|
core::trim::face_points(self.core())
|
|
}
|
|
}
|