mirror of
https://github.com/bherbruck/solidcraft.git
synced 2026-11-04 11:05:56 +00:00
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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BnQawySUFx57iaJZq7z1Fm
This commit is contained in:
@@ -1 +1 @@
|
||||
5af70704201c2abb23e6b5fa48ef6c9eea24566c
|
||||
0c5868e2ed8639cf4eae119873145755c0d1c2e9
|
||||
|
||||
@@ -409,8 +409,9 @@ fn surfaces(flat: View, n_faces: usize) -> Res<Vec<(b::Surface, Option<b::Surfac
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
/// A circle's frame turned (y reversed) where needed so that its angle grows along `form`, the
|
||||
/// NURBS the edge runs on over `range`: what [`b::Edge::curve_interval`] reads.
|
||||
/// A circle's or ellipse's frame turned (y reversed) where needed so that its angle grows along
|
||||
/// `form`, the NURBS the edge runs on over `range`: what [`b::Edge::curve_interval`] reads (an
|
||||
/// ellipse's radii scale its axes, not the way its angle turns).
|
||||
fn along(f: b::Frame, form: &b::Curve, range: [f64; 2]) -> Res<b::Frame> {
|
||||
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<b::Curve>, [
|
||||
}
|
||||
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<Nurbs> {
|
||||
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<b::Curve>, [
|
||||
);
|
||||
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()?;
|
||||
|
||||
@@ -221,11 +221,11 @@ fn laid_out(brep: &b::Brep, trusted: bool, analytic: bool) -> R<Arrays> {
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user