VTK
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 "vtkFiltersCoreModule.h" // For export macro
42 
43 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
44 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
45 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
46 
47 // order / values are important because of the SetClampMacro
48 #define VTK_COMPONENT_MODE_USE_SELECTED 0
49 #define VTK_COMPONENT_MODE_USE_ALL 1
50 #define VTK_COMPONENT_MODE_USE_ANY 2
51 
52 class vtkDataArray;
53 class vtkIdList;
54 
55 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
56 {
57 public:
58  static vtkThreshold *New();
60  void PrintSelf(ostream& os, vtkIndent indent) override;
61 
65  void ThresholdByLower(double lower);
66 
70  void ThresholdByUpper(double upper);
71 
76  void ThresholdBetween(double lower, double upper);
77 
79 
82  vtkGetMacro(UpperThreshold,double);
83  vtkGetMacro(LowerThreshold,double);
85 
87 
94  vtkSetMacro(AttributeMode,int);
95  vtkGetMacro(AttributeMode,int);
97  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT);};
99  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA);};
101  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_CELL_DATA);};
102  const char *GetAttributeModeAsString();
104 
106 
114  vtkSetClampMacro(ComponentMode,int,
117  vtkGetMacro(ComponentMode,int);
119  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED);};
121  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL);};
123  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY);};
124  const char *GetComponentModeAsString();
126 
128 
132  vtkSetClampMacro(SelectedComponent,int,0,VTK_INT_MAX);
133  vtkGetMacro(SelectedComponent,int);
135 
137 
143  vtkSetMacro(AllScalars,vtkTypeBool);
144  vtkGetMacro(AllScalars,vtkTypeBool);
145  vtkBooleanMacro(AllScalars,vtkTypeBool);
147 
149 
157  vtkSetMacro(UseContinuousCellRange,vtkTypeBool);
158  vtkGetMacro(UseContinuousCellRange,vtkTypeBool);
159  vtkBooleanMacro(UseContinuousCellRange,vtkTypeBool);
161 
163 
170  void SetPointsDataTypeToDouble() { this->SetPointsDataType( VTK_DOUBLE ); }
171  void SetPointsDataTypeToFloat() { this->SetPointsDataType( VTK_FLOAT ); }
172  void SetPointsDataType(int type);
173  int GetPointsDataType();
175 
177 
182  void SetOutputPointsPrecision(int precision);
183  int GetOutputPointsPrecision() const;
185 
186 protected:
187  vtkThreshold();
188  ~vtkThreshold() override;
189 
190  // Usual data generation method
192 
193  int FillInputPortInformation(int port, vtkInformation *info) override;
194 
195 
204 
205  int (vtkThreshold::*ThresholdFunction)(double s);
206 
207  int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );};
208  int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );};
209  int Between(double s) {return ( s >= this->LowerThreshold ?
210  ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );};
211 
212  int EvaluateComponents( vtkDataArray *scalars, vtkIdType id );
213  int EvaluateCell( vtkDataArray *scalars, vtkIdList* cellPts, int numCellPts );
214  int EvaluateCell( vtkDataArray *scalars, int c, vtkIdList* cellPts, int numCellPts );
215 private:
216  vtkThreshold(const vtkThreshold&) = delete;
217  void operator=(const vtkThreshold&) = delete;
218 };
219 
220 #endif
double UpperThreshold
Definition: vtkThreshold.h:198
double LowerThreshold
Definition: vtkThreshold.h:197
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
Store vtkAlgorithm input/output information.
#define VTK_INT_MAX
Definition: vtkType.h:157
#define VTK_ATTRIBUTE_MODE_USE_CELL_DATA
Definition: vtkThreshold.h:45
#define VTK_ATTRIBUTE_MODE_USE_POINT_DATA
Definition: vtkThreshold.h:44
void SetPointsDataTypeToDouble()
Set the data type of the output points (See the data types defined in vtkType.h).
Definition: vtkThreshold.h:170
static vtkUnstructuredGridAlgorithm * New()
int vtkIdType
Definition: vtkType.h:345
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
void SetAttributeModeToUseCellData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:100
vtkTypeBool AllScalars
Definition: vtkThreshold.h:196
int vtkTypeBool
Definition: vtkABI.h:69
#define VTK_DOUBLE
Definition: vtkType.h:59
#define VTK_FLOAT
Definition: vtkType.h:58
extracts cells where scalar value in cell satisfies threshold criterion
Definition: vtkThreshold.h:55
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int Upper(double s)
Definition: vtkThreshold.h:208
void SetAttributeModeToUsePointData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:98
int SelectedComponent
Definition: vtkThreshold.h:201
void SetPointsDataTypeToFloat()
Set the data type of the output points (See the data types defined in vtkType.h).
Definition: vtkThreshold.h:171
a simple class to control print indentation
Definition: vtkIndent.h:33
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:48
list of point or cell ids
Definition: vtkIdList.h:30
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:49
int Lower(double s)
Definition: vtkThreshold.h:207
#define VTK_ATTRIBUTE_MODE_DEFAULT
Definition: vtkThreshold.h:43
Superclass for algorithms that produce only unstructured grid as output.
void SetComponentModeToUseSelected()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:118
vtkTypeBool UseContinuousCellRange
Definition: vtkThreshold.h:203
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:120
int Between(double s)
Definition: vtkThreshold.h:209
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:50
Store zero or more vtkInformation instances.
void SetAttributeModeToDefault()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:96
int OutputPointsPrecision
Definition: vtkThreshold.h:202
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:122