UnstructuredGridFilters.remove_unused_points#
- UnstructuredGridFilters.remove_unused_points(
- *,
- inplace: bool = False,
Remove points which are not used by any cells.
Unlike
clean(), this filter does not merge points.Added in version 0.46.
- Parameters:
- Returns:
UnstructuredGridMesh with unused points removed.
Examples
Create
UnstructuredGridwith three points. The first two points are coincident and associated withVERTEXcells, and the third point is “unused” and not associated with any cells.>>> import pyvista as pv >>> cells = [1, 0, 1, 1] >>> celltypes = [pv.CellType.VERTEX, pv.CellType.VERTEX] >>> points = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [1.0, 1.0, 1.0]] >>> grid = pv.UnstructuredGrid(cells, celltypes, points) >>> grid UnstructuredGrid (...) N Cells: 2 N Points: 3 X Bounds: 0.000e+00, 1.000e+00 Y Bounds: 0.000e+00, 1.000e+00 Z Bounds: 0.000e+00, 1.000e+00 N Arrays: 0
Since the third point is unused, we can remove it. Note that coincident points are not merged by this filter, so the two vertex points are kept as-is.
>>> grid = grid.remove_unused_points() >>> grid UnstructuredGrid (...) N Cells: 2 N Points: 2 X Bounds: 0.000e+00, 0.000e+00 Y Bounds: 0.000e+00, 0.000e+00 Z Bounds: 0.000e+00, 0.000e+00 N Arrays: 0