pyvista.UniformGrid#

class UniformGrid(uinput=None, *args, dims=None, spacing=(1.0, 1.0, 1.0), origin=(0.0, 0.0, 0.0))[source]#

Models datasets with uniform spacing in the three coordinate directions.

Can be initialized in one of several ways:

  • Create empty grid

  • Initialize from a vtk.vtkImageData object

  • Initialize based on dimensions, cell spacing, and origin.

Changed in version 0.33.0: First argument must now be either a path or vtk.vtkImageData. Use keyword arguments to specify the dimensions, spacing, and origin of the uniform grid.

Parameters
uinputstr, vtk.vtkImageData, pyvista.UniformGrid, optional

Filename or dataset to initialize the uniform grid from. If set, remainder of arguments are ignored.

dimsiterable, optional

Dimensions of the uniform grid.

spacingiterable, optional

Spacing of the uniform in each dimension. Defaults to (1.0, 1.0, 1.0). Must be positive.

originiterable, optional

Origin of the uniform grid. Defaults to (0.0, 0.0, 0.0).

Examples

Create an empty UniformGrid.

>>> import pyvista
>>> grid = pyvista.UniformGrid()

Initialize from a vtk.vtkImageData object.

>>> import vtk
>>> vtkgrid = vtk.vtkImageData()
>>> grid = pyvista.UniformGrid(vtkgrid)

Initialize using using just the grid dimensions and default spacing and origin. These must be keyword arguments.

>>> grid = pyvista.UniformGrid(dims=(10, 10, 10))

Initialize using dimensions and spacing.

>>> grid = pyvista.UniformGrid(
...     dims=(10, 10, 10),
...     spacing=(2, 1, 5),
... )

Initialize using dimensions, spacing, and an origin.

>>> grid = pyvista.UniformGrid(
...     dims=(10, 10, 10),
...     spacing=(2, 1, 5),
...     origin=(10, 35, 50),
... )

Initialize from another UniformGrid.

>>> grid = pyvista.UniformGrid(
...     dims=(10, 10, 10),
...     spacing=(2, 1, 5),
...     origin=(10, 35, 50),
... )
>>> grid_from_grid = pyvista.UniformGrid(grid)
>>> grid_from_grid == grid
True

Methods

UniformGrid.add_field_array(scalars, name[, ...])

Add field data.

UniformGrid.add_field_data(array, name[, deep])

Add field data.

UniformGrid.cast_to_pointset([deep])

Get a new representation of this object as a pyvista.PointSet.

UniformGrid.cast_to_rectilinear_grid()

Cast this uniform grid to a rectilinear grid.

UniformGrid.cast_to_structured_grid()

Cast this uniform grid to a structured grid.

UniformGrid.cast_to_unstructured_grid()

Get a new representation of this object as a pyvista.UnstructuredGrid.

UniformGrid.cell_bounds(ind)

Return the bounding box of a cell.

UniformGrid.cell_centers([vertex, progress_bar])

Generate points at the center of the cells in this dataset.

UniformGrid.cell_data_to_point_data([...])

Transform cell data into point data.

UniformGrid.cell_n_points(ind)

Return the number of points in a cell.

UniformGrid.cell_point_ids(ind)

Return the point ids in a cell.

UniformGrid.cell_points(ind)

Return the points in a cell.

UniformGrid.cell_type(ind)

Return the type of a cell.

UniformGrid.clear_arrays()

Remove all arrays from point/cell/field data.

UniformGrid.clear_cell_arrays()

Remove all cell data.

UniformGrid.clear_cell_data()

Remove all cell arrays.

UniformGrid.clear_data()

Remove all arrays from point/cell/field data.

UniformGrid.clear_field_arrays()

Remove all field data.

UniformGrid.clear_field_data()

Remove all field data.

UniformGrid.clear_point_arrays()

Remove all point data.

UniformGrid.clear_point_data()

Remove all point arrays.

UniformGrid.clear_textures()

Clear the textures from this mesh.

UniformGrid.clip([normal, origin, invert, ...])

Clip a dataset by a plane by specifying the origin and normal.

UniformGrid.clip_box([bounds, invert, ...])

Clip a dataset by a bounding box defined by the bounds.

