[vtkusers] about vtkDijkstraGraphGeodesicPath
Frédéric BRIEND
briend at cyceron.fr
Thu Oct 19 11:42:08 EDT 2017
Last question Yoshimi (or others),
With your script*, is-there a way to extract the point (in x,y,z or
vertex value) where dist/2 (the half of the total geodesic distance)?
Thanks for your kindness,
Frederic
*
import vtk
import math
cylinder= vtk.vtkSphereSource()
cylinder.SetCenter(0.0, 0.0, 0.0)
cylinder.SetRadius(0.5)
appendFilter = vtk.vtkAppendFilter()
appendFilter.MergePointsOn()
vIds = [4, 12, 23, 28]
p0 = [0,0,0]
p1 = [0,0,0]
dist = 0.0
for n in range(len(vIds)-1):
v0 = vIds[n]
v1 = vIds[n+1]
dijkstra = vtk.vtkDijkstraGraphGeodesicPath()
dijkstra.SetInputConnection(cylinder.GetOutputPort())
dijkstra.SetStartVertex(v0)
dijkstra.SetEndVertex(v1)
dijkstra.Update()
pts = dijkstra.GetOutput().GetPoints()
for ptId in range(pts.GetNumberOfPoints()-1):
pts.GetPoint(ptId, p0)
pts.GetPoint(ptId+1, p1)
print(math.sqrt(vtk.vtkMath.Distance2BetweenPoints(p0, p1)))
dist += math.sqrt(vtk.vtkMath.Distance2BetweenPoints(p0, p1))
appendFilter.AddInputConnection(dijkstra.GetOutput())
print(dist)
appendFilter.Update()
More information about the vtkusers
mailing list