Skip to content

P3b part 1: the VolumeRover ContourTiler on cvc::planar, its tests and the legacy goldens - #1332

Merged
transfix merged 16 commits into
masterfrom
p3b/tiler-core
Nov 17, 2026
Merged

transfix merged 16 commits into
masterfrom
p3b/tiler-core

Conversation

@transfix

@transfix transfix commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

P3b of the VolumeRover library ports (docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md §3, §7): the legacy ContourTiler, vendored into src/cvc/geometry/tiler/ and ported onto cvc::planar, with no CGAL and no process-wide state. This PR is the core and its tests. cvc tile, pycvc and the tiler.tile intrinsic follow in a PR stacked on this one.

What it adds

  • cvc::tile_contours (inc/cvc/geometry/tiler.h): a const cvc::contour_stack in, one cvc::geometry per component out (triangles, normals, colours), plus the warnings. tile_params has a param_table (tiler_params.h). Files are left to the CLI.
  • tile_stepper and tile_contours_job (§1.9): phases snapping, curating, augmenting, tiling, assembling. Work within a slice pair is sliced too: correspondences per contour pair, tiling regions and the OTV table per vertex, phase 1 per OTV pair and chord step, phase 2 per untiled region, intersection removal per component pair. The legacy functions became coroutines (the skeleton port's step_task); each is still callable as before. The slowest single unit on the test series is 2.4 ms.
  • The vendored library, in three commits so the port is reviewable as a diff:
    1. the legacy sources as they are (volrover 1cf0fbd7);
    2. the port;
    3. clang-format on every new line, which CI requires.
  • The kernel (kernel.h, kernel.cpp) replaces CGAL::Cartesian<double> and Polygon_2. It keeps the names and members the vendored code calls. Predicates are Shewchuk's (exact; CGAL's Cartesian kernel rounded them).
  • The GPL rewrites, through planar_bridge.h: a grid is fitted per call, and contour vertices, already snapped to the stack's grid, cross over exactly.
    • Booleans: Clipper2.
    • Straight-skeleton offsets: wavefront_offset.
    • Convex partition: Hertel-Mehlhorn on CDT.
    • Natural-neighbour interpolation: Sibson.
    • Subcurves: a small split of our own.
    • The straight-skeleton fill and both CDT triangulate()s were never called, so they are gone.
  • log4cplus is gone. The logger is a member of the call's tiler_context; warnings and errors become tile_result::warnings. Trace and debug output is compiled out, and an error that preceded a throw is now in the exception's message. The static counters and the debug file output (tiler_output.h) are gone too.

Parity (§9 item 2, settled 2026-11-17)

tools/volrover-goldens now builds the legacy ContourTiler at the pinned sha and runs it on three committed Reconstruct series. tiler_test's T1 compares:

Case Result
tube (tiled between contour vertices only) The legacy surface, triangle for triangle: 330 of 330.
branch (caps, a branch, an annulus) Every triangle between contour vertices is the legacy's (494/494, 268/268), with the same topology. The untiled fill is within 0.13 of the slice spacing; the test allows 0.25.
touching (curation and intersection removal) Same topology; within 1.03 times the curation distance; the test allows 2 times.

Findings, also in the roadmap's §3:

  • Hashing. Under CGAL 6 the legacy's Point_2 is CGAL::Point_2, hashed by x and y only. The port's kernel hashes exactly as CGAL 6 does. With an x-y-z hash, the untiled fill lost its interpolated heights.
  • Rounding. fix_simple's 10-decimal rounding of curated contours stays: it gives an untouched contour back its own vertices after dilate and erode.
  • A legacy crash. The legacy's debug hook Callback::untiled_region returns no value. Clang's code aborts there on every untiled region, so the goldens build patches it.
  • Compilers. MSVC cannot compile the legacy kernel. The goldens were made with clang-cl 19 and CGAL 6.0.1, and GCC 16 compiles the same sources.
  • Tolerances. The legacy keeps absolute tolerances (1e-5 to 1e-11), which tiler.h now documents.
  • Platforms. The legacy's choices follow its containers' iteration order and std::sort's order of ties. The first CI run failed the branch case on wasm32 (other untiled regions) and on macOS arm64 (other contour triangles). The kernel now hashes with Boost's 64-bit arithmetic everywhere. Where size_t is 32 bits, each hash is folded as Boost.Unordered's 64-bit bucket placement folds one, so wasm32 gets the 64-bit buckets and order. Ties now sort stably (MSVC already kept input order, so Windows still matches), and the tiler compiles with -ffp-contract=off.

