VTK  9.3.1
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 
49 #ifndef vtkSortDataArray_h
50 #define vtkSortDataArray_h
51 
52 #include "vtkCommonCoreModule.h" // For export macro
53 #include "vtkObject.h"
54 
55 VTK_ABI_NAMESPACE_BEGIN
56 class vtkIdList;
57 class vtkAbstractArray;
58 
59 class VTKCOMMONCORE_EXPORT vtkSortDataArray : public vtkObject
60 {
61 public:
63 
67  static vtkSortDataArray* New();
68  vtkTypeMacro(vtkSortDataArray, vtkObject);
69  void PrintSelf(ostream& os, vtkIndent indent) override;
71 
76  static void Sort(vtkIdList* keys) { vtkSortDataArray::Sort(keys, 0); }
77  static void Sort(vtkAbstractArray* keys) { vtkSortDataArray::Sort(keys, 0); }
78 
80 
84  static void Sort(vtkIdList* keys, int dir);
85  static void Sort(vtkAbstractArray* keys, int dir);
87 
94  static void Sort(vtkAbstractArray* keys, vtkAbstractArray* values)
95  {
96  vtkSortDataArray::Sort(keys, values, 0);
97  }
98  static void Sort(vtkAbstractArray* keys, vtkIdList* values)
99  {
100  vtkSortDataArray::Sort(keys, values, 0);
101  }
102 
104 
110  static void Sort(vtkAbstractArray* keys, vtkAbstractArray* values, int dir);
111  static void Sort(vtkAbstractArray* keys, vtkIdList* values, int dir);
113 
121  static void SortArrayByComponent(vtkAbstractArray* arr, int k)
122  {
124  }
125 
133  static void SortArrayByComponent(vtkAbstractArray* arr, int k, int dir);
134 
136 
158  static vtkIdType* InitializeSortIndices(vtkIdType numKeys);
159  static void GenerateSortIndices(
160  int dataType, void* dataIn, vtkIdType numKeys, int numComp, int k, vtkIdType* idx);
161  static void ShuffleArray(vtkIdType* idx, int dataType, vtkIdType numKeys, int numComp,
162  vtkAbstractArray* arr, void* dataIn, int dir);
163  static void ShuffleIdList(
164  vtkIdType* idx, vtkIdType sze, vtkIdList* arrayIn, vtkIdType* dataIn, int dir);
166 
167 protected:
169  ~vtkSortDataArray() override;
170 
171  // A more efficient sort for single component arrays. This is delegated to
172  // by the methods above (if appropriate).
173  static void GenerateSort1Indices(int dataType, void* dataIn, vtkIdType numKeys, vtkIdType* idx);
174 
175  // A more efficient shuffle for single component arrays. This is delegated to
176  // by the methods above (if appropriate).
177  static void Shuffle1Array(
178  vtkIdType* idx, int dataType, vtkIdType numKeys, vtkAbstractArray* arr, void* dataIn, int dir);
179 
180 private:
181  vtkSortDataArray(const vtkSortDataArray&) = delete;
182  void operator=(const vtkSortDataArray&) = delete;
183 };
184 
185 VTK_ABI_NAMESPACE_END
186 #endif // vtkSortDataArray_h
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, values may have number of components >= 1).
abstract base class for most VTK objects
Definition: vtkObject.h:51
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
Abstract superclass for all arrays.
static void Sort(vtkAbstractArray *keys, vtkIdList *values)
static void SortArrayByComponent(vtkAbstractArray *arr, int k)
Sorts the given data array using the specified component as a key.
void Sort(RandomIt bitr, RandomIt eitr, BackToFront< T > &me)
int vtkIdType
Definition: vtkType.h:315
a simple class to control print indentation
Definition: vtkIndent.h:28
list of point or cell ids
Definition: vtkIdList.h:22
static void Sort(vtkAbstractArray *keys)
static void Sort(vtkIdList *keys)
Sorts the given array in ascending order.
provides several methods for sorting VTK arrays.
static vtkObject * New()
Create an object with Debug turned off, modified time initialized to zero, and reference counting on...