File: vtkSortFieldData.h

package info (click to toggle)
vtk9 9.0.1%2Bdfsg1-8
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 133,688 kB
  • sloc: cpp: 1,568,287; ansic: 208,587; python: 87,847; xml: 8,022; java: 4,509; yacc: 4,027; sh: 2,515; perl: 2,183; lex: 1,766; objc: 143; makefile: 126; tcl: 59
file content (117 lines) | stat: -rw-r--r-- 4,837 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*=========================================================================

  Program:   Visualization Toolkit
  Module:    vtkSortFieldData.h

  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
  All rights reserved.
  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.

     This software is distributed WITHOUT ANY WARRANTY; without even
     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
     PURPOSE.  See the above copyright notice for more information.

=========================================================================*/

/**
 * @class   vtkSortFieldData
 * @brief   provides a method for sorting field data
 *
 *
 * vtkSortFieldData is used to sort data, based on its value, or with an
 * associated key, into either ascending or descending order. This is useful
 * for operations like selection, or analysis, when evaluating and processing
 * data.
 *
 * This class, which extends the base functionality of vtkSortDataArray,
 * is used to sort field data and its various subclasses (vtkFieldData,
 * vtkDataSetAttributes, vtkPointData, vtkCellData, etc.)
 *
 * @warning
 * This class has been threaded with vtkSMPTools. Using TBB or other
 * non-sequential type (set in the CMake variable
 * VTK_SMP_IMPLEMENTATION_TYPE) may improve performance significantly on
 * multi-core machines.
 *
 * @warning
 * The sort methods below are static, hence the sorting methods can be
 * used without instantiating the class. All methods are thread safe.
 *
 * @sa
 * vtkSortDataArray
 */

#ifndef vtkSortFieldData_h
#define vtkSortFieldData_h

#include "vtkCommonDataModelModule.h" // For export macro
#include "vtkSortDataArray.h"

class vtkFieldData;

class VTKCOMMONDATAMODEL_EXPORT vtkSortFieldData : public vtkSortDataArray
{
public:
  //@{
  /**
   * Standard VTK methods for instantiating, managing type, and printing
   * information about this class.
   */
  static vtkSortFieldData* New();
  vtkTypeMacro(vtkSortFieldData, vtkSortDataArray);
  void PrintSelf(ostream& os, vtkIndent indent) override;
  //@}

  /**
   * Given field data (and derived classes such as point data and cell data),
   * sort all the arrays in the field data given an array and a component
   * number k from that array. In other words, if an array has n components,
   * the kth component is used to sort the array and all of the other arrays
   * in the field data.  Also note that the user can indicate whether the
   * function returns the sort indices (returnIndices=1). If the indices are
   * returned, then the user takes ownership of the data and must delete
   * it. Note that the indices are in sorted (ascending) order, and indicate
   * the final sorted position of the sort. So for example indices[0]=10
   * indicates that the original data in position 10 in the field, was moved
   * to position 0 after the sort. By default, returnIndices=0. (Other notes:
   * if any array is not the same length as the sorting array, then it will
   * be skipped and not sorted.)
   */
  static vtkIdType* Sort(vtkFieldData* fd, const char* arrayName, int k, int returnIndices)
  {
    return vtkSortFieldData::Sort(fd, arrayName, k, returnIndices, 0);
  }

  /**
   * Given field data (and derived classes such as point data and cell data),
   * sort all the arrays in the field data given an array and a component
   * number k from that array. In other words, if an array has n components,
   * the kth component is used to sort the array and all of the other arrays
   * in the field data.  The order of the sorted data is goven by dir: dir=0
   * means sort in ascending order; dir=1 means sort in descending
   * order. Also note that the user can indicate whether the function returns
   * the sort indices (returnIndices=1). If the indices are returned, then
   * the user takes ownership of the data and must delete it. Note that the
   * indices are always in sorted (ascending) order, and indicate the final
   * sorted position of the sort. So for example indices[0]=10 indicates that
   * the original data in position 10 in the field, was moved to position 0
   * after the sort (i.e., position 0 is the smallest value). However, if
   * sort direction dir=1, the indices do not change but the final shuffle of
   * the data is in reverse order (note idx[n-1] for n keys is the largest
   * value). By default, returnIndices=0. (Other notes: if any array is not
   * the same length as the sorting array, then it will be skipped and not
   * sorted.)
   */
  static vtkIdType* Sort(
    vtkFieldData* fd, const char* arrayName, int k, int returnIndices, int dir);

protected:
  vtkSortFieldData();
  ~vtkSortFieldData() override;

private:
  vtkSortFieldData(const vtkSortFieldData&) = delete;
  void operator=(const vtkSortFieldData&) = delete;
};

#endif // vtkSortFieldData_h