Skip to content

P3b part 2: cvc tile, pycvc and tiler.tile (the ContourTiler port's surfaces) - #1334

Merged
transfix merged 25 commits into
masterfrom
p3b/tiler-surfaces
Nov 18, 2026
Merged

transfix merged 25 commits into
masterfrom
p3b/tiler-surfaces

Conversation

@transfix

@transfix transfix commented Nov 17, 2026 •

Copy link
Copy Markdown
Owner

P3b part 2 of the VolumeRover library ports (docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md §3, §7): the tiler from #1332 on the command line, in pycvc and in the DSL.

The core, #1332, merged on 2026-11-17 (10c5d3a). This PR now targets master, with master merged in, and its diff is only the surfaces.

What it adds

  • tiler.tile (inc/cvc/geometry/tiler_intrinsics.h): tile_contours_job behind cvc/core/job_intrinsics.h's three forms, tiler.tile, -async and -start.
    • The stack is a data object, or a state path naming a node's data channel.
    • The parameters are a dict of tile_params' fields; params.defaults "tiler.tile" lists them.
    • The result is a dict of surfaces (component name to a cvc::geometry data object) and warnings. The roadmap's table said a plain dict of surfaces; the warnings entry keeps a skipped contour's warning, and the table is updated.
    • -start publishes the job keys under its target; a node's target is <node>.tiler (§3).
    • add_tiler_intrinsics(app) registers it for Ariadne documents, as add_skeleton_intrinsics does.
  • cvc tile: reads any contour format (.ser, .contour, .cvcc, ...) and writes <outdir>/<basename><component>_tiles.<ext> per component, plus <basename>_tiles.<ext> for all components, as the legacy tool did.
    • Flags come from tile_params' table.
    • The legacy cl_parse flags are rewritten to them: -C -e -r -v, -c/-x (exact names, escaped into --include/--exclude patterns), -s first last, -z (slice spacing), --color r g b, -d -b -n, -o raw, --printcomponents. So VolumeRover2's free-text default -C 0.01 -e 1e-15 -o raw works as is.
    • Accepted and ignored, with a note: the debug-output flags (-i -p -R -B -T -O -P -V -U), -f, and -m, -F, -S -1, which the legacy ignored for a series.
    • Refused: -o gnuplot, -I and smoothing (-S n).
    • The roadmap's cvc tile in.ser -o outdir became -d outdir, since -o stays the legacy output format.
  • pycvc (pycvc_tiler.i, pycvc_jobs.i):
    • pycvc.tile_contours(stack, curation_delta=0.01, ...) takes tile_params or its fields as keywords, and releases the GIL. Bad input raises ValueError.
    • The result gives names(), surface(name) (KeyError for a component with none), surfaces (a dict of geometries) and warnings.
    • pycvc.tile_contours_job(...) is the resumable job.

The one thing the keys don't carry is the slice pair being tiled. job_keys publishes status only at start and finish, and phase as "tiling 42%". tile_stepper::label() has the pair, for P4's contour_lab to show in its progress bar. Publishing it through the shared job keys would change every port's keys, so it is left for P4.

Tests

  • tiler_intrinsics_test (T10), 9 tests:

    • the three forms, cooperative and threaded;
    • a stack as a path and as a data object;
    • parameters, with bad ones raising at the call, including a curation_delta the slices are too close for;
    • params.defaults;
    • job.cancel and kill;
    • an Ariadne action starting tiler.tile-start under the default limits, with <node>.tiler.progress rising across frames.

    It joins CVC_PORT_TESTS (the wasm lane) and SAN_CXX_TESTS (ci.yml, a one-line change).

  • cvc_cli_test (T12): help, a tube, the legacy flags (component filters, slice range, base name, colour, --printcomponents, notes), and bad input.

  • test_pycvc_tiler.py (T11): a tube, keywords and params, ValueError, another thread running during the call, the job's steps and cancel.

Checked locally:

  • Windows, MSVC 19.44: tiler_intrinsics_test 9/9; cvc_cli_test *Tile* 4/4 (and *Skeleton* 4/4); ctest pycvc_tiler, pycvc_jobs, pycvc_skeleton, pycvc_contours, pycvc_segmentation and pycvc_params pass.
  • wasm-mt under node 22: tiler_intrinsics_test 9/9. The local relink drops NODERAWFS on Windows; the test reads no files.
  • cvc tile on the committed branch series writes both surfaces and reports the legacy's untiled-region warning.

Not checked locally: Linux and macOS, the sanitizer lanes, the singleton scan (no statics added). 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.
tiler_tile_op wraps tile_contours_job in cvc/core/job_intrinsics.h's three
forms. The result is a dict of "surfaces" (component name to a cvc::geometry
data object) and "warnings", so a skipped contour is not lost. -start
publishes the job keys under its target; a node's is <node>.tiler.

tiler_intrinsics_test (T10): the three forms cooperative and threaded, a stack
as a state path or a data object, bad parameters raising at the call,
job.cancel and kill, params.defaults, and an Ariadne action starting it under
the default limits. In the ports lane and the sanitizer lanes.
Reads any contour format and writes one surface per component,
<outdir>/<basename><component>_tiles.<ext>, and all of them as
<basename>_tiles.<ext>, as the legacy contour_tiler did. The parameters come
from tile_params' table; the legacy flags (-C -e -r -v -c -x -s -z --color -d
-b -n -o raw --printcomponents) are rewritten to them. Debug-output flags and
the ones the legacy ignored for a series are accepted with a note; -o gnuplot,
-I and smoothing are refused.

