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

Merged
RO
1h ago
+1167-38

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