pyvista.CompositeFilters.slice_along_line#
- CompositeFilters.slice_along_line(
- line,
- generate_triangles=False,
- contour=False,
- progress_bar=False,
Slice a dataset using a polyline/spline as the path.
This also works for lines generated with
pyvista.Line()
.- Parameters:
- line
pyvista.PolyData
A PolyData object containing one single PolyLine cell.
- generate_trianglesbool, default:
False
When
True
, the output will be triangles. Otherwise the output will be the intersection polygons.- contourbool, default:
False
If
True
, apply acontour
filter after slicing.- progress_barbool, default:
False
Display a progress bar to indicate progress.
- line
- Returns:
pyvista.PolyData
Sliced dataset.
Examples
Slice the random hills dataset along a circular arc.
>>> import numpy as np >>> import pyvista as pv >>> from pyvista import examples >>> hills = examples.load_random_hills() >>> center = np.array(hills.center) >>> point_a = center + np.array([5, 0, 0]) >>> point_b = center + np.array([-5, 0, 0]) >>> arc = pv.CircularArc(point_a, point_b, center, resolution=100) >>> line_slice = hills.slice_along_line(arc)
Plot the circular arc and the hills mesh.
>>> pl = pv.Plotter() >>> _ = pl.add_mesh(hills, smooth_shading=True, style='wireframe') >>> _ = pl.add_mesh( ... line_slice, ... line_width=10, ... render_lines_as_tubes=True, ... color='k', ... ) >>> _ = pl.add_mesh(arc, line_width=10, color='grey') >>> pl.show()
See Slicing for more examples using this filter.