cvc_cli_test: help, a tube, the legacy flags (component filters, slice range,
base name, colour, --printcomponents) and bad input.
pycvc_tiler.i wraps tile_contours on a contour_stack, with tile_params' fields
as keywords, and its result: names(), surface(name) (KeyError for none), the
surfaces as a dict of geometries, and the warnings. The call releases the GIL.
pycvc_jobs.i adds tile_contours_job.

test_pycvc_tiler.py (T11): a tube, keywords and params, ValueError for bad
input, another thread running during the call, the job's steps and cancel.
…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.
# Conflicts:
#	.github/workflows/ci.yml
…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.
Base automatically changed from p3b/tiler-core to master November 17, 2026 21:43
…tiler-surfaces

# Conflicts:
#	.github/workflows/ci.yml
#	docs/roadmap/VOLROVER-LIBRARY-PORTS-ROADMAP.md
#	src/cvc/CMakeLists.txt
#	src/cvc/tests/port_tests.cmake
@transfix
transfix merged commit a7cf5f9 into master Nov 18, 2026
29 checks passed
@transfix
transfix deleted the p3b/tiler-surfaces branch November 18, 2026 08:59
transfix added a commit that referenced this pull request Nov 18, 2026
…twin

TilerIntrinsicsAriadne.AnActionStartsItUnderTheDefaultLimits (#1334) tiles a 30-slice tube
through an action's frame loop under ctest's default 300 s and a 300 s loop of its own. It takes
109-111 s in a Debug job (two other branches' package-linux / libcvc-debug runs today); on
#1351's run 44274032889 the runner was 3-5x slower (the segmentation twin took
548 s, the skeleton's 31 s against 10 s) and it timed out three times. Its segmentation twin got
ctest TIMEOUT 900 and a 900 s loop for the same reason; this gives it the same.
transfix added a commit that referenced this pull request Nov 18, 2026
…tprint (after #1349) (#1351)

* water: fade each glitter ripple by its own pixel footprint, twelve of them

The rings on terrain_lab's lake were the A4 shading's glitter ripples (oMicroSlope)
aliasing. They faded together as the isotropic footprint (the geometric mean of the
pixel's axes) grew from 0.12 m to 0.5 m. At a grazing angle the mean hides the long
axis: from 140 m at 10 degrees a pixel is 0.1 m across the view and 0.58 m along it,
the mean read 0.24 m and kept 80 % of the waves, and the pixel sampled them along the
view at under two pixels a crest. A fixed wave sampled past that aliases into a zone
plate: evenly spaced rings round the screen point where it is one crest a pixel. They
kept their place on the screen when the orbit centre moved; with the ripples off they
were gone.

Each ripple now fades by how far its own phase turns across the pixel (the rest
position's screen derivatives, along the wave's direction): whole within an eighth of a
turn, gone at a quarter. The variance it drops goes to the GGX lobe, as the shared fade's
did. oWaterFull takes the derivatives (dpx, dpy), which both callers (the water node,
lsystem_coast) already take before any branch.

Twelve ripples in place of six (1.7 m down to 0.43 m in equal ratios, golden-ratio
directions within 0.95 rad of the wind, scattered phases): six fixed waves of equal
steepness sum to a pattern that repeats, read as regular parallel ridges near the camera
at 16 m/s and, once the rings were gone, a diagonal lattice further off. With the
ripples off the near grid's own waves leave the lake almost flat, so they carry its
texture.

* water: the ripples skip a pixel too coarse for them, from constant tables

A pixel too coarse for the longest ripple whichever way it runs (k times its shortest
axis, bounded below by its area over the root of its axes' squares, at least a quarter
turn) skips the loop, as the shared fade skipped it past 0.5 m: far water costs what it
did. The wavenumbers, frequencies and direction cosines are constants, not worked out
per fragment.

Measured with a scratch harness (oWaterFull on a full 1280 x 720 quad, glFinish over 100
quads, old and new alternated 12 times, Intel Arc iGPU): 0.081 ms a frame more than the
six ripples' 0.087 where every ripple is resolved, 0.054 on terrain_lab's grazing view,
0.001 where none is.

* water: the cascades' slopes per fragment, filtered at the pixel's footprint

The near grid took its normal from its vertices (central differences 1-4 m wide over 2-8 m
triangles), which drops every wave under about 4 m, a lake's short-cascade peak; the far grid
took central differences of nearest texels per fragment.

OceanCascades now writes each cascade's height slopes (the spectrum's own dh/dx and dh/dy,
which the time pass works out for the Jacobian's buffers) into a layer of an RG16F 2D texture
array, one pass with a draw buffer a layer, and mipmaps it. Both grids read it per fragment with
textureGrad at their own footprint (anisotropic where the context can), so the waves a pixel
cannot resolve average away instead of aliasing. The near grid's vertex normal carries only the
swell; oWaterFull's nstep is 0 (nothing coarser than the pixel bounds the normal). One more
fragment sampler: cvcgl_ariadne_realize's 16-unit scene draws with none short.

vtkOpenGLFramebufferObject::AddColorAttachment attaches a texture array's layer as a 2D texture
and leaves the attachment empty, so the layers are attached with glFramebufferTextureLayer.
cvcgl_ocean_fft checks the layers against the height tiles' central differences (correlation
0.93-0.96, ratio 1.11-1.19 at N = 64) and counts the pass (3 + 2 log2 N).

On terrain_lab's sheltered lake little changes: the lee scales the cascades to about 0.06-0.3,
and the ripples, which take the share the lee removes, still carry most of the near texture.
With the lee off at 16 m/s the cascades' slopes draw a short-crested sea. No rings in any view.

Cost (scratch harness, full 1280 x 720 quad, Intel Arc iGPU): near grid +0.018 ms close,
+0.051 ms grazing; far grid -0.085 ms, -0.07 ms grazing (two filtered reads in place of eight
nearest fetches); slope pass and mipmaps +0.08 ms a frame.

* tests: the tiler's action test gets the segmentation's 900 s, as its twin

TilerIntrinsicsAriadne.AnActionStartsItUnderTheDefaultLimits (#1334) tiles a 30-slice tube
through an action's frame loop under ctest's default 300 s and a 300 s loop of its own. It takes
109-111 s in a Debug job (two other branches' package-linux / libcvc-debug runs today); on
#1351's run 44274032889 the runner was 3-5x slower (the segmentation twin took
548 s, the skeleton's 31 s against 10 s) and it timed out three times. Its segmentation twin got
ctest TIMEOUT 900 and a 900 s loop for the same reason; this gives it the same.
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