# Voxelize

This module provides a complicated algorithm for making voxels out of regularly gridded points. Considering that this algorithm is rather complex, we are keeping it in its own module until we can simplify it, clean up the code, and make it capable of handling non-uniformly gridded points

## Voxelize Points

class PVGeo.filters.voxelize.VoxelizePoints(**kwargs)[source]

Bases: `FilterBase`

This makes a `vtkUnstructuredGrid` of scattered points given voxel sizes as input arrays. This assumes that the data is at least 2-Dimensional on the XY Plane.

RequestData(request, inInfo, outInfo)[source]

Used by pipeline to generate output

static _copy_arrays(pdi, pdo)[source]

internal helper to copy arrays from point data to cell data in the voxels.

static add_cell_data(grid, arr, name)[source]

Add a NumPy array as cell data to the given grid input

An internal helper to add the recovered information as field data

estimate_uniform_spacing(x, y, z)[source]

This assumes that the input points make up some sort of uniformly spaced grid on at least an XY plane.

get_angle(degrees=True)[source]

Returns the recovered angle if set to recover the input grid. If the input points are rotated, then this angle will reflect a close approximation of that rotation.

Parameters

degrees (bool) – A flag on to return decimal degrees or radians.

get_recovered_angle(degrees=True)[source]

DEPRECATED: use get_angle

get_spacing()[source]

Get the cell spacings

points_to_grid(xo, yo, zo, dx, dy, dz, grid=None)[source]

Convert XYZ points to a `vtkUnstructuredGrid`.

set_angle(angle)[source]

Set the rotation angle manually

set_delta_x(dx)[source]

Set the X cells spacing

Parameters

dx (float or np.array(floats)) – the spacing(s) for the cells in the X-direction

set_delta_y(dy)[source]

Set the Y cells spacing

Parameters

dy (float or np.array(floats)) – the spacing(s) for the cells in the Y-direction

set_delta_z(dz)[source]

Set the Z cells spacing

Parameters

dz (float or np.array(floats)) – the spacing(s) for the cells in the Z-direction

set_deltas(dx, dy, dz)[source]

Set the cell spacings for each axial direction

Parameters
• dx (float or np.array(floats)) – the spacing(s) for the cells in the X-direction

• dy (float or np.array(floats)) – the spacing(s) for the cells in the Y-direction

• dz (float or np.array(floats)) – the spacing(s) for the cells in the Z-direction

set_estimate_grid(flag)[source]

Set a flag on whether or not to estimate the grid spacing/rotation

set_safe_size(safe)[source]

A voxel size to use if a spacing cannot be determined for an axis

set_unique(flag)[source]

Set a flag on whether or not to try to elimate non unique elements