PolyDataFilters.remove_points

PolyDataFilters.remove_points#

PolyDataFilters.remove_points(
remove: VectorLikeBool | VectorLikeInt | None = None,
mode: Literal['any', 'all'] = 'any',
*,
keep_scalars: bool | None = None,
inplace: bool = False,
ind: int | VectorLikeInt | VectorLikeBool | None = None,
invert: bool | None = None,
pass_point_ids: bool | None = None,
pass_cell_ids: bool | None = None,
progress_bar: bool | None = None,
) → PolyData | tuple[PolyData, NDArray[np.signedinteger]][source]#

Rebuild a mesh by removing points.

Deprecated since version 0.49: Returning a (mesh, ids) tuple is deprecated and only the mesh will be returned in a future version. Until then this filter returns one or the other depending on how it is called:

  • The points passed positionally or as remove return the tuple, and warn. Only all-triangle meshes are supported.

  • The points named ind, or any of invert, pass_point_ids, pass_cell_ids and progress_bar, return only the mesh from pyvista.DataSetFilters.remove_points(), for any mesh. The ids that were the second return value are the 'vtkOriginalPointIds' array, and clear_data() replaces keep_scalars.

Parameters:
removeVectorLikeBool | VectorLikeInt, optional

If remove is a bool array, points that are True will be removed. Otherwise, it is treated as a list of indices. Only valid for all-triangle meshes.

modestr, default: “any”

When 'all', only faces containing all points flagged for removal will be removed.

keep_scalarsbool, optional

When True, point and cell scalars will be passed on to the new mesh. Defaults to True and cannot be used when only the mesh is returned.

inplacebool, default: False

Updates mesh in-place.

indint | VectorLikeInt | VectorLikeBool, optional

Point indices to remove, the same as remove. Passing this returns only the mesh. See pyvista.DataSetFilters.remove_points().

invertbool, default: False

Invert the selection. Passing this returns only the mesh.

pass_point_idsbool, default: True

Add the 'vtkOriginalPointIds' point array. Passing this returns only the mesh.

pass_cell_idsbool, default: True

Add the 'vtkOriginalCellIds' cell array. Passing this returns only the mesh.

progress_barbool, default: False

Display a progress bar to indicate progress. Passing this returns only the mesh.

Returns:
pyvista.PolyData | tuple[pyvista.PolyData, numpy.ndarray]

Mesh without the points flagged for removal, and the indices of its points relative to the original mesh. The indices are returned with the mesh as a deprecated (mesh, ids) tuple unless one of ind, invert, pass_point_ids, pass_cell_ids or progress_bar is passed, in which case only the mesh is returned.

Examples#

Download Python source code | Download Jupyter notebook

Remove 150 points from a sphere.

>>> import pyvista as pv
>>> sphere = pv.Sphere()
>>> reduced_sphere = sphere.remove_points(ind=range(100, 250))
>>> reduced_sphere.plot(show_edges=True, line_width=3)
../../../_images/pyvista-PolyDataFilters-remove_points-d2281a8d6ac3a198_00_00.png