pyvista.PolyDataFilters.geodesic

pyvista.PolyDataFilters.geodesic#

PolyDataFilters.geodesic(
start_vertex,
end_vertex,
inplace=False,
keep_order=True,
use_scalar_weights=False,
progress_bar=False,
)[source]#

Calculate the geodesic path between two vertices using Dijkstra’s algorithm.

This will add an array titled 'vtkOriginalPointIds' of the input mesh’s point ids to the output mesh. The default behavior of the underlying vtkDijkstraGraphGeodesicPath filter is that the geodesic path is reversed in the resulting mesh. This is overridden in PyVista by default.

Parameters:
start_vertexint

Vertex index indicating the start point of the geodesic segment.

end_vertexint

Vertex index indicating the end point of the geodesic segment.

inplacebool, default: False

Whether the input mesh should be replaced with the path. The geodesic path is always returned.

keep_orderbool, default: True

If True, the points of the returned path are guaranteed to start with the start vertex (as opposed to the end vertex).

Added in version 0.32.0.

use_scalar_weightsbool, default: False

If True, use scalar values in the edge weight. This only works for point data.

progress_barbool, default: False

Display a progress bar to indicate progress.

Returns:
pyvista.PolyData

PolyData object consisting of the line segment between the two given vertices. If inplace is True this is the same object as the input mesh.

Examples

Plot the path between two points on the random hills mesh.

>>> import pyvista as pv
>>> from pyvista import examples
>>> hills = examples.load_random_hills()
>>> path = hills.geodesic(560, 5820)
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(hills)
>>> _ = pl.add_mesh(path, line_width=5, color='k')
>>> pl.show()
../../../_images/pyvista-PolyDataFilters-geodesic-1_00_00.png

See Geodesic Paths for more examples using this filter.