mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-06 03:51:08 +00:00
kernel: surfaces, bridge and loft rails clippy-clean; picked_loop gone
picked_loop's one caller was the patch, which is fill's now. The rest is clippy's: a record borrowed where it was already a reference, an Ok(..?) that was the value itself. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017itGh5fpMEousnZ91cYcVt
This commit is contained in:
@@ -186,7 +186,7 @@ impl ChainLine {
|
||||
}
|
||||
curves.push((c, [a, z]));
|
||||
}
|
||||
let closed = closes(&r, chain);
|
||||
let closed = closes(r, chain);
|
||||
if closed && let Some(first) = samples.first().copied() {
|
||||
push(&mut samples, first.p, chain.len().saturating_sub(1), first.t);
|
||||
}
|
||||
@@ -322,7 +322,7 @@ pub fn frames(body: &Body, face: usize, chain: &Chain, leave: Vec3, count: usize
|
||||
let line = ChainLine::of(body, chain)?;
|
||||
let stations = line.stations(count, 0.0, false)?;
|
||||
let r = body.record();
|
||||
frames_on(&r, &vec![face; chain.len()], &stations, &line, leave)
|
||||
frames_on(r, &vec![face; chain.len()], &stations, &line, leave)
|
||||
}
|
||||
|
||||
/// The frames at `stations` (points on `line`, each with the index of the chain edge it is on),
|
||||
@@ -392,7 +392,7 @@ pub fn frames_across(body: &Body, face: usize, stations: &[(Vec3, Vec3)], length
|
||||
return Err(KernelError::Invalid("frames across a boundary need at most 65536 stations on a boundary of finite size".into()));
|
||||
}
|
||||
let r = body.record();
|
||||
let support = Support::of(&r, face, length)?;
|
||||
let support = Support::of(r, face, length)?;
|
||||
let outward = if support.forward { 1.0 } else { -1.0 };
|
||||
let mut walk = Walk::new(length);
|
||||
let mut out = Vec::with_capacity(stations.len());
|
||||
@@ -917,13 +917,13 @@ pub fn blend_between(
|
||||
(mid_a - mid_b).normalized().ok_or_else(|| KernelError::Invalid("the two boundaries coincide: there is nothing to blend".into()))?,
|
||||
),
|
||||
};
|
||||
let faces_a = support_faces(&record_a, &chain_a, leave_a, a.size())?;
|
||||
let faces_b = support_faces(&record_b, &chain_b, leave_b, b.size())?;
|
||||
let faces_a = support_faces(record_a, &chain_a, leave_a, a.size())?;
|
||||
let faces_b = support_faces(record_b, &chain_b, leave_b, b.size())?;
|
||||
let (start_a, backwards_a) = seam.map_or((0.0, false), |[p, _]| line_a.start_at_seam(p));
|
||||
let stations_a = line_a.stations(samples, start_a, backwards_a)?;
|
||||
let stations_b = pair_with(&stations_a, &line_b, seam.map(|[_, q]| q))?;
|
||||
let frames_a = frames_on(&record_a, &faces_a, &stations_a, &line_a, leave_a)?;
|
||||
let frames_b = frames_on(&record_b, &faces_b, &stations_b, &line_b, leave_b)?;
|
||||
let frames_a = frames_on(record_a, &faces_a, &stations_a, &line_a, leave_a)?;
|
||||
let frames_b = frames_on(record_b, &faces_b, &stations_b, &line_b, leave_b)?;
|
||||
let made = bridge(&frames_a, &frames_b, orders, crown)?;
|
||||
let gap = boundary_gap(&made, &line_a, false)?.max(boundary_gap(&made, &line_b, true)?);
|
||||
// The blend's face is new to the operation over `[a, b]`.
|
||||
|
||||
@@ -36,7 +36,7 @@ impl Section {
|
||||
/// The sketch segments `segs` on `plane` as a section (their exact record curves), segment i
|
||||
/// standing for the profile segments `numbers[i]`.
|
||||
pub(crate) fn of(plane: &Plane, segs: &[Seg2], numbers: Vec<Vec<usize>>) -> Result<Section> {
|
||||
let curves = segs.iter().map(|s| Ok(nurbs(&crate::freeform::segment(plane, s)?.0)?)).collect::<Result<Vec<_>>>()?;
|
||||
let curves = segs.iter().map(|s| nurbs(&crate::freeform::segment(plane, s)?.0)).collect::<Result<Vec<_>>>()?;
|
||||
Ok(Section { plane: *plane, curves, numbers })
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ pub(crate) fn surface_body(r: &Brep) -> Result<Body> {
|
||||
pub(crate) fn all_new(body: Body, operands: &[&Body]) -> Result<Body> {
|
||||
let r = body.record();
|
||||
let faces = vec![record::generated(Vec::new()); r.faces.len()];
|
||||
let h = record_history(&r, operands.len(), faces, |_, _, _| Vec::new());
|
||||
let h = record_history(r, operands.len(), faces, |_, _, _| Vec::new());
|
||||
body.with_history_counts(h, &record::counts(operands))
|
||||
}
|
||||
|
||||
@@ -469,15 +469,6 @@ pub fn patch_edges(body: &Body, at: &[Vec3]) -> Result<Body> {
|
||||
crate::fill::patch_loop(body, at, 0.0)
|
||||
}
|
||||
|
||||
/// The edges of `body` picked by points on them, chained into one closed loop (each turned to run
|
||||
/// along it).
|
||||
pub(crate) fn picked_loop(body: &Body, at: &[Vec3]) -> Result<Chain> {
|
||||
match picked_chain(body, at)? {
|
||||
(chain, true) => Ok(chain),
|
||||
(_, false) => Err(invalid("the edges do not form a closed loop")),
|
||||
}
|
||||
}
|
||||
|
||||
/// The edges of `body` picked by points on them, chained end to end (each turned to run along the
|
||||
/// chain), and whether the chain closes: a closed loop starts with the last edge picked; an open
|
||||
/// chain runs from the free end met first in pick order. Edges that branch, or form more than one
|
||||
@@ -574,7 +565,7 @@ pub fn copy_faces(body: &Body, at: &[Vec3]) -> Result<Body> {
|
||||
}
|
||||
let chosen = picked_faces(body, at)?;
|
||||
let r = body.record();
|
||||
taken(body, &r, &chosen.into_iter().map(|f| (f, false)).collect::<Vec<_>>())
|
||||
taken(body, r, &chosen.into_iter().map(|f| (f, false)).collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
/// A body's faces taken apart: each picked face (by points on it; every face when none are given)
|
||||
@@ -587,9 +578,9 @@ pub fn unstitch(body: &Body, at: &[Vec3]) -> Result<(Vec<Body>, Option<Body>)> {
|
||||
return Err(invalid("the body has one face: nothing to unstitch"));
|
||||
}
|
||||
let chosen = picked_faces(body, at)?;
|
||||
let pieces = chosen.iter().map(|f| taken(body, &r, &[(*f, false)])).collect::<Result<Vec<_>>>()?;
|
||||
let pieces = chosen.iter().map(|f| taken(body, r, &[(*f, false)])).collect::<Result<Vec<_>>>()?;
|
||||
let rest: Vec<(usize, bool)> = (0..r.faces.len()).filter(|f| !chosen.contains(f)).map(|f| (f, false)).collect();
|
||||
let rest = if rest.is_empty() { None } else { Some(taken(body, &r, &rest)?) };
|
||||
let rest = if rest.is_empty() { None } else { Some(taken(body, r, &rest)?) };
|
||||
Ok((pieces, rest))
|
||||
}
|
||||
|
||||
@@ -603,7 +594,7 @@ pub fn reverse_faces(body: &Body, at: &[Vec3]) -> Result<Body> {
|
||||
}
|
||||
let chosen = picked_faces(body, at)?;
|
||||
let r = body.record();
|
||||
taken(body, &r, &(0..r.faces.len()).map(|f| (f, chosen.contains(&f))).collect::<Vec<_>>())
|
||||
taken(body, r, &(0..r.faces.len()).map(|f| (f, chosen.contains(&f))).collect::<Vec<_>>())
|
||||
}
|
||||
|
||||
/// A body with some of its faces (indices in its face order) taken away and the gap left open: a
|
||||
@@ -619,7 +610,7 @@ pub fn remove_faces(body: &Body, faces: &[usize]) -> Result<Body> {
|
||||
if left.is_empty() {
|
||||
return Err(invalid("that would delete every face of the body"));
|
||||
}
|
||||
taken(body, &r, &left)
|
||||
taken(body, r, &left)
|
||||
}
|
||||
|
||||
/// `h`, a history over one record whose faces and edges came from the parts `c` numbers, carried
|
||||
@@ -763,9 +754,9 @@ pub fn thicken(body: &Body, thickness: f64, symmetric: bool) -> Result<Body> {
|
||||
pub(crate) fn offset_faces(body: &Body, picked: &[usize], distance: f64, tolerance: f64) -> Result<Body> {
|
||||
let r = body.record();
|
||||
if distance == 0.0 {
|
||||
return taken(body, &r, &picked.iter().map(|f| (*f, false)).collect::<Vec<_>>());
|
||||
return taken(body, r, &picked.iter().map(|f| (*f, false)).collect::<Vec<_>>());
|
||||
}
|
||||
let moved = picked.iter().map(|f| imp::offset_face(&r, *f, distance)).collect::<Result<Vec<_>>>()?;
|
||||
let moved = picked.iter().map(|f| imp::offset_face(r, *f, distance)).collect::<Result<Vec<_>>>()?;
|
||||
let (parts, offsets) = Parts::joined(&moved.iter().collect::<Vec<_>>())?;
|
||||
let c = parts.canonical()?;
|
||||
let (result, h) = imp::stitched(&c.brep, tolerance.max(c.brep.tolerance))?;
|
||||
@@ -774,7 +765,7 @@ pub(crate) fn offset_faces(body: &Body, picked: &[usize], distance: f64, toleran
|
||||
.and_then(|h| carried(&h, &c, &offsets, 1, offset))
|
||||
.map(|h| h.faces.into_iter().map(|f| FaceProv { change: Change::Generated, ..f }).collect::<Vec<_>>());
|
||||
let rec = result.record();
|
||||
let h = faces.map(|faces| record_history(&rec, 1, faces, |_, between, faces| record::meeting(between, faces)));
|
||||
let h = faces.map(|faces| record_history(rec, 1, faces, |_, between, faces| record::meeting(between, faces)));
|
||||
Ok(result.with_checked_history(h, &record::counts(&[body])))
|
||||
}
|
||||
|
||||
@@ -850,7 +841,7 @@ pub fn extend(body: &Body, at: &[Vec3], distance: f64) -> Result<Body> {
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
let loops = vec![b::Loop::Edges { edges }];
|
||||
let domain = uv_box(&loops).ok_or_else(|| invalid("the extended face has no area"))?;
|
||||
let forward = face_sides(&r).first().copied().unwrap_or(true);
|
||||
let forward = face_sides(r).first().copied().unwrap_or(true);
|
||||
parts.faces.push((b::Face { surface, domain, loops }, forward));
|
||||
let c = parts.canonical()?;
|
||||
let h = record_history(&c.brep, 1, vec![record::from_face(0, 0, Change::Modified)], |e, _, _| {
|
||||
|
||||
Reference in New Issue
Block a user