UniformGrid.clip_scalar([scalars, invert, ...])

Clip a dataset by a scalar.

UniformGrid.clip_surface(surface[, invert, ...])

Clip any mesh type using a pyvista.PolyData surface mesh.

UniformGrid.compute_cell_quality([...])

Compute a function of (geometric) quality for each cell of a mesh.

UniformGrid.compute_cell_sizes([length, ...])

Compute sizes for 1D (length), 2D (area) and 3D (volume) cells.

UniformGrid.compute_derivative([scalars, ...])

Compute derivative-based quantities of point/cell scalar field.

UniformGrid.compute_implicit_distance(surface)

Compute the implicit distance from the points to a surface.

UniformGrid.connectivity([largest, progress_bar])

Find and label connected bodies/volumes.

UniformGrid.contour([isosurfaces, scalars, ...])

Contour an input self by an array.

UniformGrid.copy([deep])

Return a copy of the object.

UniformGrid.copy_attributes(dataset)

Copy the data attributes of the input dataset object.

UniformGrid.copy_meta_from(ido[, deep])

Copy pyvista meta data onto this object from another object.

UniformGrid.copy_structure(dataset)

Copy the structure (geometry and topology) of the input dataset object.

UniformGrid.ctp([pass_cell_data, progress_bar])

Transform cell data into point data.

UniformGrid.decimate_boundary([...])

Return a decimated version of a triangulation of the boundary.

UniformGrid.deep_copy(to_copy)

Overwrite this data object with another data object as a deep copy.

UniformGrid.delaunay_3d([alpha, tol, ...])

Construct a 3D Delaunay triangulation of the mesh.

UniformGrid.elevation([low_point, ...])

Generate scalar values on a dataset.

UniformGrid.extract_all_edges([progress_bar])

Extract all the internal/external edges of the dataset as PolyData.

UniformGrid.extract_cells(ind[, progress_bar])

Return a subset of the grid.

UniformGrid.extract_feature_edges([...])

Extract edges from the surface of the mesh.

UniformGrid.extract_geometry([progress_bar])

Extract the outer surface of a volume or structured grid dataset.

UniformGrid.extract_largest([inplace, ...])

Extract largest connected set in mesh.

UniformGrid.extract_points(ind[, ...])

Return a subset of the grid (with cells) that contains any of the given point indices.

UniformGrid.extract_subset(voi[, rate, ...])

Select piece (e.g., volume of interest).

UniformGrid.extract_surface([pass_pointid, ...])

Extract surface mesh of the grid.

UniformGrid.fft([output_scalars_name, ...])

Apply a fast Fourier transform (FFT) to the active scalars.

UniformGrid.find_cells_along_line(pointa, pointb)

Find the index of cells in this mesh along a line.

UniformGrid.find_cells_within_bounds(bounds)

Find the index of cells in this mesh within bounds.

UniformGrid.find_closest_cell(point[, ...])

Find index of closest cell in this mesh to the given point.

UniformGrid.find_closest_point(point[, n])

Find index of closest point in this mesh to the given point.

UniformGrid.find_containing_cell(point)

Find index of a cell that contains the given point.

UniformGrid.flip_normal(normal[, point, ...])

Flip mesh about the normal.

UniformGrid.flip_x([point, ...])

Flip mesh about the x-axis.

UniformGrid.flip_y([point, ...])

Flip mesh about the y-axis.

UniformGrid.flip_z([point, ...])

Flip mesh about the z-axis.

UniformGrid.gaussian_smooth([radius_factor, ...])

Smooth the data with a Gaussian kernel.

UniformGrid.get_array(name[, preference])

Search both point, cell and field data for an array.

UniformGrid.get_array_association(name[, ...])

Get the association of an array.

UniformGrid.get_data_range([arr_var, preference])

Get the non-NaN min and max of a named array.

UniformGrid.glyph([orient, scale, factor, ...])

Copy a geometric representation (called a glyph) to the input dataset.

UniformGrid.head([display, html])

Return the header stats of this dataset.

UniformGrid.high_pass(x_cutoff, y_cutoff, ...)

Perform a Butterworth high pass filter in the frequency domain.

UniformGrid.image_dilate_erode([...])

Dilates one value and erodes another.

