Skip to content

P1: skeleton.compute, cvc skeleton and pycvc (skeleton port, part 3) - #1171

Merged
transfix merged 25 commits into
masterfrom
p1/skeleton-surfaces
Nov 15, 2026
Merged

transfix merged 25 commits into
masterfrom
p1/skeleton-surfaces

Conversation

@transfix

@transfix transfix commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Part 3 of P1: the skeletonization's surfaces (docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md §1.6–§1.8, §2), on the part 2 port in #1167.

#1167 merged on 2026-11-14 (squash b5aae62), and master is merged in (b722023). #1157 merged before it (squash fb634c5). The diff against master is now only this PR's own work, 14 files and 946 added lines: commits fbfa5da and fd8f3e9. Those lines are identical to what the earlier CI runs tested.

What lands

skeleton.compute, the DSL intrinsic (inc/cvc/geometry/skeleton_intrinsics.h, src/cvc/geometry/skeleton/skeleton_intrinsics.cpp)

  • Built with make_job_op<skeleton_params, skeleton>, so it gets the generic forms from P0b:
    • the waiting form skeleton.compute;
    • skeleton.compute-async;
    • skeleton.compute-start, which publishes the job keys;
    • job.cancel.
  • Cooperative or threaded (sliced_threading). The parameters come from the state tree through the table.
  • The result is a dict:
    • strands, sheets and helix as geometry data objects;
    • polylines, clusters, sheet_clusters;
    • warnings.
  • add_skeleton_intrinsics(app) registers it on the app under the "skeleton" provider key. No statics.

cvc skeleton <input> -o <strands> [--sheets F] [--helix F] [--seconds S]

  • The parameters come from the table (add_param_options<skeleton_params>), with their units, ranges and docs in --help.
  • The sheets go to <stem>_sheets<ext> unless --sheets names a file.
  • The legacy flags are translated:
    • -r → --robust;
    • -bbr r → --big-ball-ratio r² (the legacy flag is a ratio of radii, the parameter a ratio of squares);
    • -thif / -thff in degrees → radians;
    • -plc → --sheet-count, -medth → --medial-theta, -medr → --medial-ratio.
  • -mr and -hc are accepted and ignored with a note: the legacy code never reads them.

pycvc (pycvc_skeleton.i, pycvc_jobs.i)

  • pycvc.skeletonize(geom, params=None, **keywords).
  • pycvc.skeleton_params as a param table: keywords, validation, copy.
  • pycvc.skeletonize_job(...), a result_job with step, cancel and take.
  • The GIL is released during the call, and skeleton_error comes through as ValueError.
  • The result's fields are copy properties.

A result_job fix (inc/cvc/core/result_job.h)

  • Once the stepper finishes, step() now reads the stepper's own final status before take().
  • Before, job.status was left at the last in-progress line. Now it ends as the stepper's summary, such as done: 1 strands, 0 sheets (0 clusters).
  • result_job_test gains AStepperOwnStatusIsReadOnceDone for it.

Tests (§2's T10, T11 and T12)

  • T10, skeleton_intrinsics_test. It is in CVC_PORT_TESTS, so it also runs on the wasm-mt ports lane.
    • The three forms run cooperative and threaded, with parameters, a job.cancel and a kill part-way through.
    • An Ariadne document starts skeleton.compute-start from an on: action under the default limits (not raised). Its job.progress takes several values while the frame loop runs, and the result lands at the target.
  • T11, test_pycvc_skeleton.py.
    • Keywords and params, the result's parts, and a bad input's ValueError.
    • Another Python thread ticks during the call, which shows the GIL is released.
    • A job steps and cancels.
  • T12, cvc_cli_test. The help, a capsule (whose strands read back with cvc info), the legacy flags, and a plane that fails with a clear message (as does an out-of-range --threshold).

Local runs:

Build Results
Windows, MSVC skeleton_intrinsics_test 9/9, result_job_test 19/19, job_intrinsics_test 21/21, cvc_cli_test --gtest_filter=*Skeleton* 4/4, pycvc_skeleton, pycvc_jobs, pycvc_params
wasm-mt under node skeleton_intrinsics_test 9/9, result_job_test 19/19, skeleton_test 10/10

macOS

macOS builds without CVC_WITH_SHEWCHUK until #1165 merges. The macOS bundles were published on 2026-11-12, and #1165 adds macOS to the recipe's scopes. Until then the skeleton is unavailable there, and every test skips cleanly:

  • skeletonize raises a clear error;
  • the C++ tests GTEST_SKIP;
  • the CLI tests skip on the command's message;
  • the pycvc test prints a skip and exits 0.

Update 2026-11-12 (late): #1165 has merged, and master is merged into this branch (099dcc3). So this CI run is the first with CVC_WITH_SHEWCHUK on macOS, and the tests run on Apple clang instead of skipping.

Update 2026-11-13: in the package-macos / libcvc-release-grpc-static job (job 131824127850), the configure step found Shewchuk's predicates. All 23 skeleton tests and the TetComplex tests passed on Apple clang. The job is still red, on two of master's tests and nothing in this PR:

package-macos isn't a required check, and PRs no longer run it (#1205).

Not in this PR

  • cvc exec doesn't see skeleton.compute yet.
    • cvc exec builds its own scheduler and doesn't read the app's intrinsic providers.
    • Hosts that read the app's providers get it, such as Ariadne documents (see the T10 Ariadne test).
    • Wiring cvc exec to the app's providers is P0a's per-app provider work, and it applies to every port's intrinsics, not only this one.

…, part 1)

