class PolyData(var_inp=None, faces=None, n_faces=None, lines=None, n_lines=None, strips=None, n_strips=None, deep=False, force_ext=None, force_float=True)[source]#

Dataset consisting of surface geometry (e.g. vertices, lines, and polygons).

Can be initialized in several ways:

  • Create an empty mesh

  • Initialize from a vtk.vtkPolyData

  • Using vertices

  • Using vertices and faces

  • From a file

var_inpvtk.vtkPolyData, str, sequence, optional

Flexible input type. Can be a vtk.vtkPolyData, in which case this PolyData object will be copied if deep=True and will be a shallow copy if deep=False.

Also accepts a path, which may be local path as in 'my_mesh.stl' or global path like '/tmp/my_mesh.ply' or 'C:/Users/user/my_mesh.ply'.

Otherwise, this must be a points array or list containing one or more points. Each point must have 3 dimensions.

facessequence, optional

Face connectivity array. Faces must contain padding indicating the number of points in the face. For example, the two faces [10, 11, 12] and [20, 21, 22, 23] will be represented as [3, 10, 11, 12, 4, 20, 21, 22, 23]. This lets you have an arbitrary number of points per face.

When not including the face connectivity array, each point will be assigned to a single vertex. This is used for point clouds that have no connectivity.

n_facesint, optional

Number of faces in the faces connectivity array. While optional, setting this speeds up the creation of the PolyData.

linessequence, optional

The line connectivity array. Like faces, this array requires padding indicating the number of points in a line segment. For example, the two line segments [0, 1] and [1, 2, 3, 4] will be represented as [2, 0, 1, 4, 1, 2, 3, 4].

n_linesint, optional

Number of lines in the lines connectivity array. While optional, setting this speeds up the creation of the PolyData.

stripssequence, optional

Triangle strips connectivity array. Triangle strips require an initial triangle, and the following points of the strip. Each triangle is built with the new point and the two previous points. Just as in lines and faces, this array requires a padding indicating the number of points. For example, a single triangle strip of [0, 1, 2, 3, 6, 7, 4, 5, 0, 1] requires padding of 10 and should input as [10, 0, 1, 2, 3, 6, 7, 4, 5, 0, 1].

n_stripsint, optional

Number of strips in the strips connectivity array. While optional, setting this speeds up the creation of the PolyData.

deepbool, optional

Whether to copy the inputs, or to create a mesh from them without copying them. Setting deep=True ensures that the original arrays can be modified outside the mesh without affecting the mesh. Default is False.

force_extstr, optional

If initializing from a file, force the reader to treat the file as if it had this extension as opposed to the one in the file.

force_floatbool, optional

Casts the datatype to float32 if points datatype is non-float. Default True. Set this to False to allow non-float types, though this may lead to truncation of intermediate floats when transforming datasets.


>>> import vtk
>>> import numpy as np
>>> from pyvista import examples
>>> import pyvista

Create an empty mesh.

>>> mesh = pyvista.PolyData()

Initialize from a vtk.vtkPolyData object.

>>> vtkobj = vtk.vtkPolyData()
>>> mesh = pyvista.PolyData(vtkobj)

Initialize from just vertices.

>>> vertices = np.array([[0, 0, 0], [1, 0, 0], [1, 0.5, 0], [0, 0.5, 0]])
>>> mesh = pyvista.PolyData(vertices)

Initialize from vertices and faces.

>>> faces = np.hstack([[3, 0, 1, 2], [3, 0, 3, 2]])
>>> mesh = pyvista.PolyData(vertices, faces)

Initialize from vertices and lines.

>>> lines = np.hstack([[2, 0, 1], [2, 1, 2]])
>>> mesh = pyvista.PolyData(vertices, lines=lines)

Initialize from vertices and triangle strips.

>>> strips = np.hstack([[4, 0, 1, 3, 2]])
>>> mesh = pyvista.PolyData(vertices, strips=strips)

Initialize from a filename.

>>> mesh = pyvista.PolyData(examples.antfile)

See Create PolyData for more examples.


PolyData.add_field_array(scalars, name[, deep])

Add field data.

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

Add field data.

PolyData.boolean_add(*args, **kwargs)

Merge two meshes together.

PolyData.boolean_cut(*args, **kwargs)

Cut two meshes.

PolyData.boolean_difference(other_mesh[, ...])

Perform a boolean difference operation between two meshes.

PolyData.boolean_intersection(other_mesh[, ...])

Perform a boolean intersection operation on two meshes.

PolyData.boolean_union(other_mesh[, ...])

Perform a boolean union operation on two meshes.


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


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


