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 =========================================================================*/
42 #ifndef __vtkThreshold_h
43 #define __vtkThreshold_h
44 
45 #include "vtkFiltersCoreModule.h" // For export macro
47 
48 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
49 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
50 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
51 
52 // order / values are important because of the SetClampMacro
53 #define VTK_COMPONENT_MODE_USE_SELECTED 0
54 #define VTK_COMPONENT_MODE_USE_ALL 1
55 #define VTK_COMPONENT_MODE_USE_ANY 2
56 
57 class vtkDataArray;
58 
59 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
60 {
61 public:
62  static vtkThreshold *New();
64  void PrintSelf(ostream& os, vtkIndent indent);
65 
68  void ThresholdByLower(double lower);
69 
72  void ThresholdByUpper(double upper);
73 
76  void ThresholdBetween(double lower, double upper);
77 
79 
80  vtkGetMacro(UpperThreshold,double);
81  vtkGetMacro(LowerThreshold,double);
83 
85 
91  vtkSetMacro(AttributeMode,int);
92  vtkGetMacro(AttributeMode,int);
93  void SetAttributeModeToDefault()
94  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT);};
95  void SetAttributeModeToUsePointData()
96  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA);};
97  void SetAttributeModeToUseCellData()
98  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_CELL_DATA);};
99  const char *GetAttributeModeAsString();
101 
103 
109  vtkSetClampMacro(ComponentMode,int,
112  vtkGetMacro(ComponentMode,int);
113  void SetComponentModeToUseSelected()
114  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED);};
115  void SetComponentModeToUseAll()
116  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL);};
117  void SetComponentModeToUseAny()
118  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY);};
119  const char *GetComponentModeAsString();
121 
123 
125  vtkSetClampMacro(SelectedComponent,int,0,VTK_INT_MAX);
126  vtkGetMacro(SelectedComponent,int);
128 
130 
134  vtkSetMacro(AllScalars,int);
135  vtkGetMacro(AllScalars,int);
136  vtkBooleanMacro(AllScalars,int);
138 
140 
144  void SetPointsDataTypeToDouble() { this->SetPointsDataType( VTK_DOUBLE ); }
145  void SetPointsDataTypeToFloat() { this->SetPointsDataType( VTK_FLOAT ); }
146  void SetPointsDataType(int type);
147  int GetPointsDataType();
149 
151 
154  void SetOuputPointsPrecision(int precision);
155  int GetOutputPointsPrecision() const;
157 
159 
160 protected:
161  vtkThreshold();
162  ~vtkThreshold();
163 
164  // Usual data generation method
166 
168 
169 
177 
178  //BTX
179  int (vtkThreshold::*ThresholdFunction)(double s);
180  //ETX
181 
182  int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );};
183  int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );};
184  int Between(double s) {return ( s >= this->LowerThreshold ?
185  ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );};
186 
187  int EvaluateComponents( vtkDataArray *scalars, vtkIdType id );
188 
189 private:
190  vtkThreshold(const vtkThreshold&); // Not implemented.
191  void operator=(const vtkThreshold&); // Not implemented.
192 };
193 
194 #endif