Hi all
How to nicely traverse the lines of a polyline in reversed order, from end to start? Is there an existing function that does this, or do I have to implement my own loop that does this?
In the example below, I would like to get the line traversal AD -> DC -> CB -> BA, after initializing the cells to go from AB -> BC -> CD -> DA.
Thanks!
<pre>
points = vtk.vtkPoints()
points.InsertNextPoint([0,0,0]) # A
points.InsertNextPoint([1,0,0]) # B
points.InsertNextPoint([1,1,0]) # C
points.InsertNextPoint([0,1,0]) # D
lines = vtk.vtkCellArray()
for i in range(4):
line = vtk.vtkLine()
line.GetPointIds().SetId(0, i)
line.GetPointIds().SetId(1, (i+1)%4)
lines.InsertNextCell(line)
poly = vtk.vtkPolyData()
poly.SetPoints(points)
poly.SetLines(lines)
reversed = reverseLines(poly)
lines = reversed.GetLines()
points = reversed.GetPoints()
lines.InitTraversal()
idList = vtk.vtkIdList()
while lines.GetNextCell(idList):
p = []
for i in range(0, idList.GetNumberOfIds()):
p.append(points.GetPoint(idList.GetId(i)))
print(p)
</pre>
<br/><hr align="left" width="300" />
Sent from the <a href="http://vtk.1045678.n5.nabble.com/VTK-Users-f1224199.html">VTK - Users mailing list archive</a> at Nabble.com.<br/>