[vtkusers] about vtkDijkstraGraphGeodesicPath
kenichiro yoshimi
rccm.kyoshimi at gmail.com
Thu Oct 12 21:26:16 EDT 2017
Hello Frederic,
The options about constrained shortest path can not be found in the
vtkDijkstraGraphGeodesicPath. I don't know it is helpful or not but it
is possible to add points to pass through as some of the constraints.
It works in the following way due to applying vtkAppendFilter
successively to some outputs of vtkDijkstraGraphGeodesicPath.
---
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.AddInputData(dijkstra.GetOutput())
print(dist)
appendFilter.Update()
---
Thanks
2017-10-13 1:26 GMT+09:00 Frédéric BRIEND <briend at cyceron.fr>:
> Hi,
>
> Always with vtkDijkstraGraphGeodesicPath function, is-it possible to
> constrained the geodesic shortest paths (example)?
> and thus to add points beetween the "dijkstra.SetStartVertex(X)" and the
> "dijkstra.SetEndVertex(Y)"?
>
> Thanks in advance!
>
> Frederic
>
>
>
> Le 12/10/2017 à 04:52, kenichiro yoshimi a écrit :
>
> Hi,
>
> The vtkDijkstraGraphGeodesicPath filter seems to output a sorted point
> set along the geodesic path. Hence, a straightforward way of getting
> the distance is summing the lengths of each segment that makes up it.
> ---
> pts = dijkstra.GetOutput().GetPoints()
>
> p0 = [0,0,0]
> p1 = [0,0,0]
> dist = 0.0
> for ptId in range(pts.GetNumberOfPoints()-1):
> pts.GetPoint(ptId, p0)
> pts.GetPoint(ptId+1, p1)
> dist += math.sqrt(vtk.vtkMath.Distance2BetweenPoints(p0, p1))
>
> print(dist)
> ---
>
> Regards
>
> 2017-10-12 2:12 GMT+09:00 Frédéric BRIEND <briend at cyceron.fr>:
>
> Hi,
>
> Sorry for the double post.
> Since the old post of Karthik, is there a way with
> "vtkDijkstraGraphGeodesicPath" to have the distance by GetGeodesicLength() ?
> How to do otherwise?
>
> Thanks in advance!
>
> My python script:
>
> cylinder= vtk.vtkSphereSource()
> cylinder.SetCenter(0.0, 0.0, 0.0)
> cylinder.SetRadius(0.5)
>
> dijkstra = vtk.vtkDijkstraGraphGeodesicPath()
> dijkstra.SetInputConnection(cylinder.GetOutputPort())
> dijkstra.SetStartVertex(4)
> dijkstra.SetEndVertex(28)
> dijkstra.Update()
>
> weights = vtk.vtkDoubleArray()
> size=dijkstra.GetCumulativeWeights(weights)
>
> print size
>
> I obtain for size: none
>
> --
>
> Frederic Briend
>
> PhD Candidate
>
> Université de Caen Normandie
>
> Laboratoire Imagerie et Stratégies Thérapeutiques de la Schizophrénie (ISTS,
> EA 7466)
>
> GIP CYCERON, Caen 14000, France
>
> Tel +33 2 31 47 01 56
>
> Email : briend at cyceron.fr
>
> http://www.ists.cyceron.fr/
>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
>
> --
>
> Frederic Briend
>
> PhD Candidate
>
> Université de Caen Normandie
>
> Laboratoire Imagerie et Stratégies Thérapeutiques de la Schizophrénie (ISTS,
> EA 7466)
>
> GIP CYCERON, Caen 14000, France
>
> Tel +33 2 31 47 01 56
>
> Email : briend at cyceron.fr
>
> http://www.ists.cyceron.fr/
More information about the vtkusers
mailing list