The skeletonization port's tetrahedral complex (VOLROVER-LIBRARY-PORTS-ROADMAP.md §2), with
TDS_3's conventions (an infinite vertex closing the hull, neighbours opposite vertices, mirror
indices, CGAL's next_around_edge order), built by tet_complex_builder, a resumable stepper
(§1.9): checking, ordering (BRIO rounds of Morton keys, a sliced LSD radix sort), inserting
(Bowyer-Watson: a visibility walk from the last new cell, the conflict region re-starred from
the new point), compacting, circumcentres.

The predicates are Shewchuk's (cvcpkg shewchuk-predicates), with CGAL's symbolic perturbation
for cospherical and coplanar ties, so the triangulation is unique and is CGAL's
Delaunay_triangulation_3 cell for cell: cgal_ab_test's new tet_complex rows find it identical on
all 11 of its inputs, the 10^3 and 20^3 lattices, an exactly cospherical integer sphere, the
rounded sphere and a cocircular cylinder included, at 0.97-2x CGAL's speed in general position
and 4-6x Qhull's batch build. The INFO rows show what dropping Qhull's flat tetrahedra would
leave instead: 3,444 facets with no neighbour on the 10^3 lattice.

tet_complex_test (a port test, so also wasm-mt under node, and in the sanitizer lanes): exact
Delaunay and validity on clouds and degenerate input, equality with Qhull's batch build in
general position, independence of input order and seed, traversals against brute force,
duplicates, bad input, and the T7 harness. Without Shewchuk's predicates (macOS today) the
builder throws and the test skips. The ports lane installs qhull and shewchuk-predicates; the
cgal-ab job watches the new files.
The radix sort's arrays are allocated uninitialised, the point, duplicate and vertex-cell
arrays are filled while keying, the remap and the circumcentres are appended in counted loops,
and compaction moves the finite cells and then the infinite ones in two appending passes. The
slowest 4096-unit step is now 0.4-0.8 ms at 20k-100k points (cgal_ab's stepped rows report it).
§1.2's replacement table, §1.9's third-party calls, §2's triangulation and resumable phases,
the T16 row, the P1 row and §9 now say cvc::tet_complex, the exact incremental Delaunay on
Shewchuk's predicates measured in this PR, instead of Qhull. Qhull stays only as the
general-position cross-check in tet_complex_test and cgal_ab_test.
…n port, part 2)

cvc::skeletonize, skeleton_stepper and skeletonize_job (inc/cvc/geometry/skeleton.h) with
skeleton_params' table (skeleton_params.h): the legacy library (transfix/volrover
src/Skeletonization, UT LGPL-2.1) ported into src/cvc/geometry/skeleton/ as the shared
cvc::cocone core (init, util, Tight Cocone, Robust Cocone) and the skeleton stages (medial axis,
U1 and its planar clusters, U2 and its graph, polylines, stars), on tet_complex behind a
CGAL-shaped adapter (datastruct.h), so the vendored code keeps its shape.

Resumable (§1.9): every long legacy function is a C++20 coroutine that yields once per loop
iteration and per step of every walk (stepping.h); the stepper resumes the top one a unit at a
time, through the triangulation's own phases and "building", "voronoi", "tight cocone",
"medial axis", "sheets", "strands", "clean-up" and "output".

