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 =========================================================================*/
43 #ifndef vtkThreshold_h
44 #define vtkThreshold_h
45 
46 #include "vtkFiltersCoreModule.h" // For export macro
48 
49 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
50 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
51 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
52 
53 // order / values are important because of the SetClampMacro
54 #define VTK_COMPONENT_MODE_USE_SELECTED 0
55 #define VTK_COMPONENT_MODE_USE_ALL 1
56 #define VTK_COMPONENT_MODE_USE_ANY 2
57 
58 class vtkDataArray;
59 class vtkIdList;
60 
61 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
62 {
63 public:
64  static vtkThreshold *New();
66  void PrintSelf(ostream& os, vtkIndent indent) override;
67 
71  void ThresholdByLower(double lower);
72 
76  void ThresholdByUpper(double upper);
77 
82  void ThresholdBetween(double lower, double upper);
83 
85 
88  vtkGetMacro(UpperThreshold,double);
89  vtkGetMacro(LowerThreshold,double);
91 
93 
100  vtkSetMacro(AttributeMode,int);
101  vtkGetMacro(AttributeMode,int);
103  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT);};
105  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA);};
107  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_CELL_DATA);};
108  const char *GetAttributeModeAsString();
110 
112 
120  vtkSetClampMacro(ComponentMode,int,
123  vtkGetMacro(ComponentMode,int);
125  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED);};
127  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL);};
129  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY);};
130  const char *GetComponentModeAsString();
132 
134 
138  vtkSetClampMacro(SelectedComponent,int,0,VTK_INT_MAX);
139  vtkGetMacro(SelectedComponent,int);
141 
143 
149  vtkSetMacro(AllScalars,vtkTypeBool);
150  vtkGetMacro(AllScalars,vtkTypeBool);
151  vtkBooleanMacro(AllScalars,vtkTypeBool);
153 
155 
163  vtkSetMacro(UseContinuousCellRange,vtkTypeBool);
164  vtkGetMacro(UseContinuousCellRange,vtkTypeBool);
165  vtkBooleanMacro(UseContinuousCellRange,vtkTypeBool);
167 
169 
176  void SetPointsDataTypeToDouble() { this->SetPointsDataType( VTK_DOUBLE ); }
177  void SetPointsDataTypeToFloat() { this->SetPointsDataType( VTK_FLOAT ); }
178  void SetPointsDataType(int type);
179  int GetPointsDataType();
181 
183 
188  vtkSetMacro(Invert, bool);
189  vtkGetMacro(Invert, bool);
190  vtkBooleanMacro(Invert, bool);
192 
194 
199  void SetOutputPointsPrecision(int precision);
200  int GetOutputPointsPrecision() const;
202 
203 protected:
204  vtkThreshold();
205  ~vtkThreshold() override;
206 
207  // Usual data generation method
209 
210  int FillInputPortInformation(int port, vtkInformation *info) override;
211 
212 
221  bool Invert;
222 
223  int (vtkThreshold::*ThresholdFunction)(double s);
224 
225  int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );};
226  int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );};
227  int Between(double s) {return ( s >= this->LowerThreshold ?
228  ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );};
229 
230  int EvaluateComponents( vtkDataArray *scalars, vtkIdType id );
231  int EvaluateCell( vtkDataArray *scalars, vtkIdList* cellPts, int numCellPts );
232  int EvaluateCell( vtkDataArray *scalars, int c, vtkIdList* cellPts, int numCellPts );
233 private:
234  vtkThreshold(const vtkThreshold&) = delete;
235  void operator=(const vtkThreshold&) = delete;
236 };
237 
238 #endif
double UpperThreshold
Definition: vtkThreshold.h:215
double LowerThreshold
Definition: vtkThreshold.h:214
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:159
#define VTK_ATTRIBUTE_MODE_USE_CELL_DATA
Definition: vtkThreshold.h:51
#define VTK_ATTRIBUTE_MODE_USE_POINT_DATA
Definition: vtkThreshold.h:50
void SetPointsDataTypeToDouble()
Set the data type of the output points (See the data types defined in vtkType.h). ...
Definition: vtkThreshold.h:176
static vtkUnstructuredGridAlgorithm * New()
int vtkIdType
Definition: vtkType.h:347
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:106
vtkTypeBool AllScalars
Definition: vtkThreshold.h:213
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:61
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:226
void SetAttributeModeToUsePointData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:104
int SelectedComponent
Definition: vtkThreshold.h:218
void SetPointsDataTypeToFloat()
Set the data type of the output points (See the data types defined in vtkType.h). ...
Definition: vtkThreshold.h:177
a simple class to control print indentation
Definition: vtkIndent.h:39
#define VTK_COMPONENT_MODE_USE_SELECTED
Definition: vtkThreshold.h:54
list of point or cell ids
Definition: vtkIdList.h:36
abstract superclass for arrays of numeric data
Definition: vtkDataArray.h:54
#define VTK_COMPONENT_MODE_USE_ALL
Definition: vtkThreshold.h:55
int Lower(double s)
Definition: vtkThreshold.h:225
#define VTK_ATTRIBUTE_MODE_DEFAULT
Definition: vtkThreshold.h:49
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:124
vtkTypeBool UseContinuousCellRange
Definition: vtkThreshold.h:220
void SetComponentModeToUseAll()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:126
int Between(double s)
Definition: vtkThreshold.h:227
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:56
Store zero or more vtkInformation instances.
void SetAttributeModeToDefault()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:102
int OutputPointsPrecision
Definition: vtkThreshold.h:219
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:128