VTK  9.3.0
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 
58 #ifndef vtkSortDataArray_h
59 #define vtkSortDataArray_h
60 
61 #include "vtkCommonCoreModule.h" // For export macro
62 #include "vtkObject.h"
63 
64 VTK_ABI_NAMESPACE_BEGIN
65 class vtkIdList;
66 class vtkAbstractArray;
67 
68 class VTKCOMMONCORE_EXPORT vtkSortDataArray : public vtkObject
69 {
70 public:
72 
76  static vtkSortDataArray* New();
77  vtkTypeMacro(vtkSortDataArray, vtkObject);
78  void PrintSelf(ostream& os, vtkIndent indent) override;
80 
85  static void Sort(vtkIdList* keys) { vtkSortDataArray::Sort(keys, 0); }
86  static void Sort(vtkAbstractArray* keys) { vtkSortDataArray::Sort(keys, 0); }
87 
89 
93  static void Sort(vtkIdList* keys, int dir);
94  static void Sort(vtkAbstractArray* keys, int dir);
96 
103  static void Sort(vtkAbstractArray* keys, vtkAbstractArray* values)
104  {
105  vtkSortDataArray::Sort(keys, values, 0);
106  }
107  static void Sort(vtkAbstractArray* keys, vtkIdList* values)
108  {
109  vtkSortDataArray::Sort(keys, values, 0);
110  }
111 
113 
119  static void Sort(vtkAbstractArray* keys, vtkAbstractArray* values, int dir);
120  static void Sort(vtkAbstractArray* keys, vtkIdList* values, int dir);
122 
130  static void SortArrayByComponent(vtkAbstractArray* arr, int k)
131  {
133  }
134 
142  static void SortArrayByComponent(vtkAbstractArray* arr, int k, int dir);
143 
145 
168  static void GenerateSortIndices(
169  int dataType, void* dataIn, vtkIdType numKeys, int numComp, int k, vtkIdType* idx);
170  static void ShuffleArray(vtkIdType* idx, int dataType, vtkIdType numKeys, int numComp,
171  vtkAbstractArray* arr, void* dataIn, int dir);
172  static void ShuffleIdList(
173  vtkIdType* idx, vtkIdType sze, vtkIdList* arrayIn, vtkIdType* dataIn, int dir);
175 
176 protected:
178  ~vtkSortDataArray() override;
179 
180  // A more efficient sort for single component arrays. This is delegated to
181  // by the methods above (if appropriate).
182  static void GenerateSort1Indices(int dataType, void* dataIn, vtkIdType numKeys, vtkIdType* idx);
183 
184  // A more efficient shuffle for single component arrays. This is delegated to
185  // by the methods above (if appropriate).
186  static void Shuffle1Array(
187  vtkIdType* idx, int dataType, vtkIdType numKeys, vtkAbstractArray* arr, void* dataIn, int dir);
188 
189 private:
190  vtkSortDataArray(const vtkSortDataArray&) = delete;
191  void operator=(const vtkSortDataArray&) = delete;
192 };
193 
194 VTK_ABI_NAMESPACE_END
195 #endif // vtkSortDataArray_h
Abstract superclass for all arrays.
list of point or cell ids
Definition: vtkIdList.h:32
a simple class to control print indentation
Definition: vtkIndent.h:38
abstract base class for most VTK objects
Definition: vtkObject.h:61
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