VTK  9.3.20240328
vtkSortDataArray.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-FileCopyrightText: Copyright 2003 Sandia Corporation
3 // SPDX-License-Identifier: LicenseRef-BSD-3-Clause-Sandia-USGov
4 
68 #ifndef vtkSortDataArray_h
69 #define vtkSortDataArray_h
70 
71 #include "vtkCommonCoreModule.h" // For export macro
72 #include "vtkObject.h"
73 
74 VTK_ABI_NAMESPACE_BEGIN
75 class vtkIdList;
76 class vtkAbstractArray;
77 
78 class VTKCOMMONCORE_EXPORT vtkSortDataArray : public vtkObject
79 {
80 public:
82 
86  static vtkSortDataArray* New();
87  vtkTypeMacro(vtkSortDataArray, vtkObject);
88  void PrintSelf(ostream& os, vtkIndent indent) override;
90 
95  static void Sort(vtkIdList* keys) { vtkSortDataArray::Sort(keys, 0); }
96  static void Sort(vtkAbstractArray* keys) { vtkSortDataArray::Sort(keys, 0); }
97 
99 
103  static void Sort(vtkIdList* keys, int dir);
104  static void Sort(vtkAbstractArray* keys, int dir);
106 
113  static void Sort(vtkAbstractArray* keys, vtkAbstractArray* values)
114  {
115  vtkSortDataArray::Sort(keys, values, 0);
116  }
117  static void Sort(vtkAbstractArray* keys, vtkIdList* values)
118  {
119  vtkSortDataArray::Sort(keys, values, 0);
120  }
121 
123 
129  static void Sort(vtkAbstractArray* keys, vtkAbstractArray* values, int dir);
130  static void Sort(vtkAbstractArray* keys, vtkIdList* values, int dir);
132 
140  static void SortArrayByComponent(vtkAbstractArray* arr, int k)
141  {
143  }
144 
152  static void SortArrayByComponent(vtkAbstractArray* arr, int k, int dir);
153 
155 
178  static void GenerateSortIndices(
179  int dataType, void* dataIn, vtkIdType numKeys, int numComp, int k, vtkIdType* idx);
180  static void ShuffleArray(vtkIdType* idx, int dataType, vtkIdType numKeys, int numComp,
181  vtkAbstractArray* arr, void* dataIn, int dir);
182  static void ShuffleIdList(
183  vtkIdType* idx, vtkIdType sze, vtkIdList* arrayIn, vtkIdType* dataIn, int dir);
185 
186 protected:
188  ~vtkSortDataArray() override;
189 
190  // A more efficient sort for single component arrays. This is delegated to
191  // by the methods above (if appropriate).
192  static void GenerateSort1Indices(int dataType, void* dataIn, vtkIdType numKeys, vtkIdType* idx);
193 
194  // A more efficient shuffle for single component arrays. This is delegated to
195  // by the methods above (if appropriate).
196  static void Shuffle1Array(
197  vtkIdType* idx, int dataType, vtkIdType numKeys, vtkAbstractArray* arr, void* dataIn, int dir);
198 
199 private:
200  vtkSortDataArray(const vtkSortDataArray&) = delete;
201  void operator=(const vtkSortDataArray&) = delete;
202 };
203 
204 VTK_ABI_NAMESPACE_END
205 #endif // vtkSortDataArray_h
Abstract superclass for all arrays.
list of point or cell ids
Definition: vtkIdList.h:132
a simple class to control print indentation
Definition: vtkIndent.h:108
abstract base class for most VTK objects
Definition: vtkObject.h:161
provides several methods for sorting VTK arrays.
static vtkSortDataArray * New()
Standard VTK methods for instantiating, managing type, and printing information about this class.
static void Shuffle1Array(vtkIdType *idx, int dataType, vtkIdType numKeys, vtkAbstractArray *arr, void *dataIn, int dir)
static void Sort(vtkIdList *keys)
Sorts the given array in ascending order.
static void Sort(vtkAbstractArray *keys, vtkIdList *values, int dir)
Sorts the given key/value pairs based on the keys (the keys are expected to be 1-tuples,...
static void ShuffleIdList(vtkIdType *idx, vtkIdType sze, vtkIdList *arrayIn, vtkIdType *dataIn, int dir)
The following are general functions which can be used to produce an ordering, and/or sort various typ...
static void Sort(vtkAbstractArray *keys, vtkAbstractArray *values)
Sorts the given key/value pairs based on the keys (the keys are expected to be 1-tuples,...
static void GenerateSortIndices(int dataType, void *dataIn, vtkIdType numKeys, int numComp, int k, vtkIdType *idx)
The following are general functions which can be used to produce an ordering, and/or sort various typ...
static void SortArrayByComponent(vtkAbstractArray *arr, int k)
Sorts the given data array using the specified component as a key.
static void Sort(vtkIdList *keys, int dir)
Sorts the given array in either ascending (dir=0) or descending (dir!=0) order.
static void SortArrayByComponent(vtkAbstractArray *arr, int k, int dir)
Sorts the given data array using the specified component as a key.
static void Sort(vtkAbstractArray *keys, int dir)
Sorts the given array in either ascending (dir=0) or descending (dir!=0) order.
~vtkSortDataArray() override
static void Sort(vtkAbstractArray *keys, vtkAbstractArray *values, int dir)
Sorts the given key/value pairs based on the keys (the keys are expected to be 1-tuples,...
static void ShuffleArray(vtkIdType *idx, int dataType, vtkIdType numKeys, int numComp, vtkAbstractArray *arr, void *dataIn, int dir)
The following are general functions which can be used to produce an ordering, and/or sort various typ...
static void Sort(vtkAbstractArray *keys)
static vtkIdType * InitializeSortIndices(vtkIdType numKeys)
The following are general functions which can be used to produce an ordering, and/or sort various typ...
void PrintSelf(ostream &os, vtkIndent indent) override
Standard VTK methods for instantiating, managing type, and printing information about this class.
static void Sort(vtkAbstractArray *keys, vtkIdList *values)
static void GenerateSort1Indices(int dataType, void *dataIn, vtkIdType numKeys, vtkIdType *idx)
@ dir
Definition: vtkX3D.h:324
int vtkIdType
Definition: vtkType.h:315