Skip to main content

Lightweight OpenVDB file I/O, mesh-to-SDF, and grid operations

Project description

tinyvdb

Lightweight Python bindings for TinyVDB — a header-only C/C++ library for OpenVDB file I/O, mesh-to-SDF conversion, and grid operations. No OpenVDB dependency required.

Built with the Python C Stable API (abi3) for broad compatibility: one wheel per platform works across Python 3.11+.

Installation

pip install tinyvdb

Pre-built wheels are available for:

Platform Architectures
Linux x86_64, aarch64
macOS x86_64, arm64
Windows AMD64

Quick start

Read a VDB file

import tinyvdb

with tinyvdb.open("smoke.vdb") as f:
    print(f.grid_count, "grids")
    print(f.header)

    f.read_grids()
    grid = f.grid(0)
    print(grid.name, grid.type_name)
    print(grid.transform)
    print(grid.metadata)

    # Access tree structure
    tree = grid.tree
    node = tree.node(0)
    print(node.type, node.origin)

Load from bytes / save round-trip

data = open("input.vdb", "rb").read()
f = tinyvdb.from_bytes(data)
f.read_grids()

# Serialize back
output = f.to_bytes(compression=tinyvdb.COMPRESS_ZIP, level=5)
open("output.vdb", "wb").write(output)
f.close()

Mesh to SDF and back

import struct
import tinyvdb

# Vertices as flat float32 buffer, faces as flat uint32 buffer
vertices = struct.pack("9f", 0,0,0, 1,0,0, 0,1,0)
faces = struct.pack("3I", 0, 1, 2)

# Convert mesh to signed distance field
sdf = tinyvdb.mesh_to_sdf(vertices, faces, voxel_size=0.05, band_width=3.0)
print(sdf.shape)  # (nx, ny, nz)

# Extract mesh via marching cubes
mesh = tinyvdb.sdf_to_mesh(sdf, isovalue=0.0)
print(mesh.num_vertices, mesh.num_faces)

CSG operations

union = tinyvdb.csg_union(sdf_a, sdf_b)
intersection = tinyvdb.csg_intersection(sdf_a, sdf_b)
difference = tinyvdb.csg_difference(sdf_a, sdf_b)

Morphology and filtering

dilated = tinyvdb.dilate(sdf, iterations=2)
eroded = tinyvdb.erode(sdf, iterations=1)
smoothed = tinyvdb.gaussian_filter(sdf, width=1, iterations=3)

Measurement

area = tinyvdb.surface_area(sdf)
vol = tinyvdb.volume(sdf)

Ray casting

hit = tinyvdb.ray_cast_sdf(sdf,
                            origin=(0, 0, -5),
                            direction=(0, 0, 1),
                            max_t=100.0)
if hit:
    print(hit["t"], hit["position"], hit["normal"])

Differential operators

grad = tinyvdb.gradient(sdf)          # -> DenseVecGrid
div  = tinyvdb.divergence(grad)       # -> DenseGrid
lap  = tinyvdb.laplacian(sdf)         # -> DenseGrid
c    = tinyvdb.curl(vec_field)        # -> DenseVecGrid

Advection and Poisson solver

advected = tinyvdb.advect(field, velocity, dt=0.01)
solution, iterations = tinyvdb.solve_poisson(rhs, max_iters=500, tolerance=1e-6)

Particles and fracture

# Rasterize particles into SDF
sdf = tinyvdb.particles_to_sdf(positions, radii,
                                voxel_size=0.05, band_width=3.0)

# Fill volume interior with spheres
result = tinyvdb.volume_to_spheres(sdf, min_radius=0.01, max_spheres=500)

# Fracture volume with cutter SDFs
pieces = tinyvdb.fracture(volume, [cutter1, cutter2])

Manifold repair

mesh = tinyvdb.make_manifold(vertices, faces,
                              resolution=50, isovalue=0.55)

numpy interop

DenseGrid supports the buffer protocol, so zero-copy access works with numpy:

import numpy as np

grid = tinyvdb.mesh_to_sdf(verts, faces, 0.1, 3.0)
arr = np.frombuffer(grid, dtype=np.float32).reshape(grid.shape)

API reference

Types

Type Description
VDBFile VDB file handle (context manager)
VDBGrid Grid accessor (name, type, transform, metadata, tree)
VDBTree Tree structure with node access
VDBNode Tree node (root, internal, or leaf)
DenseGrid 3D scalar grid with buffer protocol
DenseVecGrid 3D vector field (3-component) with buffer protocol
TriangleMesh Triangle mesh (vertices + faces as bytes)
VDBError Exception type (subclass of RuntimeError)

Constants

