VTK
vtkSortDataArray.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkSortDataArray.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
15 
16 /*
17  * Copyright 2003 Sandia Corporation.
18  * Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
19  * license for use of this work by or on behalf of the
20  * U.S. Government. Redistribution and use in source and binary forms, with
21  * or without modification, are permitted provided that this Notice and any
22  * statement of authorship are reproduced on all copies.
23  */
24 
66 #ifndef vtkSortDataArray_h
67 #define vtkSortDataArray_h
68 
69 #include "vtkCommonCoreModule.h" // For export macro
70 #include "vtkObject.h"
71 
72 class vtkIdList;
73 class vtkAbstractArray;
74 
75 
76 class VTKCOMMONCORE_EXPORT vtkSortDataArray : public vtkObject
77 {
78 public:
80 
84  static vtkSortDataArray *New();
85  vtkTypeMacro(vtkSortDataArray, vtkObject);
86  void PrintSelf(ostream& os, vtkIndent indent) override;
88 
93  static void Sort(vtkIdList *keys)
94  {vtkSortDataArray::Sort(keys,0);}
95  static void Sort(vtkAbstractArray *keys)
96  {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  {vtkSortDataArray::Sort(keys,values,0);}
115  static void Sort(vtkAbstractArray *keys, vtkIdList *values)
116  {vtkSortDataArray::Sort(keys,values,0);}
117 
119 
125  static void Sort(vtkAbstractArray *keys, vtkAbstractArray *values, int dir);
126  static void Sort(vtkAbstractArray *keys, vtkIdList *values, int dir);
128 
136  static void SortArrayByComponent( vtkAbstractArray* arr, int k)
138 
146  static void SortArrayByComponent( vtkAbstractArray* arr, int k, int dir);
147 
149 
171  static vtkIdType *InitializeSortIndices(vtkIdType numKeys);
172  static void GenerateSortIndices(int dataType, void *dataIn, vtkIdType numKeys,
173  int numComp, int k, vtkIdType *idx);
174  static void ShuffleArray(vtkIdType *idx, int dataType, vtkIdType numKeys,
175  int numComp, vtkAbstractArray *arr,
176  void *dataIn, int dir);
177  static void ShuffleIdList(vtkIdType *idx, vtkIdType sze, vtkIdList *arrayIn,
178  vtkIdType *dataIn, int dir);
180 
181 protected:
183  ~vtkSortDataArray() override;
184 
185  // A more efficient sort for single component arrays. This is delegated to
186  // by the methods above (if appropriate).
187  static void GenerateSort1Indices(int dataType, void *dataIn, vtkIdType numKeys,
188  vtkIdType *idx);
189 
190  // A more efficient shuffle for single component arrays. This is delegated to
191  // by the methods above (if appropriate).
192  static void Shuffle1Array(vtkIdType *idx, int dataType, vtkIdType numKeys,
193  vtkAbstractArray *arr, void *dataIn, int dir);
194 
195 private:
196  vtkSortDataArray(const vtkSortDataArray &) = delete;
197  void operator=(const vtkSortDataArray &) = delete;
198 };
199 
200 #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:53
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.
int vtkIdType
Definition: vtkType.h:345
a simple class to control print indentation
Definition: vtkIndent.h:33
list of point or cell ids
Definition: vtkIdList.h:30
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...