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
- uinput
str
,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)
.
- uinput
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
.Cast this uniform grid to a rectilinear grid.
Cast this uniform grid to a structured grid.
Get a new representation of this object as a
pyvista.UnstructuredGrid
.Return the bounding box of a cell.
UniformGrid.cell_centers
([vertex, progress_bar])Generate points at the center of the cells in this dataset.
Transform cell data into point data.
Return the number of points in a cell.
Return the point ids in a cell.
Return the points in a cell.
Return the type of a cell.
Remove all arrays from point/cell/field data.
Remove all cell data.
Remove all cell arrays.
Remove all arrays from point/cell/field data.
Remove all field data.
Remove all field data.
Remove all point data.
Remove all point arrays.
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.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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Generate evenly spaced streamlines on a 2D dataset.
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
Return the active normals as an array.
Return the active scalars as an array.
Return the active scalar's association and name.
Return the name of the active scalars.
Return or set the active texture coordinates on the points.
Return the active tensors array.
Return the active tensor's field and name: [field, name].
Return the name of the active tensor array.
Return the active vectors array.
Return the active vector's association and name.
Return the name of the active vectors array.
Return the actual size of the dataset object.
Return a list of array names for the dataset.
Return a glyph representation of the active vector data as arrows.
Return the bounding box of this dataset.
Return vtkCellData as DataSetAttributes.
Return vtkCellData as DataSetAttributes.
Return the center of the bounding box.
Return the grid's dimensions.
Return or set the extent of the UniformGrid.
Return vtkFieldData as DataSetAttributes.
Return FieldData as DataSetAttributes.
Return the length of the diagonal of the bounding box.
Get address of the underlying VTK C++ object.
Return the number of arrays present in the dataset.
Return the number of cells in the entire dataset.
Return the number of points in the entire dataset.
Return the number of cells.
Return the number of points.
Return the origin of the grid (bottom southwest corner).
Return vtkPointData as DataSetAttributes.
Return vtkPointData as DataSetAttributes.
Build a copy of the implicitly defined points as a numpy array.
Return or set the spacing for each axial direction.
Return the active texture coordinates on the points.
Return a dictionary to hold compatible
vtk.vtkTexture
objects.Return active vectors.
Return the mesh volume.
Return all the X points.
Return all the Y points.
Return all the Z points.