VTK  9.3.20240424
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
150#ifndef vtkThreshold_h
151#define vtkThreshold_h
152
153#include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
154#include "vtkFiltersCoreModule.h" // For export macro
156
157#define VTK_ATTRIBUTE_MODE_DEFAULT 0
158#define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
159#define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
160
161// order / values are important because of the SetClampMacro
162#define VTK_COMPONENT_MODE_USE_SELECTED 0
163#define VTK_COMPONENT_MODE_USE_ALL 1
164#define VTK_COMPONENT_MODE_USE_ANY 2
165
166VTK_ABI_NAMESPACE_BEGIN
167class vtkDataArray;
168class vtkIdList;
169
170class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
171{
172public:
173 static vtkThreshold* New();
175 void PrintSelf(ostream& os, vtkIndent indent) override;
176
184 {
185 THRESHOLD_BETWEEN = 0,
187 THRESHOLD_UPPER
188 };
189
191
195 void SetThresholdFunction(int function);
198
200
204 vtkSetMacro(UpperThreshold, double);
205 vtkSetMacro(LowerThreshold, double);
206 vtkGetMacro(UpperThreshold, double);
207 vtkGetMacro(LowerThreshold, double);
209
211
218 VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
219 vtkSetMacro(AttributeMode, int);
220
221 VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
222 vtkGetMacro(AttributeMode, int);
223
224 VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
225 void SetAttributeModeToDefault();
226
227 VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
228 void SetAttributeModeToUsePointData();
229
230 VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
231 void SetAttributeModeToUseCellData();
232
233 VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
234 const char* GetAttributeModeAsString();
236
238
246 vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
247 vtkGetMacro(ComponentMode, int);
248 void SetComponentModeToUseSelected() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED); }
249 void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
250 void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
253
255
261 vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
262 vtkGetMacro(SelectedComponent, int);
264
266
272 vtkSetMacro(AllScalars, vtkTypeBool);
273 vtkGetMacro(AllScalars, vtkTypeBool);
274 vtkBooleanMacro(AllScalars, vtkTypeBool);
276
278
286 vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
287 vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
288 vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
290
292
299 VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
300 void SetPointsDataTypeToDouble();
301
302 VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
303 void SetPointsDataTypeToFloat();
304
305 VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
306 void SetPointsDataType(int type);
307
308 VTK_DEPRECATED_IN_9_3_0("Please use GetOutputPointsPrecision instead.")
309 int GetPointsDataType();
311
313
318 vtkSetMacro(Invert, bool);
319 vtkGetMacro(Invert, bool);
320 vtkBooleanMacro(Invert, bool);
322
324
329 vtkSetMacro(OutputPointsPrecision, int);
330 vtkGetMacro(OutputPointsPrecision, int);
332
334
347 int Lower(double s) const;
348 int Upper(double s) const;
349 int Between(double s) const;
351protected:
353 ~vtkThreshold() override;
354
355 // Usual data generation method
357
358 int FillInputPortInformation(int port, vtkInformation* info) override;
359
360 double LowerThreshold;
361 double UpperThreshold;
362 vtkTypeBool AllScalars = 1;
363 vtkTypeBool UseContinuousCellRange = 0;
364 bool Invert = false;
365 int AttributeMode = -1;
367 int SelectedComponent = 0;
368 int OutputPointsPrecision = DEFAULT_PRECISION;
369
370 int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
371
372 template <typename TScalarArray>
374 struct EvaluateCellsWorker;
375
376 template <typename TScalarsArray>
377 int EvaluateComponents(TScalarsArray& scalars, vtkIdType id);
378 template <typename TScalarsArray>
379 int EvaluateCell(TScalarsArray& scalars, const vtkIdType* cellPts, vtkIdType numCellPts);
380 template <typename TScalarsArray>
381 int EvaluateCell(TScalarsArray& scalars, int c, const vtkIdType* cellPts, vtkIdType numCellPts);
382
383private:
389 template <typename TScalarsArray>
390 bool ComputeMagnitude(double& magnitude, const TScalarsArray& scalars, vtkIdType id);
391
392 vtkThreshold(const vtkThreshold&) = delete;
393 void operator=(const vtkThreshold&) = delete;
394
395 int NumberOfComponents;
396};
397
398VTK_ABI_NAMESPACE_END
399#endif
abstract superclass for arrays of numeric data
list of point or cell ids
Definition vtkIdList.h:133
a simple class to control print indentation
Definition vtkIndent.h:108
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