VTK  9.4.20251203
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
41#ifndef vtkThreshold_h
42#define vtkThreshold_h
43
44#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
45#include "vtkFiltersCoreModule.h" // For export macro
47
48#define VTK_ATTRIBUTE_MODE_DEFAULT 0
49#define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
50#define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
51
52// order / values are important because of the SetClampMacro
53#define VTK_COMPONENT_MODE_USE_SELECTED 0
54#define VTK_COMPONENT_MODE_USE_ALL 1
55#define VTK_COMPONENT_MODE_USE_ANY 2
56
57VTK_ABI_NAMESPACE_BEGIN
58class vtkDataArray;
59class vtkIdList;
60
61class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
62{
63public:
64 static vtkThreshold* New();
66 void PrintSelf(ostream& os, vtkIndent indent) override;
67
75 {
76 THRESHOLD_BETWEEN = 0,
78 THRESHOLD_UPPER
79 };
80
82
86 void SetThresholdFunction(int function);
89
91
95 vtkSetMacro(UpperThreshold, double);
96 vtkSetMacro(LowerThreshold, double);
97 vtkGetMacro(UpperThreshold, double);
98 vtkGetMacro(LowerThreshold, double);
100
102
109 VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
110 vtkSetMacro(AttributeMode, int);
111
112 VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
113 vtkGetMacro(AttributeMode, int);
114
115 VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
116 void SetAttributeModeToDefault();
117
118 VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
119 void SetAttributeModeToUsePointData();
120
121 VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
122 void SetAttributeModeToUseCellData();
123
124 VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
125 const char* GetAttributeModeAsString();
127
129
137 vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
138 vtkGetMacro(ComponentMode, int);
139 void SetComponentModeToUseSelected() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED); }
140 void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
141 void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
144
146
152 vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
153 vtkGetMacro(SelectedComponent, int);
155
157
163 vtkSetMacro(AllScalars, vtkTypeBool);
164 vtkGetMacro(AllScalars, vtkTypeBool);
165 vtkBooleanMacro(AllScalars, vtkTypeBool);
167
169
177 vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
178 vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
179 vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
181
183
190 VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
191 void SetPointsDataTypeToDouble();
192
193 VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
194 void SetPointsDataTypeToFloat();
195
196 VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
197 void SetPointsDataType(int type);
198
199 VTK_DEPRECATED_IN_9_3_0("Please use GetOutputPointsPrecision instead.")
200 int GetPointsDataType();
202
204
209 vtkSetMacro(Invert, bool);
210 vtkGetMacro(Invert, bool);
211 vtkBooleanMacro(Invert, bool);
213
215
220 vtkSetMacro(OutputPointsPrecision, int);
221 vtkGetMacro(OutputPointsPrecision, int);
223
225
238 int Lower(double s) const;
239 int Upper(double s) const;
240 int Between(double s) const;
242protected:
244 ~vtkThreshold() override;
245
246 // Usual data generation method
248
249 int FillInputPortInformation(int port, vtkInformation* info) override;
250
251 double LowerThreshold;
252 double UpperThreshold;
253 vtkTypeBool AllScalars = 1;
254 vtkTypeBool UseContinuousCellRange = 0;
255 bool Invert = false;
256 int AttributeMode = -1;
258 int SelectedComponent = 0;
259 int OutputPointsPrecision = DEFAULT_PRECISION;
260
261 int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
262
263 template <typename TScalarArray>
265 struct EvaluateCellsWorker;
266
267 template <typename TScalarsArray>
268 int EvaluateComponents(TScalarsArray& scalars, vtkIdType id);
269 template <typename TScalarsArray>
270 int EvaluateCell(TScalarsArray& scalars, const vtkIdType* cellPts, vtkIdType numCellPts);
271 template <typename TScalarsArray>
272 int EvaluateCell(TScalarsArray& scalars, int c, const vtkIdType* cellPts, vtkIdType numCellPts);
273
274private:
280 template <typename TScalarsArray>
281 bool ComputeMagnitude(double& magnitude, const TScalarsArray& scalars, vtkIdType id);
282
283 vtkThreshold(const vtkThreshold&) = delete;
284 void operator=(const vtkThreshold&) = delete;
285
286 int NumberOfComponents;
287};
288
289VTK_ABI_NAMESPACE_END
290#endif
abstract superclass for arrays of numeric data
list of point or cell ids
Definition vtkIdList.h:24
a simple class to control print indentation
Definition vtkIndent.h:29
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
extracts cells where scalar value in cell satisfies threshold criterion
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
void SetThresholdFunction(int function)
Get/Set the threshold method, defining which threshold bounds to use.
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
ThresholdType
Possible values for the threshold function:
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
const char * GetComponentModeAsString()
Control how the decision of in / out is made with multi-component data.
int GetThresholdFunction()
Get/Set the threshold method, defining which threshold bounds to use.
static vtkThreshold * New()
Superclass for algorithms that produce only unstructured grid as output.
int vtkTypeBool
Definition vtkABI.h:64
#define VTK_DEPRECATED_IN_9_3_0(reason)
#define VTK_COMPONENT_MODE_USE_SELECTED
#define VTK_COMPONENT_MODE_USE_ALL
#define VTK_COMPONENT_MODE_USE_ANY
int vtkIdType
Definition vtkType.h:315
#define VTK_INT_MAX
Definition vtkType.h:144