trimesh.voxel.ops module

trimesh.voxel.ops.boolean_sparse(a, b, operation=<ufunc 'logical_and'>)

Find common rows between two arrays very quickly using 3D boolean sparse matrices.

Parameters:
  • a ((n, d) int, coordinates in space)

  • b ((m, d) int, coordinates in space)

  • operation (numpy operation function, ie:) – np.logical_and np.logical_or

Returns:

coords

Return type:

(q, d) int, coordinates in space

trimesh.voxel.ops.fill_base(sparse_indices)

Given a sparse surface voxelization, fill in between columns.

Parameters:

sparse_indices ((n, 3) int, location of filled cells)

Returns:

filled

Return type:

(m, 3) int, location of filled cells

trimesh.voxel.ops.fill_orthographic(dense)
trimesh.voxel.ops.fill_voxelization(sparse_indices)

Given a sparse surface voxelization, fill in between columns.

Parameters:

sparse_indices ((n, 3) int, location of filled cells)

Returns:

filled

Return type:

(m, 3) int, location of filled cells

trimesh.voxel.ops.indices_to_points(indices, pitch=None, origin=None)

Convert indices of an (n,m,p) matrix into a set of voxel center points.

Parameters:
  • indices ((q, 3) int, index of voxel matrix (n,m,p))

  • pitch (float, what pitch was the voxel matrix computed with)

  • origin ((3,) float, what is the origin of the voxel matrix)

Returns:

points

Return type:

(q, 3) float, list of points

trimesh.voxel.ops.matrix_to_marching_cubes(matrix, pitch=1.0)

Convert an (n, m, p) matrix into a mesh, using marching_cubes.

Parameters:

matrix ((n, m, p) bool) – Occupancy array

Returns:

mesh – Mesh generated by meshing voxels using the marching cubes algorithm in skimage

Return type:

trimesh.Trimesh

trimesh.voxel.ops.matrix_to_points(matrix, pitch=None, origin=None)

Convert an (n,m,p) matrix into a set of points for each voxel center.

Parameters:
  • matrix ((n,m,p) bool, voxel matrix)

  • pitch (float, what pitch was the voxel matrix computed with)

  • origin ((3,) float, what is the origin of the voxel matrix)

Returns:

points

Return type:

(q, 3) list of points

trimesh.voxel.ops.multibox(centers, pitch=1.0, colors=None)

Return a Trimesh object with a box at every center.

Doesn’t do anything nice or fancy.

Parameters:
  • centers ((n, 3) float) – Center of boxes that are occupied

  • pitch (float) – The edge length of a voxel

  • colors ((3,) or (4,) or (n,3) or (n, 4) float) – Color of boxes

Returns:

rough – Mesh object representing inputs

Return type:

Trimesh

trimesh.voxel.ops.points_to_indices(points, pitch=None, origin=None)

Convert center points of an (n,m,p) matrix into its indices.

Parameters:
  • points ((q, 3) float) – Center points of voxel matrix (n,m,p)

  • pitch (float) – What pitch was the voxel matrix computed with

  • origin ((3,) float) – What is the origin of the voxel matrix

Returns:

indices – List of indices

Return type:

(q, 3) int

trimesh.voxel.ops.points_to_marching_cubes(points, pitch=1.0)

Mesh points by assuming they fill a voxel box, and then running marching cubes on them

Parameters:

points ((n, 3) float) – Points in 3D space

Returns:

mesh – Points meshed using marching cubes

Return type:

trimesh.Trimesh

trimesh.voxel.ops.sparse_to_matrix(sparse)

Take a sparse (n,3) list of integer indexes of filled cells, turn it into a dense (m,o,p) matrix.

Parameters:

sparse ((n, 3) int) – Index of filled cells

Returns:

dense – Matrix of filled cells

Return type:

(m, o, p) bool

trimesh.voxel.ops.strip_array(data)