[vtkusers] reverse order using vtkSortDataArray

David Doria daviddoria at gmail.com
Wed Feb 27 12:03:46 EST 2013


On Tue, Jan 29, 2013 at 6:51 AM, Dr. Roman Grothausmann
<grothausmann.roman at mh-hannover.de> wrote:
> Dear mailing list members,
>
>
> How can I reverse the order of the result (e.g. values) of
> vtkSortDataArray::Sort(keys, values)?
>
> Any help or hints are very much appreciated
> Roman

I added an example of this class here:
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Utilities/SortDataArray

To reverse the values, it looks like to me that you'd just have to
create the keyArray like this:

for(vtkIdType i = valueArray->GetNumberOfTuples() - 1; i >= 0; --i)
{
  keyArray->InsertNextValue(i);
}

(That is, just create a list of reverse-ordered integers, like 5 4 3 2
1 0 to reverse the elements in an array with 6 values).

David



More information about the vtkusers mailing list