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.1.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.1-cp311-abi3-win_amd64.whl (219.3 kB view details)

Uploaded CPython 3.11+Windows x86-64

tinyvdb-0.8.1-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.1-cp311-abi3-musllinux_1_2_aarch64.whl (1.5 MB view details)

Uploaded CPython 3.11+musllinux: musl 1.2+ ARM64

tinyvdb-0.8.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (542.7 kB view details)

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

tinyvdb-0.8.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (526.1 kB view details)

Uploaded CPython 3.11+manylinux: glibc 2.17+ ARM64

tinyvdb-0.8.1-cp311-abi3-macosx_11_0_arm64.whl (398.6 kB view details)

Uploaded CPython 3.11+macOS 11.0+ ARM64

tinyvdb-0.8.1-cp311-abi3-macosx_10_9_x86_64.whl (483.2 kB view details)

Uploaded CPython 3.11+macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: tinyvdb-0.8.1.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.1.tar.gz
Algorithm Hash digest
SHA256 adcece85d567010c7a89ae00c4b186d63d0ba62c8923cc9f4bf94610f97da061
MD5 a324e31cde0903ef2fa62cb5d034cad7
BLAKE2b-256 178476091e73dd102367016370b8dbcdf431bf912ae1fd297b408061892cbbe2

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.1.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.1-cp311-abi3-win_amd64.whl.

File metadata

  • Download URL: tinyvdb-0.8.1-cp311-abi3-win_amd64.whl
  • Upload date:
  • Size: 219.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.1-cp311-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 74bef3a8da3a79e7efc6ee4abd224aa9ba28d2274c6d7181d4f064206bf1e608
MD5 bd64f53baf548035871a3e60722ec8d3
BLAKE2b-256 92a49f169e373441e7840f5462bdf32ca3973bf25d660cd8c03971c9a3952408

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.1-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.1-cp311-abi3-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.1-cp311-abi3-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 48f96922401388c9eb2cbce1273760ae3f523d87b2ded7845dfe47cb0c6dc4a3
MD5 7982b66f565392defd8957d6888e1494
BLAKE2b-256 a998ef56ca939061f43f56a965db4252897435cbb7be273e68c52483b62973ca

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.1-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.1-cp311-abi3-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.1-cp311-abi3-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8a26f6806306496eab7f39a51580e708f700abb4101a89f27773b297f55bc7ff
MD5 3a475a0317edaf91e5deadde01993afc
BLAKE2b-256 1a2b9a407b1e263d0541f93e4acaf820a518304e0dd4fb4c277e2603f53653a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.1-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.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.1-cp311-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a436af233afef6b64bbb3b1f8f58db10271aaebeaad69c4f95ccb7180fe0e1c6
MD5 52b185b8ac3f5ce65db5dc91da769365
BLAKE2b-256 9767ef5ce920d8cc547d5f6d060b3c0f4c39018f2e104c0f1e20da3cdd95d69f

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.1-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.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.1-cp311-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 3fc291e292617da4b5aadfd85ae0a4a505429317aab9af7a6718cb41b2e805dc
MD5 a2d2484fc2fd6652190f010823f3cab4
BLAKE2b-256 f818761586f3f8f87b41796eded0009f811eecf365271c6b45667bcc00768b29

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.1-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.1-cp311-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.1-cp311-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 699f9e2e4293d7b0a1b9934f317e3b516be006662c4a41ebc23aeb292a09654f
MD5 e865647ad84ac9cdeee5c7a373e9b673
BLAKE2b-256 a6dca6e72c63f923a15ac59c7206d7ead839015a6a769d3aea38da911f775596

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.1-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.1-cp311-abi3-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for tinyvdb-0.8.1-cp311-abi3-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b9a423233d52a0e07dd435a973e0a7d517af9d503cc9fea5c991f6daf1e7547d
MD5 2f15da04a45d49a21b92ed52876d4b7d
BLAKE2b-256 1484d944d71141c2dd87492b3c5fe9f476a03ac54a61a6bd61c7fa41b8031d88

See more details on using hashes here.

Provenance

The following attestation bundles were made for tinyvdb-0.8.1-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