Skip to content

feat(pycvc): Volume bindings (3D scalar-field facade) - #108

Merged
transfix merged 1 commit into
masterfrom
feat/pycvc-volume
Jul 19, 2026
Merged

transfix merged 1 commit into
masterfrom
feat/pycvc-volume

Conversation

@transfix

Copy link
Copy Markdown
Owner

Second pycvc brick (after Geometry, #107): the scalar-field path for RF / SDF (φ) / risk-field volumes — exactly what feeds VolumeRover3's GPU ray-cast VolumeNode.

What

  • pycvc.Volume — set_float_grid(values, nx,ny,nz, bounds…) builds a Float cvc::volume; value(i,j,k), min_value()/max_value(), bounds accessors; load/save where the SDK registers the volume handler.
  • Same SWIG-safe pimpl facade as Geometry (forward-declares cvc::volume; only the .cpp includes libcvc). native() %ignored for C++ hosts.

Robustness fix

cvc exceptions derive from boost::exception, not std::exception, so the SWIG %exception handler now has a catch(...) fallback — an unhandled cvc exception previously std::terminate'd the interpreter (reproduced via an unregistered .rawiv handler when consuming libcvc as a shared lib). Now it's a clean Python RuntimeError.

Note (follow-up, not blocking)

The .rawiv volume-file handler isn't registered when linking against libcvc.so in this SDK build — a static-initializer stripping issue for the format-handler TUs. Volume file I/O for SDK consumers (incl. the lab loading .rawiv fields) needs the handlers force-linked. Field-building from memory (the primary path) is unaffected.

ctest smoke passes (field build, value/min/max/bounds, bad-length error, tolerant file roundtrip).

The RF / signed-distance / risk-field path: build a Float cvc::volume from
a flat scalar grid + spatial bounds in Python, read voxels / min / max /
bounds, and (where the SDK registers the handler) load/save volume files.
Same SWIG-safe pimpl pattern as Geometry (forward-declares cvc::volume).

Also hardens the SWIG exception wrapper with a catch(...) fallback: cvc
exceptions derive from boost::exception (NOT std::exception), so an
unhandled one previously std::terminate'd the interpreter (hit via an
unregistered .rawiv handler in a shared-lib build) — now surfaced as a
Python RuntimeError. The volume test tolerates a missing file handler; the
field-building core is fully covered.

Uses a process-wide `static cvc::app` for the volume context (mirrors the
cvc-cli pattern; instancePtr() is protected). ctest smoke passes.
@transfix
transfix merged commit f134222 into master Jul 19, 2026
3 of 8 checks passed
@transfix
transfix deleted the feat/pycvc-volume branch July 19, 2026 02:13
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