API Reference

This page lists the main functions and classes in VoxelMap v5.0.0.

Global Functions

voxelmap.objcast(filename, spacing=1)

Mesh (requires [mesh])

voxelmap.mesh.MarchingMesh(array, palette=None, out_file='scene.obj', spacing=(1.0, 1.0, 1.0), level=0.5, pad=1)

Marching-cubes per label (1,2,3,…) with OBJ+MTL export.

voxelmap.mesh.MeshView(objfile='scene.obj', palette=None, alpha=1.0, mode='both', background_color='#000000', background_image=None, wireframe_color='white', flat_color='white')
OBJ viewer with modes:
  • “solid”: surfaces colored by palette

  • “wireframe”: only edges, no fills

  • “both”: filled faces + edges (with palette)

  • “flat”: single solid color fill (ignores palette)

voxelmap.mesh.ImageMesh(image_array, out_file='scene.obj', L_sectors=4, rel_depth=1.0)

ConvexHull triangulation of 2D image sectors (geometry only).

I/O (requires [io])

voxelmap.io.save_array(array, filename)
voxelmap.io.load_array(filename)
voxelmap.io.tojson(filename, array, hashblocks=None)
voxelmap.io.load_from_json(filename)

Model Class

class voxelmap.Model(array=None, file='')

Bases: object

build()

Build voxel boolean mask from self.array

draw(coloring='custom', background_color='#cccccc', window_size=(1024, 768), len_voxel=1, show=True)

Interactive 3D voxel rendering with PyVista (voxel-drawn cubes).

draw_mpl(coloring='custom', edgecolors=None, figsize=(6.4, 4.8), axis3don=False)

Draw voxel model with matplotlib

property hashblocks
hashblocks_add(key, color, alpha=1.0)
load(filename='scene.json')

Load model from JSON only (core).

property palette

Voxel palette: maps voxel values → (color, alpha).

save(filename='scene.json')

Save model (JSON or TXT).

set_color(key: int, color: str, alpha: float = 1.0)

Set color for a voxel type.

Key methods include: - set_color — assign a color to a voxel value. - draw_mpl — render voxels with Matplotlib. - draw — interactive rendering (PyVista, requires [mesh]). - save / load — persist models as JSON or TXT. - ImageMap — map 2D images to voxel arrays.

Autosummary Index

voxelmap

voxelmap.Model([array, file])

voxelmap.io

voxelmap.io I/O utilities: save/load arrays, JSON, TXT, OBJ conversion

voxelmap.mesh

voxelmap.mesh Mesh generation and visualization utilities.

# 👇 add this section to include stub pages in the build Generated API Docs ——————