diff --git a/crates/kernel/src/bridge.rs b/crates/kernel/src/bridge.rs index 4f66db2b6..7f2f0677e 100644 --- a/crates/kernel/src/bridge.rs +++ b/crates/kernel/src/bridge.rs @@ -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]`. diff --git a/crates/kernel/src/loft_rails.rs b/crates/kernel/src/loft_rails.rs index 5c65c5f1e..6f6d2b460 100644 --- a/crates/kernel/src/loft_rails.rs +++ b/crates/kernel/src/loft_rails.rs @@ -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>) -> Result
{ - let curves = segs.iter().map(|s| Ok(nurbs(&crate::freeform::segment(plane, s)?.0)?)).collect::>>()?; + let curves = segs.iter().map(|s| nurbs(&crate::freeform::segment(plane, s)?.0)).collect::>>()?; Ok(Section { plane: *plane, curves, numbers }) } } diff --git a/crates/kernel/src/surfaces.rs b/crates/kernel/src/surfaces.rs index f913517cc..78546a74a 100644 --- a/crates/kernel/src/surfaces.rs +++ b/crates/kernel/src/surfaces.rs @@ -302,7 +302,7 @@ pub(crate) fn surface_body(r: &Brep) -> Result { pub(crate) fn all_new(body: Body, operands: &[&Body]) -> Result { 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 { 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 { - 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 { } let chosen = picked_faces(body, at)?; let r = body.record(); - taken(body, &r, &chosen.into_iter().map(|f| (f, false)).collect::>()) + taken(body, r, &chosen.into_iter().map(|f| (f, false)).collect::>()) } /// 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, Option)> { 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::>>()?; + let pieces = chosen.iter().map(|f| taken(body, r, &[(*f, false)])).collect::>>()?; 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 { } let chosen = picked_faces(body, at)?; let r = body.record(); - taken(body, &r, &(0..r.faces.len()).map(|f| (f, chosen.contains(&f))).collect::>()) + taken(body, r, &(0..r.faces.len()).map(|f| (f, chosen.contains(&f))).collect::>()) } /// 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 { 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 { pub(crate) fn offset_faces(body: &Body, picked: &[usize], distance: f64, tolerance: f64) -> Result { let r = body.record(); if distance == 0.0 { - return taken(body, &r, &picked.iter().map(|f| (*f, false)).collect::>()); + return taken(body, r, &picked.iter().map(|f| (*f, false)).collect::>()); } - let moved = picked.iter().map(|f| imp::offset_face(&r, *f, distance)).collect::>>()?; + let moved = picked.iter().map(|f| imp::offset_face(r, *f, distance)).collect::>>()?; let (parts, offsets) = Parts::joined(&moved.iter().collect::>())?; 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::>()); 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 { .collect::>>()?; 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, _, _| {