Skip to content

fix(operations): revolve an ellipse or spline edge as one wall, full or part turn - #2940

Merged
andymai merged 6 commits into
andymai:mainfrom
Robokan:fix/revolve-spline-one-wall
Nov 30, 2026
Merged

andymai merged 6 commits into
andymai:mainfrom
Robokan:fix/revolve-spline-one-wall

Conversation

@Robokan

@Robokan Robokan commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A revolve of a profile with an ellipse or B-spline edge among lines built every face once per quarter turn. A full turn's flat top came back as four quarter discs and each side wall as four quarter faces. A part turn split the same way. The volume was right but the topology wasn't: a reference kernel gives one face per profile edge.

  • Full turn (revolve an ellipse or spline arc as one wall per turn): the analytic full-turn path now takes an ellipse or spline edge. Its ends must be off the axis, and the hull of its control points must show the whole span clear of the axis. A circle arc stored as a spline keeps the old path, which sweeps an exact sphere. The new path sweeps the edge as one rational B-spline wall round the nine-point circle, with the edge as its seam.

  • Directions and neighbours: the path reads the wall's directions at the middle of a knot span inside the curve's domain. So a spline that turns at a knot still faces out. The path also clamps a profile spline to its domain before it sweeps a band or a wall. This does not change the curve on its domain.

    To judge the profile's direction, the path takes eight points on each knot span of a spline. The lines and circles beside it keep their exact planes, cylinders, cones and tori. unify_faces_keeping keeps a part turn's caps as faces of their own.

  • Part turn (a part turn of an ellipse or spline edge sweeps one wall): such an edge's wall is now one surface with a rational span per quarter turn (curve_revolution_spans). The edge at each end and every quarter's rim arcs bound it. Its first span is the band that curve_revolution_surface built, so the face's sense stays the same. An edge with an end on the axis, or not shown clear of it, keeps its wedges.

Tests

crates/operations/tests/revolve_spline_edge_faces.rs revolves a profile of lines with an elliptic arc, written as the rational B-spline a reference kernel writes for it. It runs a full turn and part turns of 90, 126, 180, 270 and 342 degrees, and asserts:

  • one face per profile edge off the axis (5 for the full turn, 7 for a part turn), with one B-spline wall;
  • a valid solid and a watertight mesh;
  • the closed-form volume within 1e-5;
  • points inside and outside, classified half way round.

The first two tests fail on main: the full turn gives 20 faces where 5 are wanted, and a quarter turn 12 where 7 are. Another test checks that a half ellipse closed along its axis revolves to the exact ellipsoid volume.

More tests cover:

  • turned and mirrored poses;
  • a spline that turns at its middle knot, and one with a narrow middle span;
  • a spline that comes to the axis between samples, which keeps its quarter faces;
  • a circle arc stored as a spline, which keeps its sphere;
  • an unclamped spline, whose knots run past its domain;
  • a native ellipse edge, stored forward and reversed;
  • quadratic splines with end knots repeated only up to the degree, or with a -0.0 end knot;
  • a spline whose shape lies in a small part of its domain, whose full turn no longer comes out inside out.

Limit: a part turn of that last spline still comes out inside out, as on main. Part turns find the profile's direction with main's three-point sample, which this PR does not change. On main, its full turn is inside out too.

revolve::tests::revolve_square_half_circle now expects 5 faces for a half turn of a square, one per side plus the two caps.

🤖 Generated with Claude Code

Robokan and others added 2 commits November 26, 2026 13:43
A profile edge that is an ellipse or B-spline arc clear of the axis now
takes the analytic full-revolution path: one rational B-spline wall from
the nine-point circle, beside the lines' exact planes and cylinders. A part
turn keeps its plane and cylinder faces whole; its caps stay faces of their
own, as a half turn sets them in one plane either side of the axis, and a
line square to the axis from a point on it no longer counts as touching it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…wall

A part turn built the wall of a curved profile edge other than a circle
one face per quarter turn, while its line and circle neighbours' bands
merged into one face each: a half turn of an ellipse arc gave two wall
faces, three quarters three. The wall is now one rational surface with a
span per quarter turn, bounded by the edge at each end and the rim arcs
of every quarter. An edge with an end on the axis keeps its wedges.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 00:00
@greptile-apps

greptile-apps Bot commented Nov 27, 2026

Copy link
Copy Markdown

PR author is not in the allowed authors list.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical tangent–normal mismatch can orient the entire revolved wall incorrectly, and the fallback also replaces recognized spherical arcs with NURBS walls.

2 open issues

Review effort: Balanced

Comment thread crates/operations/src/revolve.rs Resolved
Comment thread crates/operations/src/revolve.rs Resolved
andymai added a commit that referenced this pull request Nov 29, 2026
## Summary

`nurbs_face_over_domain` integrates a face that is its whole B-spline
surface directly over the surface's `(u, v)` domain, in panels between
its knots. Besides open patches it takes a band closed along `v`, a
blend round a closed rim, whose wire runs both closed sides and its seam
once each way.