The fixes (§2): no global bounding box, no srand/rand (colours by index), no debug files (their
cases are warnings), Flat Phi and the sharp angle are parameters, the helix window is an
off-by-default parameter, and both sheets (fanned) and strands are returned. Also fixed: five
CGAL_assertion()s with side effects that release builds compiled out (has_vertex, find_acceptor),
the infinite vertex's point read in is_cospherical_pair, closed loops dropped from the strands, and
U2's dependence on the cells' memory order (the saddles are traced in a geometric order).

T1: tools/volrover-goldens builds the legacy library with CGAL (patched copies; the same five
assertions made plain calls) and writes goldens for four committed point clouds; the CI job
installs CGAL, GMP, MPFR and Boost. skeleton_test matches them exactly on the capsule, the torus
and the cospherical box, and contains all 361 legacy segments on the dumbbell (2 more, the order
effect). Also T2-T8: kernel predicates, known shapes, point-order and rigid-motion invariance,
bad input, threads and call order, the T7 harness, the parameter table. Passes natively and as
wasm-mt under node; joins the ports lane and the sanitizer lanes.
The skeletonization's surfaces, on the part 2 port:

- skeleton.compute, a job intrinsic through make_job_op<skeleton_params, skeleton>:
  the generic -start/-async forms and job.cancel come with it, cooperative or
  threaded, and the result is a dict of the strands, sheets and helix geometries,
  the polylines, the clusters and the warnings. add_skeleton_intrinsics(app)
  registers it on the app under the "skeleton" provider key.
- cvc skeleton <input> -o <strands> [--sheets] [--helix] [--seconds]: the
  parameters come from the table, and the legacy flags (-r, -bbr, -thif, -thff,
  -plc, -medth, -medr) are translated; -mr and -hc are accepted and ignored with
  a note.
- pycvc: skeletonize(geom, params=None, **keywords) and skeletonize_job, with
  skeleton_params as a param table, the GIL released and skeleton_error as
  ValueError.
- result_job: once the stepper finishes, its own final status is read before
  take(), so job.status ends as the stepper's summary instead of the last
  in-progress line.

Tests: skeleton_intrinsics_test (in CVC_PORT_TESTS, so on the wasm-mt ports
lane), result_job_test's AStepperOwnStatusIsReadOnceDone, the cvc_cli_test
skeleton cases and test_pycvc_skeleton.py.
…dicates

macOS builds without CVC_WITH_SHEWCHUK until its bundles exist; skeletonize then raises, so the test says so and exits 0, as the C++ tests skip.
@transfix
transfix enabled auto-merge (squash) November 12, 2026 08:26
The asan-ubsan job failed in TetComplex.DuplicatesMapToTheirFirstPoint with
a stack-buffer-overflow in shewchuk::detail::fast_expansion_sum_zeroelim,
called from orient3dadapt. Shewchuk's expansion sums read one element past an
input expansion on their last pass (`fnow = f[++findex]`); the value is never
used, so the predicates' results are right, but the read is out of bounds.

exact_predicates.cpp is now the only file that includes
<shewchuk/predicates.hpp>, and tet_complex.cpp calls cvc::exact::orient3d,
insphere and orient2d. The ASan builds compile that one file without ASan, as
the cvcpkg deps are, so no instrumented copy of the header's inline functions
is linked. The header itself should guard the read in cvcpkg's recipe.
…n skips

The skeleton kernel (skeleton/datastruct.cpp) calls cvc::exact::orient3d and
orient2d too, so exact_predicates.cpp stays the only file that includes
<shewchuk/predicates.hpp> and no ASan-instrumented copy of its expansion
sums is linked.
The skeleton goldens were made on Windows, and CI's check on ubuntu-24.04 compares bytes, so
it failed on box_grid, capsule and dumbbell. The legacy output differs by platform: the last
digits and the order of tied sheet polygons on the box and capsule, and on the dumbbell the
merged chains themselves (361 segments on Windows, 362 on Linux), since the legacy code walks
its cells in the allocator's memory order.

