[vtkusers] How to traverse lines of a polyline in reversed order?

kenichiro yoshimi rccm.kyoshimi at gmail.com
Fri Jul 20 05:01:31 EDT 2018


Hi,

vtkReverseSense is exactly what you are searching for.

Regards
2018年7月18日(水) 18:50 normanius <juch at zhaw.ch>:
>
> 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!
>
>     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)
>
>
> ________________________________
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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:
> https://public.kitware.com/mailman/listinfo/vtkusers


More information about the vtkusers mailing list