<div dir="ltr"><div>A quick note on a potentially powerful but likely overlooked capability relative to sorting data in VTK. This is available from a recent merge.</div><div><br></div><div>vtkSortDataArray has been revamped, a lot of what you'd expect: removed a static variable so it's thread-safe, significant code cleanup; new tests; uses std::sort instead of older C-based homegrown stuff; uses vtkSMPTools::Sort(),  so when the build is configured appropriately you'll see faster performance, etc.</div><div><br></div><div>The interesting bit is that sorting has been broken out into separate steps. An initial sort creates a permutation / sort index of vtkIdType that indicates where the data ends up (after the sort). This sorting index can then be used to shuffle any associated data around, or the sort index can be queried to perform additional analysis on the data.</div><div><br></div><div>Practically this means you can use any component of a tuple in a data array to generate a sort index. So for example, if you want to find the top N points with lowest/greatest scalar value; or the cells with largest z-velocity component; etc. it is quite easy to do. Look at Common/Core/Testing/Cxx/TestSortDataArray.cxx. I also thought about creating an extraction filter to sort, extract, and/or reorder cells/points based on data value; this is down on my todo list....</div><div><br></div><div>There is also a new, related class vtkSortFieldData that enables you to simultaneously sort all the arrays contained in subclasses of vtkFieldData (e.g., vtkPointData and vtkCellData).</div><div><br></div><div>Have fun and as always let me know if there are issues, concerns, or improvements to be made.</div><div><br></div><div>Best,</div><div>W</div>
</div>