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
VTK_INT_MAX
#define VTK_INT_MAX
Definition: vtkType.h:159
vtkThreshold::SetAttributeModeToDefault
void SetAttributeModeToDefault()
Definition: vtkThreshold.h:96
VTK_ATTRIBUTE_MODE_USE_POINT_DATA
#define VTK_ATTRIBUTE_MODE_USE_POINT_DATA
Definition: vtkThreshold.h:44
vtkX3D::type
Definition: vtkX3D.h:516
vtkIdType
int vtkIdType
Definition: vtkType.h:347
vtkThreshold::SetComponentModeToUseAny
void SetComponentModeToUseAny()
Definition: vtkThreshold.h:122
vtkInformationVector
Store zero or more vtkInformation instances.
Definition: vtkInformationVector.h:35
VTK_COMPONENT_MODE_USE_ALL
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:49
vtkThreshold::AllScalars
vtkTypeBool AllScalars
Definition: vtkThreshold.h:196
vtkThreshold::LowerThreshold
double LowerThreshold
Definition: vtkThreshold.h:197
vtkThreshold::SetAttributeModeToUsePointData
void SetAttributeModeToUsePointData()
Definition: vtkThreshold.h:98
vtkThreshold::SelectedComponent
int SelectedComponent
Definition: vtkThreshold.h:201
vtkThreshold::SetPointsDataTypeToFloat
void SetPointsDataTypeToFloat()
Definition: vtkThreshold.h:171
vtkDataArray
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:48
vtkThreshold::SetPointsDataTypeToDouble
void SetPointsDataTypeToDouble()
Set the data type of the output points (See the data types defined in vtkType.h).
Definition: vtkThreshold.h:170
vtkX3D::port
Definition: vtkX3D.h:447
vtkThreshold::SetComponentModeToUseSelected
void SetComponentModeToUseSelected()
Definition: vtkThreshold.h:118
vtkThreshold::UseContinuousCellRange
vtkTypeBool UseContinuousCellRange
Definition: vtkThreshold.h:203
vtkUnstructuredGridAlgorithm::RequestData
virtual int RequestData(vtkInformation *request, vtkInformationVector **inputVector, vtkInformationVector *outputVector)
This is called by the superclass.
vtkThreshold::SetComponentModeToUseAll
void SetComponentModeToUseAll()
Definition: vtkThreshold.h:120
vtkIndent
a simple class to control print indentation
Definition: vtkIndent.h:33
vtkThreshold
extracts cells where scalar value in cell satisfies threshold criterion
Definition: vtkThreshold.h:55
vtkThreshold::SetAttributeModeToUseCellData
void SetAttributeModeToUseCellData()
Definition: vtkThreshold.h:100
VTK_FLOAT
#define VTK_FLOAT
Definition: vtkType.h:58
VTK_DOUBLE
#define VTK_DOUBLE
Definition: vtkType.h:59
vtkIdList
list of point or cell ids
Definition: vtkIdList.h:30
vtkUnstructuredGridAlgorithm::FillInputPortInformation
int FillInputPortInformation(int port, vtkInformation *info) override
Fill the input port information objects for this algorithm.
vtkThreshold::AttributeMode
int AttributeMode
Definition: vtkThreshold.h:199
vtkThreshold::Upper
int Upper(double s)
Definition: vtkThreshold.h:208
VTK_ATTRIBUTE_MODE_DEFAULT
#define VTK_ATTRIBUTE_MODE_DEFAULT
Definition: vtkThreshold.h:43
vtkInformation
Store vtkAlgorithm input/output information.
Definition: vtkInformation.h:80
vtkX3D::info
Definition: vtkX3D.h:376
vtkThreshold::Lower
int Lower(double s)
Definition: vtkThreshold.h:207
VTK_ATTRIBUTE_MODE_USE_CELL_DATA
#define VTK_ATTRIBUTE_MODE_USE_CELL_DATA
Definition: vtkThreshold.h:45
VTK_COMPONENT_MODE_USE_SELECTED
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:48
vtkUnstructuredGridAlgorithm::New
static vtkUnstructuredGridAlgorithm * New()
vtkThreshold::OutputPointsPrecision
int OutputPointsPrecision
Definition: vtkThreshold.h:202
vtkUnstructuredGridAlgorithm::PrintSelf
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
vtkUnstructuredGridAlgorithm.h
vtkUnstructuredGridAlgorithm
Superclass for algorithms that produce only unstructured grid as output.
Definition: vtkUnstructuredGridAlgorithm.h:40
vtkThreshold::ComponentMode
int ComponentMode
Definition: vtkThreshold.h:200
vtkThreshold::UpperThreshold
double UpperThreshold
Definition: vtkThreshold.h:198
vtkThreshold::Between
int Between(double s)
Definition: vtkThreshold.h:209
VTK_COMPONENT_MODE_USE_ANY
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:50
vtkTypeBool
int vtkTypeBool
Definition: vtkABI.h:69
int
int
Definition: vtkVectorOperators.h:164