UniformGrid.image_threshold(threshold[, ...])

Apply a threshold to scalar values in a uniform grid.

UniformGrid.integrate_data([progress_bar])

Integrate point and cell data.

UniformGrid.interpolate(target[, sharpness, ...])

Interpolate values onto this mesh from a given dataset.

UniformGrid.low_pass(x_cutoff, y_cutoff, ...)

Perform a Butterworth low pass filter in the frequency domain.

UniformGrid.median_smooth([kernel_size, ...])

Smooth data using a median filter.

UniformGrid.merge([grid, merge_points, ...])

Join one or many other grids to this grid.

UniformGrid.outline([generate_faces, ...])

Produce an outline of the full extent for the input dataset.

UniformGrid.outline_corners([factor, ...])

Produce an outline of the corners for the input dataset.

UniformGrid.overwrite(mesh)

Overwrite this dataset inplace with the new dataset's geometries and data.

UniformGrid.plot([off_screen, full_screen, ...])

Plot a PyVista, numpy, or vtk object.

UniformGrid.plot_over_circular_arc(pointa, ...)

Sample a dataset along a circular arc and plot it.

UniformGrid.plot_over_circular_arc_normal(center)

Sample a dataset along a resolution circular arc defined by a normal and polar vector and plot it.

UniformGrid.plot_over_line(pointa, pointb[, ...])

Sample a dataset along a high resolution line and plot.

UniformGrid.point_data_to_cell_data([...])

Transform point data into cell data.

UniformGrid.point_is_inside_cell(ind, point)

Return whether one or more points are inside a cell.

UniformGrid.probe(points[, tolerance, ...])

Sample data values at specified point locations.

UniformGrid.ptc([pass_point_data, progress_bar])

Transform point data into cell data.

UniformGrid.reflect(normal[, point, ...])

Reflect a dataset across a plane.

UniformGrid.rename_array(old_name, new_name)

Change array name by searching for the array then renaming it.

UniformGrid.rfft([output_scalars_name, ...])

Apply a reverse fast Fourier transform (RFFT) to the active scalars.

UniformGrid.rotate_vector(vector, angle[, ...])

Rotate mesh about a vector.

UniformGrid.rotate_x(angle[, point, ...])

Rotate mesh about the x-axis.

UniformGrid.rotate_y(angle[, point, ...])

Rotate mesh about the y-axis.

UniformGrid.rotate_z(angle[, point, ...])

Rotate mesh about the z-axis.

UniformGrid.sample(target[, tolerance, ...])

Resample array data from a passed mesh onto this mesh.

UniformGrid.sample_over_circular_arc(pointa, ...)

Sample a dataset over a circular arc.

UniformGrid.sample_over_circular_arc_normal(center)

Sample a dataset over a circular arc defined by a normal and polar vector and plot it.

UniformGrid.sample_over_line(pointa, pointb)

Sample a dataset onto a line.

UniformGrid.sample_over_multiple_lines(points)

Sample a dataset onto a multiple lines.

UniformGrid.save(filename[, binary, texture])

Save this vtk object to file.

UniformGrid.scale(xyz[, ...])

Scale the mesh.

UniformGrid.select_enclosed_points(surface)

Mark points as to whether they are inside a closed surface.

UniformGrid.set_active_scalars(name[, ...])

Find the scalars by name and appropriately sets it as active.

UniformGrid.set_active_tensors(name[, ...])

Find the tensors by name and appropriately sets it as active.

UniformGrid.set_active_vectors(name[, ...])

Find the vectors by name and appropriately sets it as active.

UniformGrid.shallow_copy(to_copy)

Shallow copy the given mesh to this mesh.

UniformGrid.shrink([shrink_factor, progress_bar])

Shrink the individual faces of a mesh.

UniformGrid.slice([normal, origin, ...])

Slice a dataset by a plane at the specified origin and normal vector orientation.

UniformGrid.slice_along_axis([n, axis, ...])

Create many slices of the input dataset along a specified axis.

UniformGrid.slice_along_line(line[, ...])

Slice a dataset using a polyline/spline as the path.

UniformGrid.slice_orthogonal([x, y, z, ...])

Create three orthogonal slices through the dataset on the three cartesian planes.

UniformGrid.split_bodies([label, progress_bar])

Find, label, and split connected bodies/volumes.

UniformGrid.streamlines([vectors, ...])

Integrate a vector field to generate streamlines.

UniformGrid.streamlines_evenly_spaced_2D([...])

Generate evenly spaced streamlines on a 2D dataset.

UniformGrid.streamlines_from_source(source)

Generate streamlines of vectors from the points of a source mesh.

UniformGrid.surface_indices([progress_bar])

Return the surface indices of a grid.

UniformGrid.tessellate([max_n_subdivide, ...])

Tessellate a mesh.

UniformGrid.texture_map_to_plane([origin, ...])

Texture map this dataset to a user defined plane.

UniformGrid.texture_map_to_sphere([center, ...])

Texture map this dataset to a user defined sphere.

UniformGrid.threshold([value, scalars, ...])

Apply a vtkThreshold filter to the input dataset.

UniformGrid.threshold_percent([percent, ...])

Threshold the dataset by a percentage of its range on the active scalars array.

UniformGrid.transform(trans[, ...])

Transform this mesh with a 4x4 transform.

UniformGrid.translate(xyz[, ...])

Translate the mesh.

UniformGrid.triangulate([inplace, progress_bar])

Return an all triangle mesh.

UniformGrid.warp_by_scalar([scalars, ...])

Warp the dataset's points by a point data scalars array's values.

UniformGrid.warp_by_vector([vectors, ...])

Warp the dataset's points by a point data vectors array's values.

Attributes

UniformGrid.active_normals

Return the active normals as an array.

UniformGrid.active_scalars

Return the active scalars as an array.

UniformGrid.active_scalars_info

Return the active scalar's association and name.

UniformGrid.active_scalars_name

Return the name of the active scalars.

UniformGrid.active_t_coords

Return or set the active texture coordinates on the points.

UniformGrid.active_tensors

Return the active tensors array.

UniformGrid.active_tensors_info

Return the active tensor's field and name: [field, name].

UniformGrid.active_tensors_name

Return the name of the active tensor array.

UniformGrid.active_vectors

Return the active vectors array.

UniformGrid.active_vectors_info

Return the active vector's association and name.

UniformGrid.active_vectors_name

Return the name of the active vectors array.

UniformGrid.actual_memory_size

Return the actual size of the dataset object.

UniformGrid.array_names

Return a list of array names for the dataset.

UniformGrid.arrows

Return a glyph representation of the active vector data as arrows.

UniformGrid.bounds

Return the bounding box of this dataset.

UniformGrid.cell_arrays

Return vtkCellData as DataSetAttributes.

UniformGrid.cell_data

Return vtkCellData as DataSetAttributes.

UniformGrid.center

Return the center of the bounding box.

UniformGrid.dimensions

Return the grid's dimensions.

UniformGrid.extent

Return or set the extent of the UniformGrid.

UniformGrid.field_arrays

Return vtkFieldData as DataSetAttributes.

UniformGrid.field_data

Return FieldData as DataSetAttributes.

UniformGrid.length

Return the length of the diagonal of the bounding box.

UniformGrid.memory_address

Get address of the underlying VTK C++ object.

UniformGrid.n_arrays

Return the number of arrays present in the dataset.

UniformGrid.n_cells

Return the number of cells in the entire dataset.

UniformGrid.n_points

Return the number of points in the entire dataset.

UniformGrid.number_of_cells

Return the number of cells.

UniformGrid.number_of_points

Return the number of points.

UniformGrid.origin

Return the origin of the grid (bottom southwest corner).

UniformGrid.point_arrays

Return vtkPointData as DataSetAttributes.

UniformGrid.point_data

Return vtkPointData as DataSetAttributes.

UniformGrid.points

Build a copy of the implicitly defined points as a numpy array.

UniformGrid.spacing

Return or set the spacing for each axial direction.

UniformGrid.t_coords

Return the active texture coordinates on the points.

UniformGrid.textures

Return a dictionary to hold compatible vtk.vtkTexture objects.

UniformGrid.vectors

Return active vectors.

UniformGrid.volume

Return the mesh volume.

UniformGrid.x

Return all the X points.

UniformGrid.y

Return all the Y points.

UniformGrid.z

Return all the Z points.