Return the bounding box of a cell.

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


Return the coordinates for the center of mass of the mesh.

PolyData.clean([point_merging, tolerance, ...])

Clean the mesh.


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.

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

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

PolyData.clip_box([bounds, invert, factor, ...])

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

PolyData.clip_closed_surface([normal, ...])

Clip a closed polydata surface with a plane.

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

Clip a dataset by a scalar.

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

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

PolyData.collision(other_mesh[, ...])

Perform collision determination between two polyhedral surfaces.


Compute the arc length over the length of the probed line.


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

PolyData.compute_cell_sizes([length, area, ...])

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

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

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


Compute the implicit distance from the points to a surface.

PolyData.compute_normals([cell_normals, ...])

Compute point and/or cell normals for a mesh.

PolyData.connectivity([largest, progress_bar])

Find and label connected bodies/volumes.

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

Contour an input self by an array.


Return a copy of the object.


Copy the data attributes of the input dataset object.


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

PolyData.copy_meta_from(ido[, deep])

Copy pyvista meta data onto this object from another object.


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

PolyData.ctp([pass_cell_data, progress_bar])

Transform cell data into point data.

PolyData.curvature([curv_type, progress_bar])

Return the pointwise curvature of a mesh.

PolyData.decimate(target_reduction[, ...])

Reduce the number of triangles in a triangular mesh using vtkQuadricDecimation.


Return a decimated version of a triangulation of the boundary.

PolyData.decimate_pro(reduction[, ...])

Reduce the number of triangles in a triangular mesh.


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

PolyData.delaunay_2d([tol, alpha, offset, ...])

Apply a 2D Delaunay filter along the best fitting plane.

PolyData.delaunay_3d([alpha, tol, offset, ...])

Construct a 3D Delaunay triangulation of the mesh.

PolyData.edge_mask(angle[, progress_bar])

Return a mask of the points of a surface mesh that has a surface angle greater than angle.

PolyData.elevation([low_point, high_point, ...])

Generate scalar values on a dataset.


Push each individual cell away from the center of the dataset.

PolyData.extract_all_edges([use_all_points, ...])

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

PolyData.extract_cells(ind[, progress_bar])

Return a subset of the grid.


Extract edges from the surface of the mesh.

PolyData.extract_geometry([extent, progress_bar])

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

PolyData.extract_largest([inplace, progress_bar])

Extract largest connected set in mesh.

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

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

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

Extract surface mesh of the grid.

PolyData.extrude(vector[, capping, inplace, ...])

Sweep polygonal data creating a "skirt" from free edges.

PolyData.extrude_rotate([resolution, ...])

Sweep polygonal data creating "skirt" from free edges and lines, and lines from vertices.

PolyData.extrude_trim(direction, trim_surface)

Extrude polygonal data trimmed by a surface.

PolyData.fill_holes(hole_size[, inplace, ...])

Fill holes in a pyvista.PolyData or vtk.vtkPolyData object.

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

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

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

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

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

Flip mesh about the normal.


Flip normals of a triangular mesh by reversing the point ordering.

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

Flip mesh about the x-axis.

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

Flip mesh about the y-axis.

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

Flip mesh about the z-axis.

PolyData.geodesic(start_vertex, end_vertex)

Calculate the geodesic path between two vertices using Dijkstra's algorithm.

PolyData.geodesic_distance(start_vertex, ...)

Calculate the geodesic distance between two vertices using Dijkstra's algorithm.

PolyData.get_array(name[, preference])

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

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

Get the association of an array.

PolyData.get_data_range([arr_var, preference])

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

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

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

PolyData.head([display, html])

Return the header stats of this dataset.


Integrate point and cell data.

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

Interpolate values onto this mesh from a given dataset.

PolyData.intersection(mesh[, split_first, ...])

Compute the intersection between two meshes.

PolyData.merge(dataset[, merge_points, ...])

Merge this mesh with one or more datasets.

PolyData.multi_ray_trace(origins, directions)

Perform multiple ray trace calculations.

PolyData.outline([generate_faces, progress_bar])

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

PolyData.outline_corners([factor, progress_bar])

Produce an outline of the corners for the input dataset.


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

PolyData.partition(n_partitions[, ...])

Break down input dataset into a requested number of partitions.

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

Plot a PyVista, numpy, or vtk object.

PolyData.plot_boundaries([edge_color, ...])

Plot boundaries of a mesh.


Plot the curvature.

PolyData.plot_normals([show_mesh, mag, ...])

Plot the point normals of a mesh.

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

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

Sample a dataset along a high resolution line and plot.