Tests

  • tiler_test, 20 tests:
    • T1, parity with the legacy goldens;
    • T3, known shapes: a cylinder is a closed genus-0 tube, a Y is one surface, touching components give disjoint surfaces;
    • T4, invariants on seeded stacks: closed, manifold, no self-crossings, z in range, prism volume within 2%;
    • T5, bad input: empty, one slice, gaps, self-intersecting contours, orientation, invalid parameters, scale and offset;
    • T6, no singletons: two threads, either order, two apps;
    • T7, resumable on the shared harness: bit-identical at budgets 1, 64, random and 0, cancellation, cooperative frames;
    • T8, the parameter table.
  • tiler_legacy_test: the legacy CppUnitLite2 tests on gtest, 58 tests. The file header lists each legacy test and why some can't run: they read a test_data/ that volrover never committed, or call a harness the legacy itself had commented out.
  • Both run in the ports wasm lane (CVC_PORT_TESTS) and are added to the sanitizer lanes' SAN_CXX_TESTS (ci.yml, a one-line change).

Checked locally:

  • Windows, MSVC 19.44: tiler_test 20/20 and tiler_legacy_test 58/58.
  • wasm-mt under node 22: tiler_legacy_test 58/58 and tiler_test 20/20. The series and goldens are embedded, because NODERAWFS can't read the cwd on Windows. That build reproduced CI's branch failure before the fix.
  • make_goldens.py --libs tiler --check passes on Windows.
  • GCC 16 syntax-checks the port and the legacy sources.

Not checked locally: Linux GCC and macOS builds (macOS arm64 is where the sort-tie and FMA changes matter), the sanitizer lanes, the singleton scan, and the goldens check on Linux. CI runs all of these.

…f0fbd7)

The legacy library (transfix/volrover src/ContourTiler and inc/ContourTiler at the commit
tools/volrover-goldens/volrover.sha pins), copied without changes so the next commit's diff is
the port: the library's sources and the headers they include, without its tools (ecs,
smfconvert, decimate, sandbox, ContourNear), its command line (main.cpp, cl_options.cpp), its
readers (reader_ser.h, reader_csv.h, xml/), dev.cpp, minkowski.cpp (nothing calls it),
CGAL_hash.cpp and tiler_output.cpp (debug output). Not built.
…18 settles on it

clang-format re-wraps a comment holding tabs differently on every pass, so the changed-lines check never passed on those lines. Also drops the doubled blank lines the include clean-up left.
…ts, no FMA)

The legacy's choices follow its containers' iteration order and std::sort's
order of ties. The branch parity case failed on wasm32 (other untiled regions,
other topology) and on macOS arm64 (other contour triangles).

- Hashes: Boost 1.86's 64-bit hash_value(double) and hash_combine, computed
  in 64 bits everywhere. Where size_t is 32 bits they are folded to lo32 +
  hi32, which is what Boost.Unordered's 64-bit bucket placement reduces a hash
  to, so the buckets and iteration order are the 64-bit ones. On 64-bit
  platforms the values are boost's own, unchanged.
- The four std::sort calls whose ties matter (the OTV candidates by distance
  among them) are stable_sort, so ties keep their input order on every
  standard library. MSVC already gave that order: Windows still matches the
  goldens.
- The tiler's sources compile with -ffp-contract=off, as nav, lsys and world.

Checked: native MSVC tiler_test 20/20 and tiler_legacy_test 58/58; wasm-mt
under node tiler_test 20/20, with the committed series embedded (the CI
failure reproduced first, the same numbers).
…und)

trim() calls find_last_adj(end, c.end(), p) once its cuts reach the polyline's end. The legacy then formed begin + 1 past the end and read *end (asan-ubsan: heap-buffer-overflow in TilerLegacy_intersection.intersection_poly). An empty range now returns end, which ends trim()'s loop as the legacy meant to.
@transfix
transfix merged commit 10c5d3a into master Nov 17, 2026
29 checks passed
@transfix
transfix deleted the p3b/tiler-core branch November 17, 2026 21:43
transfix added a commit that referenced this pull request Nov 18, 2026
…urfaces) (#1334)

tiler.tile with -async and -start, cvc tile with the legacy contour_tiler flags, and pycvc tile_contours / tile_contours_job, on the tiler core from #1332. Tests: tiler_intrinsics_test, cvc_cli_test Tile*, test_pycvc_tiler.py.
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