From 69702833ffb4669a6998d0cfa3770dc514f532b2 Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Fri, 23 Oct 2026 18:20:36 -0400 Subject: [PATCH] solidcraft-smlib: ellipse edges on their NURBS form, as circles are (fork 0c5868e) SMLib holds every ellipse as an exact rational NURBS; the fork now sends ellipse edges with that form and takes them back with it. The export reads an ellipse with its form as it reads a circle with one (its frame turned so its angle grows along the form, its trims carried over as they are); the import writes an ellipse on its form as its conic entry plus the NURBS. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01BnQawySUFx57iaJZq7z1Fm --- crates/smlib/SMLIB_REV | 2 +- crates/smlib/src/export.rs | 15 +++++++++++---- crates/smlib/src/import.rs | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/crates/smlib/SMLIB_REV b/crates/smlib/SMLIB_REV index b6bd9d907..8f227365b 100644 --- a/crates/smlib/SMLIB_REV +++ b/crates/smlib/SMLIB_REV @@ -1 +1 @@ -5af70704201c2abb23e6b5fa48ef6c9eea24566c +0c5868e2ed8639cf4eae119873145755c0d1c2e9 diff --git a/crates/smlib/src/export.rs b/crates/smlib/src/export.rs index 00727fd4e..e07dbb7ad 100644 --- a/crates/smlib/src/export.rs +++ b/crates/smlib/src/export.rs @@ -409,8 +409,9 @@ fn surfaces(flat: View, n_faces: usize) -> Res Res { let eval = b::eval::CurveEval::new(form).map_err(|e| invalid(format!("circle NURBS form: {e}")))?; let [t0, t1] = range; @@ -461,7 +462,7 @@ fn curves(flat: View, n_edges: usize) -> Res<(Vec<(b::Curve, Option, [ } let (mut nurbs, mut lines, mut circles, mut ellipses) = (0usize, 0usize, 0usize, 0usize); let (mut cv, mut kn) = (0usize, 0usize); - // The next NURBS block, in edge order: a NURBS edge's curve or a circle's NURBS form. + // The next NURBS block, in edge order: a NURBS edge's curve or a circle's or ellipse's form. let mut next_nurbs = || -> Res { let n = count(at(flat.i(EDGE_NURBS_VERTEX_COUNT), nurbs, "NURBS edge")?, "NURBS edge")?; let o = count(at(flat.i(EDGE_NURBS_ORDER), nurbs, "NURBS edge")?, "NURBS edge")?; @@ -512,7 +513,13 @@ fn curves(flat: View, n_edges: usize) -> Res<(Vec<(b::Curve, Option, [ ); let radii = [at(flat.f(EDGE_ELLIPSE_X_RADIUS), ellipses, "ellipse")?, at(flat.f(EDGE_ELLIPSE_Y_RADIUS), ellipses, "ellipse")?]; ellipses += 1; - (b::Curve::Ellipse { frame: f, radii }, None, r, None) + // Like a circle: on its NURBS form, the trims on it carry over as they are. + if forms.get(e) == Some(&1) { + let form = next_nurbs()?.record(); + (b::Curve::Ellipse { frame: along(f, &form, r)?, radii }, Some(form), r, Some([1.0, 0.0])) + } else { + (b::Curve::Ellipse { frame: f, radii }, None, r, None) + } } CURVE_NURBS => { let c = next_nurbs()?; diff --git a/crates/smlib/src/import.rs b/crates/smlib/src/import.rs index 779e7c592..e95697d8d 100644 --- a/crates/smlib/src/import.rs +++ b/crates/smlib/src/import.rs @@ -221,11 +221,11 @@ fn laid_out(brep: &b::Brep, trusted: bool, analytic: bool) -> R { let any_edge_form = brep.edges.iter().any(|e| e.nurbs.is_some()); for (e, (interval, _)) in brep.edges.iter().zip(&intervals) { - // A circle on its NURBS form: what it is (its circle entry), then the NURBS it is - // parameterised on (EDGE_NURBS_FORM). Another curve on a NURBS form is written as that + // A circle or ellipse on its NURBS form: what it is (its conic entry), then the NURBS it + // is parameterised on (EDGE_NURBS_FORM). Another curve on a NURBS form is written as that // NURBS, whose parameter the edge's interval and trims are in. let form = match (&e.curve, &e.nurbs) { - (b::Curve::Circle { .. }, Some(n)) => { + (b::Curve::Circle { .. } | b::Curve::Ellipse { .. }, Some(n)) => { curve(&mut a, &e.curve)?; edge_nurbs_block(&mut a, n)?; true