VTK  9.1.0
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 =========================================================================*/
37 #ifndef vtkThreshold_h
38 #define vtkThreshold_h
39 
40 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_1_0
41 #include "vtkFiltersCoreModule.h" // For export macro
43 
44 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
45 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
46 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
47 
48 // order / values are important because of the SetClampMacro
49 #define VTK_COMPONENT_MODE_USE_SELECTED 0
50 #define VTK_COMPONENT_MODE_USE_ALL 1
51 #define VTK_COMPONENT_MODE_USE_ANY 2
52 
53 class vtkDataArray;
54 class vtkIdList;
55 
56 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
57 {
58 public:
59  static vtkThreshold* New();
61  void PrintSelf(ostream& os, vtkIndent indent) override;
62 
70  {
71  THRESHOLD_BETWEEN = 0,
73  THRESHOLD_UPPER
74  };
75 
77 
81  void SetThresholdFunction(int function);
84 
88  VTK_DEPRECATED_IN_9_1_0("Use 'SetLowerThreshold' and 'SetThresholdFunction' instead.")
89  void ThresholdByLower(double lower);
90 
94  VTK_DEPRECATED_IN_9_1_0("Use 'SetUpperThreshold' and 'SetThresholdFunction' instead.")
95  void ThresholdByUpper(double upper);
96 
102  "Use 'SetLowerThreshold', 'SetUpperThreshold' and 'SetThresholdFunction' instead.")
103  void ThresholdBetween(double lower, double upper);
104 
106 
110  vtkSetMacro(UpperThreshold, double);
111  vtkSetMacro(LowerThreshold, double);
112  vtkGetMacro(UpperThreshold, double);
113  vtkGetMacro(LowerThreshold, double);
115 
117 
124  vtkSetMacro(AttributeMode, int);
125  vtkGetMacro(AttributeMode, int);
126  void SetAttributeModeToDefault() { this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT); }
128  {
129  this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA);
130  }
134 
136 
144  vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
145  vtkGetMacro(ComponentMode, int);
147  void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
148  void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
151 
153 
157  vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
158  vtkGetMacro(SelectedComponent, int);
160 
162 
168  vtkSetMacro(AllScalars, vtkTypeBool);
169  vtkGetMacro(AllScalars, vtkTypeBool);
170  vtkBooleanMacro(AllScalars, vtkTypeBool);
172 
174 
182  vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
183  vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
184  vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
186 
188 
195  void SetPointsDataTypeToDouble() { this->SetPointsDataType(VTK_DOUBLE); }
196  void SetPointsDataTypeToFloat() { this->SetPointsDataType(VTK_FLOAT); }
200 
202 
207  vtkSetMacro(Invert, bool);
208  vtkGetMacro(Invert, bool);
209  vtkBooleanMacro(Invert, bool);
211 
213 
218  void SetOutputPointsPrecision(int precision);
221 
223 
236  int Lower(double s) const;
237  int Upper(double s) const;
238  int Between(double s) const;
240 protected:
242  ~vtkThreshold() override;
243 
244  // Usual data generation method
246 
248 
251  vtkTypeBool AllScalars = 1;
252  vtkTypeBool UseContinuousCellRange = 0;
253  bool Invert = false;
254  int AttributeMode = -1;
255  int ComponentMode = VTK_COMPONENT_MODE_USE_SELECTED;
256  int SelectedComponent = 0;
257  int OutputPointsPrecision = DEFAULT_PRECISION;
258 
259  int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
260 
262  int EvaluateCell(vtkDataArray* scalars, vtkIdList* cellPts, int numCellPts);
263  int EvaluateCell(vtkDataArray* scalars, int c, vtkIdList* cellPts, int numCellPts);
264 
265 private:
266  vtkThreshold(const vtkThreshold&) = delete;
267  void operator=(const vtkThreshold&) = delete;
268 };
269 
270 #endif
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:50
list of point or cell ids
Definition: vtkIdList.h:31
a simple class to control print indentation
Definition: vtkIndent.h:34
Store zero or more vtkInformation instances.
Store vtkAlgorithm input/output information.
extracts cells where scalar value in cell satisfies threshold criterion
Definition: vtkThreshold.h:57
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int EvaluateCell(vtkDataArray *scalars, vtkIdList *cellPts, int numCellPts)
const char * GetComponentModeAsString()
Control how the decision of in / out is made with multi-component data.
void SetAttributeModeToUsePointData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:127
void SetPointsDataType(int type)
Set the data type of the output points (See the data types defined in vtkType.h).
void SetThresholdFunction(int function)
Get/Set the threshold method, defining which threshold bounds to use.
void SetComponentModeToUseSelected()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:146
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:148
const char * GetAttributeModeAsString()
Control how the filter works with scalar point data and cell attribute data.
ThresholdType
Possible values for the threshold function:
Definition: vtkThreshold.h:70
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:147
int GetOutputPointsPrecision() const
Set/get the desired precision for the output types.
double LowerThreshold
Definition: vtkThreshold.h:249
void SetPointsDataTypeToDouble()
Set the data type of the output points (See the data types defined in vtkType.h).
Definition: vtkThreshold.h:195
void SetAttributeModeToUseCellData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:131
int EvaluateComponents(vtkDataArray *scalars, vtkIdType id)
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
int GetPointsDataType()
Set the data type of the output points (See the data types defined in vtkType.h).
void SetPointsDataTypeToFloat()
Set the data type of the output points (See the data types defined in vtkType.h).
Definition: vtkThreshold.h:196
double UpperThreshold
Definition: vtkThreshold.h:250
void SetOutputPointsPrecision(int precision)
Set/get the desired precision for the output types.
static vtkThreshold * New()
int Upper(double s) const
Methods used for thresholding.
~vtkThreshold() override
int Between(double s) const
Methods used for thresholding.
int EvaluateCell(vtkDataArray *scalars, int c, vtkIdList *cellPts, int numCellPts)
int Lower(double s) const
Methods used for thresholding.
int GetThresholdFunction()
Get/Set the threshold method, defining which threshold bounds to use.
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
Superclass for algorithms that produce only unstructured grid as output.
@ info
Definition: vtkX3D.h:382
@ port
Definition: vtkX3D.h:453
@ type
Definition: vtkX3D.h:522
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DEPRECATED_IN_9_1_0(reason)
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:49
#define VTK_ATTRIBUTE_MODE_USE_POINT_DATA
Definition: vtkThreshold.h:45
#define VTK_ATTRIBUTE_MODE_DEFAULT
Definition: vtkThreshold.h:44
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:50
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:51
#define VTK_ATTRIBUTE_MODE_USE_CELL_DATA
Definition: vtkThreshold.h:46
int vtkIdType
Definition: vtkType.h:332
#define VTK_DOUBLE
Definition: vtkType.h:55
#define VTK_FLOAT
Definition: vtkType.h:54
#define VTK_INT_MAX
Definition: vtkType.h:155