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 
46 
47 #define VTK_ATTRIBUTE_MODE_DEFAULT 0
48 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1
49 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2
50 
51 // order / values are important because of the SetClampMacro
52 #define VTK_COMPONENT_MODE_USE_SELECTED 0
53 #define VTK_COMPONENT_MODE_USE_ALL 1
54 #define VTK_COMPONENT_MODE_USE_ANY 2
55 
56 class vtkDataArray;
57 
59 {
60 public:
61  static vtkThreshold *New();
63  void PrintSelf(ostream& os, vtkIndent indent);
64 
67  void ThresholdByLower(double lower);
68 
71  void ThresholdByUpper(double upper);
72 
75  void ThresholdBetween(double lower, double upper);
76 
78 
79  vtkGetMacro(UpperThreshold,double);
80  vtkGetMacro(LowerThreshold,double);
82 
84 
90  vtkSetMacro(AttributeMode,int);
91  vtkGetMacro(AttributeMode,int);
93  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT);};
95  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA);};
97  {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_CELL_DATA);};
98  const char *GetAttributeModeAsString();
100 
102 
108  vtkSetClampMacro(ComponentMode,int,
111  vtkGetMacro(ComponentMode,int);
113  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED);};
115  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL);};
117  {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY);};
118  const char *GetComponentModeAsString();
120 
122 
124  vtkSetClampMacro(SelectedComponent,int,0,VTK_INT_MAX);
125  vtkGetMacro(SelectedComponent,int);
127 
129 
133  vtkSetMacro(AllScalars,int);
134  vtkGetMacro(AllScalars,int);
135  vtkBooleanMacro(AllScalars,int);
137 
139 
141  void SetPointsDataTypeToDouble() { this->SetPointsDataType( VTK_DOUBLE ); }
142  void SetPointsDataTypeToFloat() { this->SetPointsDataType( VTK_FLOAT ); }
143  vtkSetMacro( PointsDataType, int );
144  vtkGetMacro( PointsDataType, int );
146 
148 
149 protected:
150  vtkThreshold();
151  ~vtkThreshold();
152 
153  // Usual data generation method
155 
157 
158 
166 
167  //BTX
168  int (vtkThreshold::*ThresholdFunction)(double s);
169  //ETX
170 
171  int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );};
172  int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );};
173  int Between(double s) {return ( s >= this->LowerThreshold ?
174  ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );};
175 
176  int EvaluateComponents( vtkDataArray *scalars, vtkIdType id );
177 
178 private:
179  vtkThreshold(const vtkThreshold&); // Not implemented.
180  void operator=(const vtkThreshold&); // Not implemented.
181 };
182 
183 #endif