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 
69 #ifndef vtkSortDataArray_h
70 #define vtkSortDataArray_h
71 
72 #include "vtkCommonCoreModule.h" // For export macro
73 #include "vtkObject.h"
74 
75 class vtkIdList;
76 class vtkAbstractArray;
77 
78 
79 class VTKCOMMONCORE_EXPORT vtkSortDataArray : public vtkObject
80 {
81 public:
83 
87  static vtkSortDataArray *New();
88  vtkTypeMacro(vtkSortDataArray, vtkObject);
89  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
91 
96  static void Sort(vtkIdList *keys)
97  {vtkSortDataArray::Sort(keys,0);}
98  static void Sort(vtkAbstractArray *keys)
99  {vtkSortDataArray::Sort(keys,0);}
100 
102 
106  static void Sort(vtkIdList *keys, int dir);
107  static void Sort(vtkAbstractArray *keys, int dir);
109 
116  static void Sort(vtkAbstractArray *keys, vtkAbstractArray *values)
117  {vtkSortDataArray::Sort(keys,values,0);}
118  static void Sort(vtkAbstractArray *keys, vtkIdList *values)
119  {vtkSortDataArray::Sort(keys,values,0);}
120 
122 
128  static void Sort(vtkAbstractArray *keys, vtkAbstractArray *values, int dir);
129  static void Sort(vtkAbstractArray *keys, vtkIdList *values, int dir);
131 
139  static void SortArrayByComponent( vtkAbstractArray* arr, int k)
141 
149  static void SortArrayByComponent( vtkAbstractArray* arr, int k, int dir);
150 
152 
174  static vtkIdType *InitializeSortIndices(vtkIdType numKeys);
175  static void GenerateSortIndices(int dataType, void *dataIn, vtkIdType numKeys,
176  int numComp, int k, vtkIdType *idx);
177  static void ShuffleArray(vtkIdType *idx, int dataType, vtkIdType numKeys,
178  int numComp, vtkAbstractArray *arr,
179  void *dataIn, int dir);
180  static void ShuffleIdList(vtkIdType *idx, vtkIdType sze, vtkIdList *arrayIn,
181  vtkIdType *dataIn, int dir);
183 
184 protected:
186  ~vtkSortDataArray() VTK_OVERRIDE;
187 
188  // A more efficient sort for single component arrays. This is delegated to
189  // by the methods above (if appropriate).
190  static void GenerateSort1Indices(int dataType, void *dataIn, vtkIdType numKeys,
191  vtkIdType *idx);
192 
193  // A more efficient shuffle for single component arrays. This is delegated to
194  // by the methods above (if appropriate).
195  static void Shuffle1Array(vtkIdType *idx, int dataType, vtkIdType numKeys,
196  vtkAbstractArray *arr, void *dataIn, int dir);
197 
198 private:
199  vtkSortDataArray(const vtkSortDataArray &) VTK_DELETE_FUNCTION;
200  void operator=(const vtkSortDataArray &) VTK_DELETE_FUNCTION;
201 };
202 
203 #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:59
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:287
a simple class to control print indentation
Definition: vtkIndent.h:39
list of point or cell ids
Definition: vtkIdList.h:36
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...