DataSetFilters.select_interior_points#
- DataSetFilters.select_interior_points(
- surface: pv.PolyData,
- *,
- method: _SelectInteriorPointsOptions = 'signed_distance',
- inside_out: bool = False,
- check_surface: bool = True,
- locator_tolerance: float | None = None,
Mark points from this mesh as inside or outside relative to a closed surface.
Evaluate all of this mesh’s points to determine if they are inside an enclosed surface. The filter produces a boolean point array named
'selected_points'withTruevalues indicating points are inside, andFalsevalues indicating points are outside the provided surface.By default, the input surface is checked to ensure it is closed. Optionally, this check may be disabled.
Note
This filter generates a data array, but does not modify the input dataset. If you wish to extract cells or points, various threshold filters are available (i.e., threshold the output array).
Added in version 0.47.
- Parameters:
- surface
PolyData Surface used to test for containment. It should be a closed surface such that it has a defined “inside” and “outside”.
- method‘signed_distance’ | ‘cell_locator’, default: ‘signed_distance’
Underlying method used to select points.
'signed_distance': Usecompute_implicit_distance()and select points based on the distance. Points with negative distance are inside, points with positive distance are outside.'cell_locator': Use vtkSelectEnclosedPoints to select points. This uses vtkStaticCellLocator internally to spatially search for interior points. Use thelocator_toleranceto control the search tolerance.
Note
The
'signed_distance'method is generally slower, but is also more reliable for correctly identifying interior points.Warning
The
'cell_locator'option can erroneously mark outside points as inside.- inside_outbool, default:
False By default, points inside the surface have value
True, and points outside have valueFalse. Setinside_out=Trueto invert this.- check_surfacebool, default:
True Specify whether to check the surface for closure. When
True, the algorithm first checks to see if the surface is closed and manifold. If the surface is not closed, a runtime error is raised.- locator_tolerance
float, default: 0.001 The tolerance on the intersection when using the
'cell_locator'method. The tolerance is expressed as a fraction of the bounding box of the enclosing surface.
- surface
- Returns:
PolyDataMesh with a new
'selected_points'point_dataarray.
Examples
Determine which points on a plane are inside a manifold sphere surface mesh. Extract these points using the
extract_points()filter and then plot them.>>> import pyvista as pv >>> sphere = pv.Sphere() >>> plane = pv.Plane() >>> selected = plane.select_interior_points(sphere) >>> pts = plane.extract_points( ... selected['selected_points'], include_cells=False ... ) >>> pl = pv.Plotter() >>> _ = pl.add_mesh(sphere, style='wireframe', line_width=3) >>> _ = pl.add_points( ... pts, color='r', point_size=15, render_points_as_spheres=True ... ) >>> pl.show()
Select the outside points instead.
>>> selected = plane.select_interior_points(sphere, inside_out=True) >>> pts = plane.extract_points( ... selected['selected_points'], include_cells=False ... ) >>> pl = pv.Plotter() >>> _ = pl.add_mesh(sphere, style='wireframe', line_width=3) >>> _ = pl.add_points( ... pts, color='r', point_size=15, render_points_as_spheres=True ... ) >>> pl.show()