Transform point data into cell data.

PolyData.point_is_inside_cell(ind, point)

Return whether one or more points are inside a cell.


Convert the points datatype to double precision.

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

Sample data values at specified point locations.

PolyData.project_points_to_plane([origin, ...])

Project points of this mesh to a plane.

PolyData.ptc([pass_point_data, progress_bar])

Transform point data into cell data.

PolyData.ray_trace(origin, end_point[, ...])

Perform a single ray trace calculation.

PolyData.reconstruct_surface([nbr_sz, ...])

Reconstruct a surface from the points in this dataset.

PolyData.reflect(normal[, point, inplace, ...])

Reflect a dataset across a plane.

PolyData.remove_cells(ind[, inplace])

Remove cells.

PolyData.remove_points(remove[, mode, ...])

Rebuild a mesh by removing points.

PolyData.rename_array(old_name, new_name[, ...])

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

PolyData.ribbon([width, scalars, angle, ...])

Create a ribbon of the lines in this dataset.

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

Rotate mesh about a vector.

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

Rotate mesh about the x-axis.

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

Rotate mesh about the y-axis.

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

Rotate mesh about the z-axis.

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

Resample array data from a passed mesh onto this mesh.

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

PolyData.sample_over_line(pointa, pointb[, ...])

Sample a dataset onto a line.


Sample a dataset onto a multiple lines.[, binary, texture])

Write a surface mesh to disk.

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

Scale the mesh.

PolyData.select_enclosed_points(surface[, ...])

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


Return a copy of the dataset with separated cells with no shared points.

PolyData.set_active_scalars(name[, preference])

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

PolyData.set_active_tensors(name[, preference])

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

PolyData.set_active_vectors(name[, preference])

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


Create a shallow copy from a different dataset into this one.

PolyData.shrink([shrink_factor, progress_bar])

Shrink the individual faces of a mesh.

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

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

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

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

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

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

PolyData.slice_implicit(implicit_function[, ...])

Slice a dataset by a VTK implicit function.

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

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

PolyData.smooth([n_iter, relaxation_factor, ...])

Adjust point coordinates using Laplacian smoothing.

PolyData.smooth_taubin([n_iter, pass_band, ...])

Smooth a PolyData DataSet with Taubin smoothing.

PolyData.split_bodies([label, progress_bar])

Find, label, and split connected bodies/volumes.

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

Integrate a vector field to generate streamlines.


Generate evenly spaced streamlines on a 2D dataset.

PolyData.streamlines_from_source(source[, ...])

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

PolyData.strip([join, max_length, ...])

Strip poly data cells.

PolyData.subdivide(nsub[, subfilter, ...])

Increase the number of triangles in a single, connected triangular mesh.

PolyData.subdivide_adaptive([max_edge_len, ...])

Increase the number of triangles in a triangular mesh based on edge and/or area metrics.


Return the surface indices of a grid.

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

Tessellate a mesh.

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

Texture map this dataset to a user defined plane.

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

Texture map this dataset to a user defined sphere.

PolyData.threshold([value, scalars, invert, ...])

Apply a vtkThreshold filter to the input dataset.

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

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

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

Transform this mesh with a 4x4 transform.

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

Translate the mesh.

PolyData.triangulate([inplace, progress_bar])

Return an all triangle mesh.[radius, scalars, capping, ...])

Generate a tube around each input line.

PolyData.warp_by_scalar([scalars, factor, ...])

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

PolyData.warp_by_vector([vectors, factor, ...])

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



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 the mesh area if 2D.


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 cell normals.

Return the center of the bounding box.


Return the cell normals.


Return a pointer to the faces as a numpy array.


Return vtkFieldData as DataSetAttributes.


Return FieldData as DataSetAttributes.


Return if all the faces of the pyvista.PolyData are triangles.


Return if the mesh is manifold (no open edges).


Return the length of the diagonal of the bounding box.


Return a pointer to the lines as a numpy array.


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


Return the number of lines.


Return the number of open edges on this mesh.


Return the number of points in the entire dataset.


Return the number of strips.


Return the number of vertices.


Return the number of cells.


Return the number of cells.


Return the number of points.


Return the obbTree of the polydata.


Return vtkPointData as DataSetAttributes.


Return vtkPointData as DataSetAttributes.


Return the point normals.


Return a reference to the points as a numpy object.


Return a pointer to the strips as a numpy array.


Return the active texture coordinates on the points.


Return a dictionary to hold compatible vtk.vtkTexture objects.


Return active vectors.


Get the vertex cells.


Return the approximate volume of the dataset.