------------------------------------------------------------------------------ Given a set of indices (after sorting), copy the ids from a pre-sorted id array to a final, post-sorted array.
| 302 | // Given a set of indices (after sorting), copy the ids from a pre-sorted |
| 303 | // id array to a final, post-sorted array. |
| 304 | void vtkSortDataArray::ShuffleIdList( |
| 305 | vtkIdType* idx, vtkIdType sze, vtkIdList* arrayIn, vtkIdType* preSort, int dir) |
| 306 | { |
| 307 | vtkIdType* postSort = new vtkIdType[sze]; |
| 308 | |
| 309 | if (dir == 0) // ascending |
| 310 | { |
| 311 | for (vtkIdType i = 0; i < sze; ++i) |
| 312 | { |
| 313 | postSort[i] = preSort[idx[i]]; |
| 314 | } |
| 315 | } |
| 316 | else |
| 317 | { |
| 318 | vtkIdType end = sze - 1; |
| 319 | for (vtkIdType i = 0; i < sze; ++i) |
| 320 | { |
| 321 | postSort[i] = preSort[idx[end - i]]; |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | arrayIn->SetArray(postSort, sze); |
| 326 | } |
| 327 | |
| 328 | //------------------------------------------------------------------------------ |
| 329 | // Sort a position index based on the values in the abstract array. Once |