convert module

Module Summary

functions:

convert.colour2hex

convert.colour2rgb

convert.default_sample_grid

Calculate sample grid fine enough to capture point details resolution of smallest dimension will be minres elements

convert.export_OBJ

Export given object(s) to an OBJ file Supports only triangle mesh object data

convert.export_PLY

Export given object(s) to a PLY file Supports points or triangle mesh object data

convert.export_any

Export given object(s) to a file format supproted by trimesh, eg: GLTF or GLB file See: https://trimsh.org/trimesh.exchange.html Requires "trimesh" module Supports triangle mesh object data

convert.min_max_range

Get bounding box from a list of vertices returns (min, max, range)

convert.plot_PLY

Plot triangles from a PlyData instance.

convert.points_to_volume

Convert object vertices to a volume by interpolating points to a grid

convert.points_to_volume_3D

Interpolate points to grid and load into passed volume object

convert.points_to_volume_4D

Interpolate points to grid at each timestep

convert.points_to_volume_histogram

Using numpy.histogramdd to create 3d histogram volume grid (Easily the fastest, but less control over output)

convert.points_to_volume_tree

Using scipy.spatial.KDTree to find nearest points on grid

convert.read_any

Load using trimesh, supports GLTF etc

convert.try_import

Attempts to import a module, then runs pip install if not found and attempts again

Module Details

functions:

colour2hex(rgb)[source]
colour2rgb(c)[source]
default_sample_grid(vrange, res=8)[source]

Calculate sample grid fine enough to capture point details resolution of smallest dimension will be minres elements

export_OBJ(filepath, source, verbose=False, vertexcolours=True)[source]

Export given object(s) to an OBJ file Supports only triangle mesh object data

If source is lavavu.Viewer() exports all objects If source is lavavu.Object() exports single object

Set vertexcolours to support writing R,G,B values with vertices (not part of OBJ standard but supported in some software)

export_PLY(filepath, source, binary=True)[source]

Export given object(s) to a PLY file Supports points or triangle mesh object data

If source is lavavu.Viewer() exports all objects If source is lavavu.Object() exports single object

Parameters:
  • filepath (str) – Output file to write

  • source (lavavu.Viewer or lavavu.Object) – Where to get object data to export

  • binary (boolean) – Write vertex/face data as binary, default True

export_any(filepath, source, name=None)[source]

Export given object(s) to a file format supproted by trimesh, eg: GLTF or GLB file See: https://trimsh.org/trimesh.exchange.html Requires “trimesh” module Supports triangle mesh object data

If source is lavavu.Viewer() exports all objects If source is lavavu.Object() exports single object

Parameters:
min_max_range(verts)[source]

Get bounding box from a list of vertices returns (min, max, range)

plot_PLY(lv, filename)[source]

Plot triangles from a PlyData instance. Assumptions: has a ‘vertex’ element with ‘x’, ‘y’, and ‘z’ properties, has a ‘face’ element with an integral list property ‘vertex_indices’, all of whose elements have length 3.

points_to_volume(verts, weights=None, res=8, kdtree=False, normed=True, clamp=None, boundingbox=None)[source]

Convert object vertices to a volume by interpolating points to a grid

  • Vertex data only is used, so treated as a point cloud

  • Can also be used to sample an irregular grid to a regular so volume render matches the grid dimensions

  • Result is a density field that can be volume rendered

Default is to use numpy.histogramdd method, pass kdtree=True to use scipy.spatial.KDTree

TODO: support colour data too, converted density field becomes alpha channel (actually, use weights)

Returns:

  • values (numpy array of float32) – The converted density field

  • boundingbox (2,3) – the minimum 3d vertex of the bounding box the maximum 3d vertex of the bounding box

points_to_volume_3D(vol, objects, res=8, kdtree=False, blur=0, pad=None, normed=True, clamp=None, weights=None)[source]

Interpolate points to grid and load into passed volume object

Given a list of objects and a volume object, convert a point cloud from another object (or objects - list is supported) into a volume using points_to_volume()

points_to_volume_4D(vol, objects, res=8, kdtree=False, blur=0, pad=None, normed=True, clamp=None, weights=None)[source]

Interpolate points to grid at each timestep

Given a list of objects and a volume object, convert a time-varying point cloud from another object (or objects - list is supported) into a volume using points_to_volume_3D()

points_to_volume_histogram(verts, weights, res=8, normed=True, clamp=None, boundingbox=None)[source]

Using numpy.histogramdd to create 3d histogram volume grid (Easily the fastest, but less control over output)

points_to_volume_tree(verts, res=8)[source]

Using scipy.spatial.KDTree to find nearest points on grid

Much slower, but more control

TODO: control parameters

read_any(filepath, lv, scaling=None)[source]

Load using trimesh, supports GLTF etc

See: https://trimsh.org/trimesh.exchange.html Requires “trimesh” module

try_import(module_name, second_try=False)[source]

Attempts to import a module, then runs pip install if not found and attempts again