Repository navigation
P1 part 1: cvc::tet_complex, an exact incremental Delaunay (and the Qhull decision) - #1157
Merged
Merged
Conversation
…, 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.
This was referenced Nov 12, 2026
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.
# Conflicts: # .github/workflows/ci.yml # src/cvc/tests/port_tests.cmake
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
transfix
added a commit
that referenced
this pull request
Nov 13, 2026
The one conflict was arigl_web_smoke.mjs. Both sides are kept: - the /apps/up endpoint, with #1200's ISOLATION headers on its replies as on every response; - the settle probe reads out and isolated/sab; - each case runs its before/inject and #1200's isolation check. The headless-Chrome smoke passes 6/6 here, the picked-file upload included. Master since then: #1179, #1174, #1196, #1198, #1178, #1157, #1172, #1200.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Decided 2026-11-12: Joe chose
cvc::tet_complex("Yes, tet_complex"). The roadmap's §1.2, §1.9, §2, T16 row, P1 row and §9 now say so (646b45c). Qhull stays only as the general-position cross-check intet_complex_testandcgal_ab_test. Merging still needs Joe's OK once CI is green; parts 2 and 3 build on this.Part 1 of P1, the skeletonization core (
docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md§2, §7). The roadmap asks P1's first PR to prove the incremental build against the batch build, and to settle what to do about Qhull on degenerate input before the rest of the port is built on it. This PR does both.The decision: Qhull with its flat tetrahedra dropped, or an exact incremental Delaunay
The spike (libcvc workstream, "Spike (P1)") found that incremental Qhull matches the batch build in general position, but
Qtleaves flat tetrahedra on exactly cospherical points, and nearly cospherical points get merged into a fan that isn't exactly Delaunay. The two ways out were to drop the flats and accept approximate Delaunay, or to write our own incremental Delaunay on Shewchuk's predicates. I built the second one, so both could be measured on the same inputs (cgal_ab_test, Windows, MSVC 19.44, CGAL 6.0.1):d Qbb Qt Qz)cvc::tet_complex(this PR)Why dropping the flats doesn't work: each flat tetrahedron sits between two different splits of the same planar quadrilateral, so once it is gone the tetrahedra on either side have facets with no neighbour. The cocone code walks across facets and around edges, so those holes are exactly what it can't take. Fixing them means flipping, which is most of an exact Delaunay anyway, and the nearly cospherical case would still not be Delaunay.
What
cvc::tet_complexdoes. It is an incremental Bowyer–Watson of libcvc's own, about 1,200 lines of code:orient3d/insphere(cvcpkgshewchuk-predicates);inspherewith a point off the plane.The perturbation makes the triangulation unique, so the result is CGAL's
Delaunay_triangulation_3, cell for cell, on every input, degenerate ones included. That holds whatever the insertion order or seed (tested), and wherever cells are compared, so T1 (legacy parity) and T16 (A/B) can be exact on cospherical samples too, not just in general position. At 100k points it runs at CGAL's speed, 4× faster than Qhull's batch build and about 11× faster than incremental Qhull. Stepping in 4,096-unit slices costs 1–3% over a single step.Recommendation: build P1 on
cvc::tet_complex, the exact incremental Delaunay in this PR. It is exact, it has no flats, it matches CGAL even on degenerate input, it is faster, and it is a stepper by construction. P1 then needs no Qhull at all. Qhull stays a cvcpkg package and a libcvc option; nothing else uses it yet.If you'd rather keep Qhull, I'll swap the builder behind
tet_complexto the spike's incremental Qhull in this PR, with flat tetrahedra kept as flagged zero-volume cells rather than dropped, since dropping leaves the holes above. Thetet_complexAPI stays the same either way.The roadmap's §1.2, §2 and the P1 row still say Qhull. I'll update them in this PR once you've decided.
What lands
inc/cvc/geometry/tet_complex.h,src/cvc/geometry/tet_complex.cpp.cvc::tet_complexfollowsTriangulation_data_structure_3's conventions: an infinite vertex closes the hull;neighbor(c, i)is oppositevertex(c, i); mirror indices; finite cells positively oriented as CGAL counts it; CGAL'snext_around_edgeorder forcells_around_edge. It caches circumcentres with CGAL's formula, term for term, so Voronoi vertices round as the legacytriang.dual(c)did. It also hasvalidate(), with an exact Delaunay check, andfinite_tetrahedra()in canonical form. The skeleton port's CGAL-handle adapter for the vendored cocone code comes in part 2, on top of this.cvc::tet_complex_builderis a resumable stepper (§1.9). Its phases arechecking,ordering,inserting,compactingandcircumcentres, every one sliced. A unit is a point checked, a key moved in one radix pass, a cell touched by an insertion, a cell compacted, or a circumcentre.cancel()ends the build cleanly, so aresult_jobaround it ends "cancelled". Duplicates map to their first point.cvc::delaunay_tet_complex()is the blocking build: the stepper run at budget 0.constexprtables, an RNG seeded from the options, and every insertion's state on the builder.tet_complex_testis a googletest binary inCVC_PORT_TESTS, so it also runs as wasm-mt under node in the ports lane, and it joinsSAN_CXX_TESTS. Rows:d Qbb Qt Qzin general position (uniform 300 and 5,000, clump 5,000).cgal_ab's stepped rows); no phase change does O(n) work outside the unit count.tools/cgal_ab:tet_complexrows against DT3 on everydelaunay3input, plus three new degenerate inputs (lattice 20^3, the integer sphere, the cylinder);tet_complex steppedrows; andINFOrows for what dropping Qhull's flats leaves. The README records the findings.qhullandshewchuk-predicatesfor wasm-mt;cgal-abjob's path filter watches the new files;ci.ymlkeeps its CRLF line endings.macOS
CVC_WITH_SHEWCHUKis OFF on macOS in this PR. The builder then throws a clear error,tet_complex_available()returns false, and the test skips itself. The skeleton is optional behindCVC_WITH_SHEWCHUKin the same way.Update 2026-11-12: the macOS bundles of
shewchuk-predicates(and of clipper2, cdt and nanoflann) are published on cvcpkg.org now. #1165 (open) adds macOS to the recipe's scopes, so once it mergesCVC_WITH_SHEWCHUKis on there and these tests run on macOS too.Update 2026-11-12 (late): #1165 has merged, and master is merged into this branch (72b0d1f). So this CI run is the first with
CVC_WITH_SHEWCHUKon macOS, and the tests run on Apple clang instead of skipping.Checked locally
tet_complex_testpasses 10/10, andcgal_ab_testpasses with 0 failures (CGAL 6.0.1).tet_complex_testpasses 10/10 under node 22 as built by the ports lane's configuration. On this Windows host, googletest needs a POSIXprocess.cwd()under NODERAWFS; Linux CI doesn't. The slowest 4,096-unit step was 0.55 ms; the cooperative frame run's slowest frame was 13 ms with a 4 ms slice, unbounded for now.Next (parts 2 and 3, after your decision)
Part 2. The legacy skeletonization (transfix/volrover
src/Skeletonization, UT LGPL-2.1) ported intosrc/cvc/geometry/skeleton/, with the sharedcvc::coconecore,skeleton_contextand the adapter ontotet_complex, plus §2's fixes:bounding_box,srand/randand the debug files go;It also brings
skeleton_stepperwith every phase sliced,cvc::skeletonizeand itsresult_job, the parameter table, T1–T8, andcgal_abrows comparing the skeletons built on each triangulation.Part 3.
cvc skeleton, pycvc, theskeleton.computeintrinsic (with-start/-asyncandjob.cancel), and T10–T12.