[vtkusers] vtkDijkstraGraphGeodesicPath in Python
EdwardWang
ed1996 at gmail.com
Thu Sep 29 15:48:34 EDT 2016
First off I want to apologize because I posted this in VTK-Dev first, and
then deleted it and moved it here. Please let me know if that's bad
etiquette.
Hi,
I am trying to use the vtkDijkstraGraphGeodesicPath to create a geodesic
contour on my vtkPolyData model. The model itself is exported from Slicer3D.
I know that there are some examples of this in C++, but I have not been able
to find any in Python. I figured I would first used the
vtkDijkstraGraphGeodesicPath class to get my values, and then worry about
the contours later.
The point data of my polydata has no lines or triangles, only polygons.
According to the documentation, the input polydata must consist of only
triangle cells, which I don't know how to verify. However, I think the
polydata is in the right format, because I implemented the class as shown
below and got some values:
dijkstra = vtk.vtkDijkstraGraphGeodesicPath()
dijkstra.SetInputData(polydata)
dijkstra.SetStartVertex(0)
dijkstra.Update()
weights = vtk.vtkDoubleArray()
dijkstra.GetCumulativeWeights(weights)
length = weights.GetMaxId()+1
numericArray = np.zeros(length)
for i in range(length):
numericArray[i] = weights.GetTuple(i)[0]
I believe numeric array holds the geodesic computed from each point to the
start vertex. This is what the colormap looks like:
colormap.PNG <http://vtk.1045678.n5.nabble.com/file/n5740606/colormap.PNG>
It's about what you'd expect, except that I've noticed that sometimes the
geodesic value is -1. I've experimented with different files and it seems
that less than .05% of the geodesics failed. I found the vertices at which
the geodesic failed, and when I set them as the start vertex, the program
fails with exit code -1073740777 (0xC0000417).
My guess is that something is wrong with my input polydata, and I've tried
to apply both vtkCleanPolyData and vtkTriangleFilter, but they didn't seem
to make any changes. Maybe my implementation is wrong?
cleanFilter = vtk.vtkCleanPolyData()
cleanFilter.SetInputData(polydata)
cleanFilter.Update()
cleanFilter.UpdateDataObject()
polydata = cleanFilter.GetOutput()
Any help is much appreciated.
Thanks,
Edward
Remove Ads
--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkDijkstraGraphGeodesicPath-in-Python-tp5740606.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list