Exact profiles for splines of any degree (a degree-4…7 Bézier segment kind, Seg2::Bezier, extruded as B-spline edges) and for free-form curves cut by crossings (exact sub-curves whose ends are moved to the true crossing, found by Newton; polylines only where that fails)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AS5Tn3xieewUSg3uxrMVdL
This commit is contained in:
bherbruckandClaude Opus 5.5 committed 2026-10-08 09:42:34 +00:00
1 parent f79b5c1045
commit b9bc75670c
11 files changed
+389 -34

No files matched your search

+2 -12
View File
@@ -904,20 +904,10 @@ impl Sketch {
let p: Vec<Vec2> = pts.iter().map(pt).collect::<Option<_>>()?;
Some(crate::curves::fit_beziers(&p).into_iter().map(|[p0, p1, p2, p3]| Seg2::Cubic { p0, p1, p2, p3 }).collect())
}
CurveKind::Spline { pts, control: true, degree } if *degree <= 3 => {
CurveKind::Spline { pts, control: true, degree } if (*degree as usize) <= solvecraft_geom::MAX_BEZIER_DEGREE => {
let p: Vec<Vec2> = pts.iter().map(pt).collect::<Option<_>>()?;
let k = (*degree as usize).min(p.len().saturating_sub(1)).max(1);
Some(
crate::curves::bspline_beziers(&p, k)
.into_iter()
.filter_map(|c| match c[..] {
[a, b] => Some(Seg2::Line { a, b }),
[a, x, b] => Some(Seg2::Conic { a, apex: x, b, w: 1.0 }),
[p0, p1, p2, p3] => Some(Seg2::Cubic { p0, p1, p2, p3 }),
_ => None,
})
.collect(),
)
Some(crate::curves::bspline_beziers(&p, k).iter().filter_map(|c| solvecraft_geom::bezier(c)).collect())
}
_ => None,
}