VTK  9.3.0
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
49 #ifndef vtkThreshold_h
50 #define vtkThreshold_h
51 
52 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
53 #include "vtkFiltersCoreModule.h" // For export macro
55 
56 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
57 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
58 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
59 
60 // order / values are important because of the SetClampMacro
61 #define VTK_COMPONENT_MODE_USE_SELECTED 0
62 #define VTK_COMPONENT_MODE_USE_ALL 1
63 #define VTK_COMPONENT_MODE_USE_ANY 2
64 
65 VTK_ABI_NAMESPACE_BEGIN
66 class vtkDataArray;
67 class vtkIdList;
68 
69 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
70 {
71 public:
72  static vtkThreshold* New();
74  void PrintSelf(ostream& os, vtkIndent indent) override;
75 
83  {
84  THRESHOLD_BETWEEN = 0,
86  THRESHOLD_UPPER
87  };
88 
90 
94  void SetThresholdFunction(int function);
97 
99 
103  vtkSetMacro(UpperThreshold, double);
104  vtkSetMacro(LowerThreshold, double);
105  vtkGetMacro(UpperThreshold, double);
106  vtkGetMacro(LowerThreshold, double);
108 
110 
117  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
118  vtkSetMacro(AttributeMode, int);
119 
120  VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
121  vtkGetMacro(AttributeMode, int);
122 
123  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
124  void SetAttributeModeToDefault();
125 
126  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
127  void SetAttributeModeToUsePointData();
128 
129  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
130  void SetAttributeModeToUseCellData();
131 
132  VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
133  const char* GetAttributeModeAsString();
135 
137 
145  vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
146  vtkGetMacro(ComponentMode, int);
147  void SetComponentModeToUseSelected() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED); }
148  void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
149  void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
152 
154 
158  vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
159  vtkGetMacro(SelectedComponent, int);
161 
163 
169  vtkSetMacro(AllScalars, vtkTypeBool);
170  vtkGetMacro(AllScalars, vtkTypeBool);
171  vtkBooleanMacro(AllScalars, vtkTypeBool);
173 
175 
183  vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
184  vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
185  vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
187 
189 
196  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
197  void SetPointsDataTypeToDouble();
198 
199  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
200  void SetPointsDataTypeToFloat();
201 
202  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
203  void SetPointsDataType(int type);
204 
205  VTK_DEPRECATED_IN_9_3_0("Please use GetOutputPointsPrecision instead.")
206  int GetPointsDataType();
208 
210 
215  vtkSetMacro(Invert, bool);
216  vtkGetMacro(Invert, bool);
217  vtkBooleanMacro(Invert, bool);
219 
221 
226  vtkSetMacro(OutputPointsPrecision, int);
227  vtkGetMacro(OutputPointsPrecision, int);
229 
231 
244  int Lower(double s) const;
245  int Upper(double s) const;
246  int Between(double s) const;
248 protected:
250  ~vtkThreshold() override;
251 
252  // Usual data generation method
254 
255  int FillInputPortInformation(int port, vtkInformation* info) override;
256 
257  double LowerThreshold;
258  double UpperThreshold;
259  vtkTypeBool AllScalars = 1;
260  vtkTypeBool UseContinuousCellRange = 0;
261  bool Invert = false;
262  int AttributeMode = -1;
263  int ComponentMode = VTK_COMPONENT_MODE_USE_SELECTED;
264  int SelectedComponent = 0;
265  int OutputPointsPrecision = DEFAULT_PRECISION;
266 
267  int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
268 
269  template <typename TScalarArray>
271  struct EvaluateCellsWorker;
272 
273  template <typename TScalarsArray>
274  int EvaluateComponents(TScalarsArray& scalars, vtkIdType id);
275  template <typename TScalarsArray>
276  int EvaluateCell(TScalarsArray& scalars, const vtkIdType* cellPts, vtkIdType numCellPts);
277  template <typename TScalarsArray>
278  int EvaluateCell(TScalarsArray& scalars, int c, const vtkIdType* cellPts, vtkIdType numCellPts);
279 
280 private:
281  vtkThreshold(const vtkThreshold&) = delete;
282  void operator=(const vtkThreshold&) = delete;
283 
284  int NumberOfComponents;
285 };
286 
287 VTK_ABI_NAMESPACE_END
288 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
list of point or cell ids
Definition: vtkIdList.h:32
a simple class to control print indentation
Definition: vtkIndent.h:38
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
extracts cells where scalar value in cell satisfies threshold criterion
Definition: vtkThreshold.h:70
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
const char * GetComponentModeAsString()
Control how the decision of in / out is made with multi-component data.
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.
Definition: vtkThreshold.h:149
ThresholdType
Possible values for the threshold function:
Definition: vtkThreshold.h:83
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:148
static vtkThreshold * New()
int GetThresholdFunction()
Get/Set the threshold method, defining which threshold bounds to use.
Superclass for algorithms that produce only unstructured grid as output.
@ info
Definition: vtkX3D.h:376
@ port
Definition: vtkX3D.h:447
@ type
Definition: vtkX3D.h:516
int vtkTypeBool
Definition: vtkABI.h:64
#define VTK_DEPRECATED_IN_9_3_0(reason)
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:61
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:62
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:63
int vtkIdType
Definition: vtkType.h:315
#define VTK_INT_MAX
Definition: vtkType.h:144