Commit the goldens CI made (two CI runs made the same bytes). skeleton_test still passes against
them: capsule, box and torus exact to 1e-9, and the port has all 362 legacy dumbbell segments
plus 1 (it also contains Windows' 361). The README and the test's comment say so.
# Conflicts:
#	.github/workflows/ci.yml
#	src/cvc/tests/port_tests.cmake
# Conflicts:
#	.github/workflows/ci.yml
#	src/cvc/tests/port_tests.cmake
# Conflicts:
#	bindings/pycvc/CMakeLists.txt
#	bindings/pycvc/pycvc.i
#	src/cvc/tests/port_tests.cmake
Both conflicts are two features added side by side, kept both:
- src/cvc-cli/main.cpp: the includes for param_cli.h (cvc skeleton) and
  input_trace.h (cvc trace).
- src/cvc-cli/cvc_cli_test.cpp: the cvc skeleton tests, then the cvc trace
  tests.
#1203 gives every cvc command its app as an argument and removes cvc_app().
- src/cvc-cli/main.cpp: the conflict was cmd_skeleton beside
  cmd_tetrahedralize2's new signature; kept both, and cmd_skeleton takes
  cvc::app & like the rest.
- cmd_trace (#1168) still had the old signature and called cvc_app(), so
  master's cvc-cli does not build; it takes cvc::app & too, the same change
  as the separate fix for master.
…urfaces

A clean merge. #1225 makes master build again after #1203; its cmd_trace
change is the one this branch already had. The diff against master is only
this PR's own 14 files again.
transfix added a commit that referenced this pull request Nov 15, 2026
…os, exp, sqrt or tanh on the GPU (#1219)

* EWave: each mode's rates from a texture worked out in double, not sqrt and tanh in float

cvcgl_ewave fails on the macOS package lanes (Apple Software Renderer): the
GPU window drifts from the CPU one at a steady 4.2e-3 of the RMS height per
second of simulated time, the same at dt 0.2 and 0.1, to 3e-2 by step 48
against a 1e-3 bound (#1171, job 131824127881). A per-step
error in cos, sin or exp would double its rate when dt halves; a rate off by
about 1e-3 (omega = sqrt(g kappa), kappa = k tanh(min(k d, 20))) does not.
#1174's macOS package jobs were all cancelled, so it never showed there.

The update pass now reads omega, kappa / omega, g / omega and the damping
rate from an RGBA32F texture that init() fills in double with the CPU
window's formulas (det::tanh), and takes only the cos, sin and exp of a step,
so a new dt still costs nothing.

On Windows (Intel Arc) cvcgl_ewave passes before and after: step 48 h 1.95e-5
before, 1.92e-5 after; the wall run 5.62e-5 before, 5.60e-5 after.

* EWave: each step's coefficients and real-space factors from the host, no cos/sin/exp on the GPU

The first try (fea1efb) moved each mode's rates to a texture worked out in double but left the
step's cos, sin and exp in the shader. On macOS CI (Apple Software Renderer) cvcgl_ewave failed
with the same numbers to the digit: h 3.05e-2 at step 48, the wall run 4.36e-2. So the rates were
never the problem. A drift that grows per second of simulated time is what a sin or cos off in
proportion to its small angle gives.

Now the host works out, in double and only when dt or the mask changes, what ewave::prepare and
ewave::step work out on the CPU: each mode's 2 x 2 update with its damping (RGBA32F) and each
cell's real-space factor (R32F, the beach, the sponge and land). The update and real-space passes
are multiply-adds only. A new dt costs that host work and an n^2 upload; the same dt costs nothing
more.

Windows (Intel Arc): cvcgl_ewave step 48 h 1.92e-5 -> 8.80e-6, phi -> 9.06e-6; the wall run
5.60e-5 -> 9.62e-6. So Intel's in-shader cos/sin/exp were most of its GPU-CPU difference too.
@transfix
transfix merged commit a2d5d0b into master Nov 15, 2026
49 of 50 checks passed
@transfix
transfix deleted the p1/skeleton-surfaces branch November 15, 2026 09:45
transfix added a commit that referenced this pull request Nov 15, 2026
#1171 (P1 part 3: skeleton.compute, cvc skeleton, pycvc) added its job to pycvc_jobs.i and its
CLI tests to cvc_cli_test.cpp where this branch adds segment_seeded_job and the cvc segment
tests. Both kept, segmentation first.
transfix added a commit that referenced this pull request Nov 15, 2026
- stream_intrinsics.cpp: the stream provider stays `any`, and #1236's raster verbs are a provider
  of their own, registered `host_proxied`: they are synchronous, raster-open and raster-publish
  write the raster's mirrors into the state tree raw (write_node), and one thread paints and
  publishes a raster, so in an `any` group they run on the host thread. Registered host_only (the
  default) they would have put every isolated document of an app with the stream verbs in a
  host-affinity group.
- STATE_EXEC_THREADED.md: the raster verbs and #1171's skeleton provider in the provider table,
  and the file list.
transfix added a commit that referenced this pull request Nov 15, 2026
No conflicts. Master brings 26 commits (#1171, #1191, #1221, #1236,
#1245, #1248, #1250 and others); none adds a writable global, a function
static or a signal handler to the hosts or examples, and none touches
the allowlist.
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.

1 participant