Constant Value Description
COMPRESS_NONE 0 No compression
COMPRESS_ZIP 1 ZIP (zlib/miniz)
COMPRESS_ACTIVE_MASK 2 Compress node masks
COMPRESS_BLOSC 4 BLOSC (LZ4)
SIGN_FLOOD_FILL 0 Exterior flood fill sign method
SIGN_SWEEP 1 Directional sweep sign method

Supported VDB versions

Reads and writes OpenVDB files version 220 through 225 (OpenVDB 3.x to 10.x+).

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tinyvdb-0.8.0.tar.gz (26.3 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

tinyvdb-0.8.0-cp311-abi3-win_amd64.whl (217.3 kB view details)

Uploaded CPython 3.11+Windows x86-64

tinyvdb-0.8.0-cp311-abi3-musllinux_1_2_x86_64.whl (1.6 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ x86-64

tinyvdb-0.8.0-cp311-abi3-musllinux_1_2_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

tinyvdb-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (539.7 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ x86-64

tinyvdb-0.8.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (523.8 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

tinyvdb-0.8.0-cp311-abi3-macosx_11_0_arm64.whl (395.7 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

tinyvdb-0.8.0-cp311-abi3-macosx_10_9_x86_64.whl (479.6 kB view details)

Uploaded CPython 3.11+macOS 10.9+ x86-64

File details

Details for the file tinyvdb-0.8.0.tar.gz.

File metadata

  • Download URL: tinyvdb-0.8.0.tar.gz
  • Upload date:
  • Size: 26.3 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tinyvdb-0.8.0.tar.gz
Algorithm Hash digest
SHA256 272b20194314af8376cccbd250d59271c69b8530cb69df96b5bdb4aef752bab7
MD5 5db2755efa8de522963e68335140e61f
BLAKE2b-256 747759513caadd322eb120f16483b5580fd28df6fcc64d6de064cf539c9744e8

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.0.tar.gz:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.8.0-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: tinyvdb-0.8.0-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 217.3 kB
  • Tags: CPython 3.11+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for tinyvdb-0.8.0-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 68262f3805f0856e049921e21d6c34ccf4d0fb718b51a55f332b87d6575bfe16
MD5 a7a243d94dd99c418ffdfb772a876a84
BLAKE2b-256 a053991bcdb5be0f2c5c815aff53ea71a283732118f30bf887ee089ad862664b

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.0-cp311-abi3-win_amd64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.8.0-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.0-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 75e59bb3b6c92253048da4851b516859ad097b36c771218947c9b27f506cf1a2
MD5 aec4b1c6f9e69189c6f732f2ea46b1d5
BLAKE2b-256 d4a8de2f849b6a37981b17dc32f29d85ea65bc99437bb885e1ea03b673351c18

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.0-cp311-abi3-musllinux_1_2_x86_64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.8.0-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.0-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7f03f9bb8967826384dd54ff79c72abf0a2d9af27ddcd57f318a7be3eaba9b6b
MD5 7467e9195aef60bb3d4f917bf19fa8f2
BLAKE2b-256 65f729778841067a851aff74a35daeb4cb4657dad81594d3b1b00add29055c0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.0-cp311-abi3-musllinux_1_2_aarch64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 b9ad5f9f62b313221bc40d84f704eecf69b2a308870acc27c645c1a232b758ef
MD5 362809b57dce10d3b14a316804e3c8f3
BLAKE2b-256 f6bf51a01029cf26908ed092f1e72cdac9a93b707c152009bdc5123b6db1c4c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.0-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.8.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 39df0a65b2f161166d3c42482e74ebe725e0de1a8aff670097bf13af6a48c73a
MD5 622bc94069d3557c98eed12cb1fb6460
BLAKE2b-256 03087642d5c88dff70636f1fd9ad63fb283170a4a2ed76d690d3164346bb88c9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.0-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.8.0-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.0-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9803eda4c3071e9ec8c0643bd21ae60eb7ffc0498ba65f07ab44041a04bd2685
MD5 afb04b4a82e5861b3a6516b376ed37ce
BLAKE2b-256 6e5551ed7656b0b7ebb054fc17c58f753d56cd4c3e7d4ef656cf072a3cf69edd

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.0-cp311-abi3-macosx_11_0_arm64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tinyvdb-0.8.0-cp311-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.0-cp311-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e71b4709bf9daf09ab61d939393a8a1832bd747b7691c9a0c3baf7971afb7f57
MD5 67511142f1be57b3f2722993f7082818
BLAKE2b-256 1ea720725a7225c43911e22ce428f2037be35fc0f1598e2c64a81e2acc2777ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.0-cp311-abi3-macosx_10_9_x86_64.whl:

Publisher: wheels.yml on syoyo/tinyvdb

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page