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.min_max_range

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

convert.plot_PLY

Plot triangles from a PlyData instance. Assumptions:

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

Module Details

functions:

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

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

export_OBJ(filepath, 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

export_PLY(filepath, source, binary=True)

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

min_max_range(verts)

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

plot_PLY(lv, filename)
Plot triangles from a PlyData instance. Assumptions:
`ply’ has a ‘vertex’ element with ‘x’, ‘y’, and ‘z’

properties;

`ply’ has a ‘face’ element with an integral list property

‘vertex_indices’, all of whose elements have length 3.

points_to_volume(verts, res=8, kdtree=False, normed=False, clamp=None, boundingbox=None)

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

Returns

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

  • vmin – the minimum 3d vertex of the bounding box

  • vmax – the maximum 3d vertex of the bounding box

points_to_volume_3D(vol, objects, res=8, kdtree=False, blur=0, pad=None, normed=False, clamp=None)

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=False, normed=False, clamp=None)

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, res=8, normed=False, clamp=None, boundingbox=None)

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

points_to_volume_tree(verts, res=8)

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

Much slower, but more control

TODO: control parameters