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) VTK_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,int);
150  vtkGetMacro(AllScalars,int);
151  vtkBooleanMacro(AllScalars,int);
153 
155 
163  vtkSetMacro(UseContinuousCellRange,int);
164  vtkGetMacro(UseContinuousCellRange,int);
165  vtkBooleanMacro(UseContinuousCellRange,int);
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  void SetOutputPointsPrecision(int precision);
189  int GetOutputPointsPrecision() const;
191 
192 protected:
193  vtkThreshold();
194  ~vtkThreshold() VTK_OVERRIDE;
195 
196  // Usual data generation method
197  int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
198 
199  int FillInputPortInformation(int port, vtkInformation *info) VTK_OVERRIDE;
200 
201 
202  int AllScalars;
203  double LowerThreshold;
204  double UpperThreshold;
205  int AttributeMode;
206  int ComponentMode;
207  int SelectedComponent;
208  int OutputPointsPrecision;
209  int UseContinuousCellRange;
210 
211  int (vtkThreshold::*ThresholdFunction)(double s);
212 
213  int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );};
214  int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );};
215  int Between(double s) {return ( s >= this->LowerThreshold ?
216  ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );};
217 
218  int EvaluateComponents( vtkDataArray *scalars, vtkIdType id );
219  int EvaluateCell( vtkDataArray *scalars, vtkIdList* cellPts, int numCellPts );
220  int EvaluateCell( vtkDataArray *scalars, int c, vtkIdList* cellPts, int numCellPts );
221 private:
222  vtkThreshold(const vtkThreshold&) VTK_DELETE_FUNCTION;
223  void operator=(const vtkThreshold&) VTK_DELETE_FUNCTION;
224 };
225 
226 #endif
Store vtkAlgorithm input/output information.
#define VTK_INT_MAX
Definition: vtkType.h:153
#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:287
void SetAttributeModeToUseCellData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:106
#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:214
void SetAttributeModeToUsePointData()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:104
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
#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
vtkSetMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
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:215
#define VTK_COMPONENT_MODE_USE_ANY
Definition: vtkThreshold.h:56
Store zero or more vtkInformation instances.
vtkBooleanMacro(IgnoreDriverBugs, bool)
When set known driver bugs are ignored during driver feature detection.
void SetAttributeModeToDefault()
Control how the filter works with scalar point data and cell attribute data.
Definition: vtkThreshold.h:102
void SetComponentModeToUseAny()
Control how the decision of in / out is made with multi-component data.
Definition: vtkThreshold.h:128