DataSetFilters.remove_points#
- DataSetFilters.remove_points(
- ind: int | VectorLikeInt | VectorLikeBool,
- mode: Literal['any', 'all'] = 'any',
- *,
- invert: bool = False,
- pass_point_ids: bool = True,
- pass_cell_ids: bool = True,
- inplace: bool = False,
- progress_bar: bool = False,
Remove points and their cells from a mesh.
Cells are removed according to
mode, and only points used by a remaining cell are kept. The output isPolyDataforPolyDatainput,PointSetforPointSetinput, and anUnstructuredGridotherwise. Withinvert=Trueandmode='all'this removes every point except those specified, which isextract_points()with the input type kept:# UnstructuredGrid, whatever the input extracted = mesh.extract_points(ind) # PolyData for PolyData input, PointSet for PointSet input extracted = mesh.remove_points(ind, mode='all', invert=True)
A
PolyDatawithout cells returns one vertex cell per remaining point, the same aspv.PolyData(points)creates. Usecast_to_pointset()first to remove points from a point cloud without cells.Added in version 0.49.
- Parameters:
- ind
int|VectorLikeInt|VectorLikeBool Point indices to remove. Can be a single
intor a vector ofints. Aboolvector is also supported; the vector size should match the number of points.- mode‘any’ | ‘all’, default: ‘any’
Remove cells that use
'any'of the specified points, or only cells whose points are'all'specified. With'all', specified points that are still used by a remaining cell are kept.- invertbool, default:
False Invert the selection and remove all points except those specified.
- pass_point_idsbool, default:
True Add a point array
'vtkOriginalPointIds'that identifies the original points the remaining points correspond to.- pass_cell_idsbool, default:
True Add a cell array
'vtkOriginalCellIds'that identifies the original cells the remaining cells correspond to.- inplacebool, default:
False Update the mesh in-place. This is only possible when the output has the same type as the input.
- progress_barbool, default:
False Display a progress bar to indicate progress.
- ind
- Returns:
pyvista.UnstructuredGrid|pyvista.PolyData|pyvista.PointSetMesh with the specified points removed.
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)
Remove a point from a mesh of line segments. The ids of the remaining points are kept.
>>> points = [
... [0.0, 0.0, 0.0],
... [1.0, 0.0, 0.0],
... [2.0, 0.0, 0.0],
... [3.0, 0.0, 0.0],
... ]
>>> lines = pv.PolyData(points, lines=[2, 0, 1, 2, 1, 2, 2, 2, 3])
>>> reduced = lines.remove_points(ind=0)
>>> reduced['vtkOriginalPointIds'].tolist()
[1, 2, 3]