A wall turned a whole turn with the turn along `u` is closed along `u`
instead. A full revolve of an ellipse or spline profile edge builds one
like this (#2940). The domain path declined it, so it fell to
`nurbs_face_by_boundary`, which projects every boundary point onto the
surface.

Such a wall is now read through its transpose: the same surface with `u`
and `v` swapped, whose normal points the other way, so its integrals
come out the same under the opposite sign. `closed_along_u_and_poleless`
is `closed_along_v_and_poleless` with the sides swapped.

For a profile of five lines and one ellipse arc turned a whole turn
about z:

| | before | after |
|---|---|---|
| the wall's integral | 15 ms | 4.5 ms |
| `solid_volume` (mean of 50) | 24.8 ms | 2.65 ms |
| volume against the closed form | 4e-16 | 3e-15 |

The half turn's wall, already open, takes 3.2 ms either way.

## Tests

`a_wall_closed_along_u_is_read_over_its_domain` builds a cylinder wall
of radius 5 and height 10 as a rational B-spline, turned in quarters
along `u` and, as a check, along `v`. It asserts:

- both read over their domain, at the closed-form area and volume to
1e-12;
- the two agree on the moments.

It fails without the change: the domain path returns `None` for the wall
turned along `u`.

`cargo test -p brepkit-check` passes on this branch.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

<!-- This is an auto-generated description by cubic. -->
---
## Summary by cubic
Speeds up domain integration of NURBS walls closed along `u`, such as a
full revolve's wall, which previously fell back to slower boundary
projection. The surface is read as its transpose — `u` and `v` swapped,
normal negated — so the integrals keep their sign. A wall's integral
drops from 15 ms to 4.5 ms, `solid_volume` from 24.8 ms to 2.65 ms.

- Adds a test that reads a cylinder wall turned in quarters along both
`u` and `v`, asserting both integrate over their domain with matching
area, volume, and moments; it fails before the change.

<sup>Written for commit ec52852.
Summary will update on new commits.</sup>

<a
href="https://cubic.dev/pr/andymai/brepkit/pull/2941?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>

<!-- End of auto-generated description by cubic. -->

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Andy Aragon <hi@andymai.com>
…keep a circle arc's sphere

A full turn now reads the wall's normal and the edge's tangent at the
middle of one knot span. A secant across a knot or a narrow span can run
against the tangent of the span that gives the normal, and the wall then
faced into the solid.

A circle arc that is stored as a B-spline keeps the segmented path, which
sweeps its exact sphere. A spline edge sweeps one wall only where the hull
of each Bezier piece shows that it keeps clear of the axis. Samples miss a
narrow span that comes to the axis.

Tests: a turn at the middle knot, a step back in a narrow middle span, a
dip to the axis between samples, a circle arc stored as a spline, and the
bulb turned, mirrored, and both. The first four fail without the change.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The orientation probe can select a knot span outside the curve domain and turn valid spline walls inward, and native-ellipse single-wall paths still lack coverage, including reversed arcs.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread crates/operations/src/revolve.rs Resolved
Comment on lines +1075 to +1076
None if matches!(curve, EdgeCurve::Ellipse(_) | EdgeCurve::NurbsCurve(_))
&& edge.start() != edge.end()
…l's senses in it

An unclamped spline's knots run on past its domain. The full turn read
the wall's senses at the middle of its widest knot span, which can lie
outside the domain, where the span's polynomial crosses the axis and the
wall then faced in. The senses are now read only in spans of the domain.

A profile spline is now clamped at the ends of its domain before a band
or a wall is swept from it: the same curve, its ends its first and last
control points. The ray cast reads an unclamped surface by a coarse grid
of samples, and it read points inside the swept solid as outside.

Tests: two unclamped degree-1 splines, whole and part turns, fail without
the change. The bulb's arc as a native ellipse, stored either way and run
forward or backward, sweeps one wall in whole and part turns.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Valid quadratic profiles can fail revolution with ParameterOutOfRange because clamping mishandles start-knot multiplicity and treats signed-zero knots as unequal.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment thread crates/operations/src/revolve.rs Resolved
Comment thread crates/operations/src/revolve.rs Resolved
…nding by span

Clamping cut at an end whose knot already repeated up to the degree, and
read a -0.0 end knot as unclamped, so revolve failed on such splines. An
end whose knot repeats that often is now clamped without a cut.

The full turn read a spline edge's winding from three points of its whole
domain. A spline with its shape in a small part of that domain came out
inside out. It now takes eight points per knot span, in the order the edge
is used.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Endpoint tolerance conflates distinct near-end knots, removing control points and valid spans so the swept wall can lose its original boundary edge.

2 open issues
2 resolved since last review

Review effort: Balanced

Comment thread crates/operations/src/revolve.rs Outdated
fn clamped(curve: &NurbsCurve) -> Result<NurbsCurve, brepkit_math::MathError> {
let p = curve.degree();
let (d0, d1) = curve.domain();
let eps = 1e-12 * (d1 - d0);
Clamping counted knots within 1e-12 of the domain as repeats of its end, so
a spline with a 1e-13 span next to an end lost that span and the leg it
held. It now counts them as `curve_split` does, closer than 1e-15.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

A critical winding bug caused by sparse spline sampling makes the narrow-span profile’s partial-turn wall face inward, requiring a fix and regression coverage.

3 open issues

Review effort: Balanced

Comment on lines +2468 to +2471
let profile = profile_band_curve(
&profile_curve,
fwd_seg,
(p0_start, p1_start),
@andymai
andymai merged commit 629f236 into andymai:main Nov 30, 2026
23 of 24 checks passed
andymai added a commit to Robokan/brepkit that referenced this pull request Nov 30, 2026
andymai#2940 landed as a squash commit. For each conflicted file, main's changes
since andymai#2940's head are replayed onto this branch's version.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants