MCPcopy Create free account
hub / github.com/Kitware/VTK / SortArrayByComponent

Method SortArrayByComponent

Common/Core/vtkSortDataArray.cxx:414–442  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

412
413//------------------------------------------------------------------------------
414void vtkSortDataArray::SortArrayByComponent(vtkAbstractArray* arr, int k, int dir)
415{
416 // Check input
417 if (arr == nullptr)
418 {
419 return;
420 }
421 vtkIdType numKeys = arr->GetNumberOfTuples();
422 int nc = arr->GetNumberOfComponents();
423
424 if (k < 0 || k >= nc)
425 {
426 vtkGenericWarningMacro(
427 "Cannot sort by column " << k << " since the array only has columns 0 through " << (nc - 1));
428 return;
429 }
430
431 // Perform the sort
432 vtkIdType* idx = vtkSortDataArray::InitializeSortIndices(numKeys);
433
434 void* dataIn = arr->GetVoidPointer(0);
435 int dataType = arr->GetDataType();
436 vtkSortDataArray::GenerateSortIndices(dataType, dataIn, numKeys, nc, k, idx);
437
438 vtkSortDataArray::ShuffleArray(idx, dataType, numKeys, nc, arr, dataIn, dir);
439
440 // Clean up
441 delete[] idx;
442}
443
444//------------------------------------------------------------------------------
445void vtkSortDataArray::PrintSelf(ostream& os, vtkIndent indent)

Callers

nothing calls this directly

Calls 5

ShuffleArrayFunction · 0.85
GetNumberOfTuplesMethod · 0.45
GetNumberOfComponentsMethod · 0.45
GetVoidPointerMethod · 0.45
GetDataTypeMethod · 0.45

Tested by

no test coverage detected