VTK  9.3.1
vtkThreshold.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
40 #ifndef vtkThreshold_h
41 #define vtkThreshold_h
42 
43 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
44 #include "vtkFiltersCoreModule.h" // For export macro
46 
47 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
48 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
49 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
50 
51 // order / values are important because of the SetClampMacro
52 #define VTK_COMPONENT_MODE_USE_SELECTED 0
53 #define VTK_COMPONENT_MODE_USE_ALL 1
54 #define VTK_COMPONENT_MODE_USE_ANY 2
55 
56 VTK_ABI_NAMESPACE_BEGIN
57 class vtkDataArray;
58 class vtkIdList;
59 
60 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
61 {
62 public:
63  static vtkThreshold* New();
65  void PrintSelf(ostream& os, vtkIndent indent) override;
66 
74  {
75  THRESHOLD_BETWEEN = 0,
77  THRESHOLD_UPPER
78  };
79 
81 
85  void SetThresholdFunction(int function);
86  int GetThresholdFunction();
88 
90 
94  vtkSetMacro(UpperThreshold, double);
95  vtkSetMacro(LowerThreshold, double);
96  vtkGetMacro(UpperThreshold, double);
97  vtkGetMacro(LowerThreshold, double);
99 
101 
108  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
109  vtkSetMacro(AttributeMode, int);
110 
111  VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
112  vtkGetMacro(AttributeMode, int);
113 
114  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
115  void SetAttributeModeToDefault();
116 
117  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
118  void SetAttributeModeToUsePointData();
119 
120  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
121  void SetAttributeModeToUseCellData();
122 
123  VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
124  const char* GetAttributeModeAsString();
126 
128 
136  vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
137  vtkGetMacro(ComponentMode, int);
138  void SetComponentModeToUseSelected() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED); }
139  void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
140  void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
141  const char* GetComponentModeAsString();
143 
145 
149  vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
150  vtkGetMacro(SelectedComponent, int);
152 
154 
160  vtkSetMacro(AllScalars, vtkTypeBool);
161  vtkGetMacro(AllScalars, vtkTypeBool);
162  vtkBooleanMacro(AllScalars, vtkTypeBool);
164 
166 
174  vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
175  vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
176  vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
178 
180 
187  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
188  void SetPointsDataTypeToDouble();
189 
190  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
191  void SetPointsDataTypeToFloat();
192 
193  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
194  void SetPointsDataType(int type);
195 
196  VTK_DEPRECATED_IN_9_3_0("Please use GetOutputPointsPrecision instead.")
197  int GetPointsDataType();
199 
201 
206  vtkSetMacro(Invert, bool);
207  vtkGetMacro(Invert, bool);
208  vtkBooleanMacro(Invert, bool);
210 
212 
217  vtkSetMacro(OutputPointsPrecision, int);
218  vtkGetMacro(OutputPointsPrecision, int);
220 
222 
235  int Lower(double s) const;
236  int Upper(double s) const;
237  int Between(double s) const;
239 protected:
240  vtkThreshold();
241  ~vtkThreshold() override;
242 
243  // Usual data generation method
244  int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
245 
246  int FillInputPortInformation(int port, vtkInformation* info) override;
247 
248  double LowerThreshold;
249  double UpperThreshold;
250  vtkTypeBool AllScalars = 1;
251  vtkTypeBool UseContinuousCellRange = 0;
252  bool Invert = false;
253  int AttributeMode = -1;
254  int ComponentMode = VTK_COMPONENT_MODE_USE_SELECTED;
255  int SelectedComponent = 0;
256  int OutputPointsPrecision = DEFAULT_PRECISION;
257 
258  int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
259 
260  template <typename TScalarArray>
262  struct EvaluateCellsWorker;
263 
264  template <typename TScalarsArray>
265  int EvaluateComponents(TScalarsArray& scalars, vtkIdType id);
266  template <typename TScalarsArray>
267  int EvaluateCell(TScalarsArray& scalars, const vtkIdType* cellPts, vtkIdType numCellPts);
268  template <typename TScalarsArray>
269  int EvaluateCell(TScalarsArray& scalars, int c, const vtkIdType* cellPts, vtkIdType numCellPts);
270 
271 private:
272  vtkThreshold(const vtkThreshold&) = delete;
273  void operator=(const vtkThreshold&) = delete;
274 
275  int NumberOfComponents;
276 };
277 
278 VTK_ABI_NAMESPACE_END
279 #endif
Store vtkAlgorithm input/output information.
#define VTK_INT_MAX
Definition: vtkType.h:144
static vtkUnstructuredGridAlgorithm * New()
int vtkIdType
Definition: vtkType.h:315
int vtkTypeBool
Definition: vtkABI.h:64
extracts cells where scalar value in cell satisfies threshold criterion
Definition: vtkThreshold.h:60
#define VTK_DEPRECATED_IN_9_3_0(reason)
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
a simple class to control print indentation
Definition: vtkIndent.h:28
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:52
list of point or cell ids
Definition: vtkIdList.h:22
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:44
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:53
Superclass for algorithms that produce only unstructured grid as output.
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:139
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:54
Store zero or more vtkInformation instances.
ThresholdType
Possible values for the threshold function:
Definition: vtkThreshold.h:73
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:140