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 =========================================================================*/
146 #ifndef vtkThreshold_h
147 #define vtkThreshold_h
148 
149 #include "vtkDeprecation.h" // For VTK_DEPRECATED_IN_9_1_0
150 #include "vtkFiltersCoreModule.h" // For export macro
152 
153 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
154 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
155 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
156 
157 // order / values are important because of the SetClampMacro
158 #define VTK_COMPONENT_MODE_USE_SELECTED 0
159 #define VTK_COMPONENT_MODE_USE_ALL 1
160 #define VTK_COMPONENT_MODE_USE_ANY 2
161 
162 class vtkDataArray;
163 class vtkIdList;
164 
165 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
166 {
167 public:
168  static vtkThreshold* New();
170  void PrintSelf(ostream& os, vtkIndent indent) override;
171 
179  {
180  THRESHOLD_BETWEEN = 0,
182  THRESHOLD_UPPER
183  };
184 
186 
190  void SetThresholdFunction(int function);
193 
197  VTK_DEPRECATED_IN_9_1_0("Use 'SetLowerThreshold' and 'SetThresholdFunction' instead.")
198  void ThresholdByLower(double lower);
199 
203  VTK_DEPRECATED_IN_9_1_0("Use 'SetUpperThreshold' and 'SetThresholdFunction' instead.")
204  void ThresholdByUpper(double upper);
205 
211  "Use 'SetLowerThreshold', 'SetUpperThreshold' and 'SetThresholdFunction' instead.")
212  void ThresholdBetween(double lower, double upper);
213 
215 
219  vtkSetMacro(UpperThreshold, double);
220  vtkSetMacro(LowerThreshold, double);
221  vtkGetMacro(UpperThreshold, double);
222  vtkGetMacro(LowerThreshold, double);
224 
226 
233  vtkSetMacro(AttributeMode, int);
234  vtkGetMacro(AttributeMode, int);
235  void SetAttributeModeToDefault() { this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT); }
237  {
238  this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA);
239  }
243 
245 
253  vtkSetClampMacro(ComponentMode, int, VTK_COMPONENT_MODE_USE_SELECTED, VTK_COMPONENT_MODE_USE_ANY);
254  vtkGetMacro(ComponentMode, int);
256  void SetComponentModeToUseAll() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL); }
257  void SetComponentModeToUseAny() { this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY); }
260 
262 
266  vtkSetClampMacro(SelectedComponent, int, 0, VTK_INT_MAX);
267  vtkGetMacro(SelectedComponent, int);
269 
271 
277  vtkSetMacro(AllScalars, vtkTypeBool);
278  vtkGetMacro(AllScalars, vtkTypeBool);
279  vtkBooleanMacro(AllScalars, vtkTypeBool);
281 
283 
291  vtkSetMacro(UseContinuousCellRange, vtkTypeBool);
292  vtkGetMacro(UseContinuousCellRange, vtkTypeBool);
293  vtkBooleanMacro(UseContinuousCellRange, vtkTypeBool);
295 
297 
304  void SetPointsDataTypeToDouble() { this->SetPointsDataType(VTK_DOUBLE); }
305  void SetPointsDataTypeToFloat() { this->SetPointsDataType(VTK_FLOAT); }
309 
311 
316  vtkSetMacro(Invert, bool);
317  vtkGetMacro(Invert, bool);
318  vtkBooleanMacro(Invert, bool);
320 
322 
327  void SetOutputPointsPrecision(int precision);
330 
332 
345  int Lower(double s) const;
346  int Upper(double s) const;
347  int Between(double s) const;
349 protected:
351  ~vtkThreshold() override;
352 
353  // Usual data generation method
355 
357 
360  vtkTypeBool AllScalars = 1;
361  vtkTypeBool UseContinuousCellRange = 0;
362  bool Invert = false;
363  int AttributeMode = -1;
364  int ComponentMode = VTK_COMPONENT_MODE_USE_SELECTED;
365  int SelectedComponent = 0;
366  int OutputPointsPrecision = DEFAULT_PRECISION;
367 
368  int (vtkThreshold::*ThresholdFunction)(double s) const = &vtkThreshold::Between;
369 
371  int EvaluateCell(vtkDataArray* scalars, vtkIdList* cellPts, int numCellPts);
372  int EvaluateCell(vtkDataArray* scalars, int c, vtkIdList* cellPts, int numCellPts);
373 
374 private:
375  vtkThreshold(const vtkThreshold&) = delete;
376  void operator=(const vtkThreshold&) = delete;
377 };
378 
379 #endif
vtkThreshold::GetAttributeModeAsString
const char * GetAttributeModeAsString()
Control how the filter works with scalar point data and cell attribute data.
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:155
vtkThreshold::SetThresholdFunction
void SetThresholdFunction(int function)
Get/Set the threshold method, defining which threshold bounds to use.
vtkThreshold::ThresholdType
ThresholdType
Possible values for the threshold function:
Definition: vtkThreshold.h:179
VTK_ATTRIBUTE_MODE_USE_POINT_DATA
#define VTK_ATTRIBUTE_MODE_USE_POINT_DATA
Definition: vtkThreshold.h:154
vtkX3D::type
@ type
Definition: vtkX3D.h:522
vtkIdType
int vtkIdType
Definition: vtkType.h:332
vtkThreshold::SetComponentModeToUseAny
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:257
vtkThreshold::vtkThreshold
vtkThreshold()
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:145
VTK_COMPONENT_MODE_USE_ALL
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:159
VTK_DEPRECATED_IN_9_1_0
#define VTK_DEPRECATED_IN_9_1_0(reason)
Definition: vtkDeprecation.h:117
vtkThreshold::LowerThreshold
double LowerThreshold
Definition: vtkThreshold.h:358
vtkThreshold::SetAttributeModeToUsePointData
void SetAttributeModeToUsePointData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:236
vtkThreshold::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkThreshold::SetPointsDataTypeToFloat
void SetPointsDataTypeToFloat()
Set the data type of the output points (See the data types defined in vtkType.h).
Definition: vtkThreshold.h:305
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:159
vtkThreshold::EvaluateComponents
int EvaluateComponents(vtkDataArray *scalars, vtkIdType id)
vtkAlgorithm::DEFAULT_PRECISION
@ DEFAULT_PRECISION
Definition: vtkAlgorithm.h:153
vtkThreshold::SetPointsDataTypeToDouble
void SetPointsDataTypeToDouble()
Set the data type of the output points (See the data types defined in vtkType.h).
Definition: vtkThreshold.h:304
vtkThreshold::EvaluateCell
int EvaluateCell(vtkDataArray *scalars, vtkIdList *cellPts, int numCellPts)
vtkX3D::port
@ port
Definition: vtkX3D.h:453
vtkThreshold::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkThreshold::SetComponentModeToUseSelected
void SetComponentModeToUseSelected()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:255
vtkThreshold::GetComponentModeAsString
const char * GetComponentModeAsString()
Control how the decision of in / out is made with multi-component data.
vtkThreshold::SetComponentModeToUseAll
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:256
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:113
vtkThreshold
extracts cells where scalar value in cell satisfies threshold criterion
Definition: vtkThreshold.h:166
vtkThreshold::SetAttributeModeToUseCellData
void SetAttributeModeToUseCellData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:240
vtkThreshold::GetOutputPointsPrecision
int GetOutputPointsPrecision() const
Set/get the desired precision for the output types.
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:54
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:55
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:140
vtkThreshold::GetThresholdFunction
int GetThresholdFunction()
Get/Set the threshold method, defining which threshold bounds to use.
vtkThreshold::Lower
int Lower(double s) const
Methods used for thresholding.
vtkThreshold::SetPointsDataType
void SetPointsDataType(int type)
Set the data type of the output points (See the data types defined in vtkType.h).
vtkThreshold::~vtkThreshold
~vtkThreshold() override
VTK_ATTRIBUTE_MODE_DEFAULT
#define VTK_ATTRIBUTE_MODE_DEFAULT
Definition: vtkThreshold.h:153
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:183
vtkX3D::info
@ info
Definition: vtkX3D.h:382
vtkThreshold::Between
int Between(double s) const
Methods used for thresholding.
vtkDeprecation.h
VTK_ATTRIBUTE_MODE_USE_CELL_DATA
#define VTK_ATTRIBUTE_MODE_USE_CELL_DATA
Definition: vtkThreshold.h:155
VTK_COMPONENT_MODE_USE_SELECTED
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:158
vtkThreshold::THRESHOLD_LOWER
@ THRESHOLD_LOWER
Definition: vtkThreshold.h:181
vtkUnstructuredGridAlgorithm.h
vtkThreshold::RequestData
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) override
This is called by the superclass.
vtkUnstructuredGridAlgorithm
Superclass for algorithms that produce only unstructured grid as output.
Definition: vtkUnstructuredGridAlgorithm.h:41
vtkThreshold::SetOutputPointsPrecision
void SetOutputPointsPrecision(int precision)
Set/get the desired precision for the output types.
vtkThreshold::EvaluateCell
int EvaluateCell(vtkDataArray *scalars, int c, vtkIdList *cellPts, int numCellPts)
vtkThreshold::UpperThreshold
double UpperThreshold
Definition: vtkThreshold.h:359
vtkThreshold::GetPointsDataType
int GetPointsDataType()
Set the data type of the output points (See the data types defined in vtkType.h).
VTK_COMPONENT_MODE_USE_ANY
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:160
vtkThreshold::New
static vtkThreshold * New()
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
vtkThreshold::Upper
int Upper(double s) const
Methods used for thresholding.