VTK  9.2.20230327
vtkThreshold.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Visualization Toolkit
4  Module: vtkThreshold.h
5 
6  Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7  All rights reserved.
8  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9 
10  This software is distributed WITHOUT ANY WARRANTY; without even
11  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12  PURPOSE. See the above copyright notice for more information.
13 
14 =========================================================================*/
161 #ifndef vtkThreshold_h
162 #define vtkThreshold_h
163 
164 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_3_0
165 #include "vtkFiltersCoreModule.h" // For export macro
167 
168 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
169 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
170 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
171 
172 // order / values are important because of the SetClampMacro
173 #define VTK_COMPONENT_MODE_USE_SELECTED 0
174 #define VTK_COMPONENT_MODE_USE_ALL 1
175 #define VTK_COMPONENT_MODE_USE_ANY 2
176 
177 VTK_ABI_NAMESPACE_BEGIN
178 class vtkDataArray;
179 class vtkIdList;
180 
181 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
182 {
183 public:
184  static vtkThreshold* New();
186  void PrintSelf(ostream& os, vtkIndent indent) override;
187 
195  {
196  THRESHOLD_BETWEEN = 0,
198  THRESHOLD_UPPER
199  };
200 
202 
206  void SetThresholdFunction(int function);
209 
211 
215  vtkSetMacro(UpperThreshold, double);
216  vtkSetMacro(LowerThreshold, double);
217  vtkGetMacro(UpperThreshold, double);
218  vtkGetMacro(LowerThreshold, double);
220 
222 
229  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
230  vtkSetMacro(AttributeMode, int);
231 
232  VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
233  vtkGetMacro(AttributeMode, int);
234 
235  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
236  void SetAttributeModeToDefault();
237 
238  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
239  void SetAttributeModeToUsePointData();
240 
241  VTK_DEPRECATED_IN_9_3_0("Please use SetInputArrayToProcess instead.")
242  void SetAttributeModeToUseCellData();
243 
244  VTK_DEPRECATED_IN_9_3_0("This method is deprecated.")
245  const char* GetAttributeModeAsString();
247 
249 
257  vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
258  vtkGetMacro(ComponentMode, int);
259  void SetComponentModeToUseSelected() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED); }
260  void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
261  void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
264 
266 
270  vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
271  vtkGetMacro(SelectedComponent, int);
273 
275 
281  vtkSetMacro(AllScalars, vtkTypeBool);
282  vtkGetMacro(AllScalars, vtkTypeBool);
283  vtkBooleanMacro(AllScalars, vtkTypeBool);
285 
287 
295  vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
296  vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
297  vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
299 
301 
308  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
309  void SetPointsDataTypeToDouble();
310 
311  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
312  void SetPointsDataTypeToFloat();
313 
314  VTK_DEPRECATED_IN_9_3_0("Please use SetOutputPointsPrecision instead.")
315  void SetPointsDataType(int type);
316 
317  VTK_DEPRECATED_IN_9_3_0("Please use GetOutputPointsPrecision instead.")
318  int GetPointsDataType();
320 
322 
327  vtkSetMacro(Invert, bool);
328  vtkGetMacro(Invert, bool);
329  vtkBooleanMacro(Invert, bool);
331 
333 
338  vtkSetMacro(OutputPointsPrecision, int);
339  vtkGetMacro(OutputPointsPrecision, int);
341 
343 
356  int Lower(double s) const;
357  int Upper(double s) const;
358  int Between(double s) const;
360 protected:
362  ~vtkThreshold() override;
363 
364  // Usual data generation method
366 
367  int FillInputPortInformation(int port, vtkInformation* info) override;
368 
369  double LowerThreshold;
370  double UpperThreshold;
371  vtkTypeBool AllScalars = 1;
372  vtkTypeBool UseContinuousCellRange = 0;
373  bool Invert = false;
374  int AttributeMode = -1;
375  int ComponentMode = VTK_COMPONENT_MODE_USE_SELECTED;
376  int SelectedComponent = 0;
377  int OutputPointsPrecision = DEFAULT_PRECISION;
378 
379  int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
380 
381  template <typename TScalarArray>
383  struct EvaluateCellsWorker;
384 
385  template <typename TScalarsArray>
386  int EvaluateComponents(TScalarsArray& scalars, vtkIdType id);
387  template <typename TScalarsArray>
388  int EvaluateCell(TScalarsArray& scalars, const vtkIdType* cellPts, vtkIdType numCellPts);
389  template <typename TScalarsArray>
390  int EvaluateCell(TScalarsArray& scalars, int c, const vtkIdType* cellPts, vtkIdType numCellPts);
391 
392 private:
393  vtkThreshold(const vtkThreshold&) = delete;
394  void operator=(const vtkThreshold&) = delete;
395 
396  int NumberOfComponents;
397 };
398 
399 VTK_ABI_NAMESPACE_END
400 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:166
list of point or cell ids
Definition: vtkIdList.h:144
a simple class to control print indentation
Definition: vtkIndent.h:120
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
extracts cells where scalar value in cell satisfies threshold criterion
Definition: vtkThreshold.h:182
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:261
ThresholdType
Possible values for the threshold function:
Definition: vtkThreshold.h:195
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:260
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:388
@ port
Definition: vtkX3D.h:459
@ type
Definition: vtkX3D.h:528
int vtkTypeBool
Definition: vtkABI.h:71
#define VTK_DEPRECATED_IN_9_3_0(reason)
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:173
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:174
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:175
int vtkIdType
Definition: vtkType.h:327
#define VTK_INT_MAX
Definition: vtkType.h:156