VTK
|
00001 /*========================================================================= 00002 00003 Program: Visualization Toolkit 00004 Module: vtkThreshold.h 00005 00006 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 00007 All rights reserved. 00008 See Copyright.txt or http://www.kitware.com/Copyright.htm for details. 00009 00010 This software is distributed WITHOUT ANY WARRANTY; without even 00011 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00012 PURPOSE. See the above copyright notice for more information. 00013 00014 =========================================================================*/ 00042 #ifndef __vtkThreshold_h 00043 #define __vtkThreshold_h 00044 00045 #include "vtkFiltersCoreModule.h" // For export macro 00046 #include "vtkUnstructuredGridAlgorithm.h" 00047 00048 #define VTK_ATTRIBUTE_MODE_DEFAULT 0 00049 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA 1 00050 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA 2 00051 00052 // order / values are important because of the SetClampMacro 00053 #define VTK_COMPONENT_MODE_USE_SELECTED 0 00054 #define VTK_COMPONENT_MODE_USE_ALL 1 00055 #define VTK_COMPONENT_MODE_USE_ANY 2 00056 00057 class vtkDataArray; 00058 class vtkIdList; 00059 00060 class VTKFILTERSCORE_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm 00061 { 00062 public: 00063 static vtkThreshold *New(); 00064 vtkTypeMacro(vtkThreshold,vtkUnstructuredGridAlgorithm); 00065 void PrintSelf(ostream& os, vtkIndent indent); 00066 00069 void ThresholdByLower(double lower); 00070 00073 void ThresholdByUpper(double upper); 00074 00077 void ThresholdBetween(double lower, double upper); 00078 00080 00081 vtkGetMacro(UpperThreshold,double); 00082 vtkGetMacro(LowerThreshold,double); 00084 00086 00092 vtkSetMacro(AttributeMode,int); 00093 vtkGetMacro(AttributeMode,int); 00094 void SetAttributeModeToDefault() 00095 {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT);}; 00096 void SetAttributeModeToUsePointData() 00097 {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA);}; 00098 void SetAttributeModeToUseCellData() 00099 {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_CELL_DATA);}; 00100 const char *GetAttributeModeAsString(); 00102 00104 00110 vtkSetClampMacro(ComponentMode,int, 00111 VTK_COMPONENT_MODE_USE_SELECTED, 00112 VTK_COMPONENT_MODE_USE_ANY); 00113 vtkGetMacro(ComponentMode,int); 00114 void SetComponentModeToUseSelected() 00115 {this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED);}; 00116 void SetComponentModeToUseAll() 00117 {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL);}; 00118 void SetComponentModeToUseAny() 00119 {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY);}; 00120 const char *GetComponentModeAsString(); 00122 00124 00126 vtkSetClampMacro(SelectedComponent,int,0,VTK_INT_MAX); 00127 vtkGetMacro(SelectedComponent,int); 00129 00131 00135 vtkSetMacro(AllScalars,int); 00136 vtkGetMacro(AllScalars,int); 00137 vtkBooleanMacro(AllScalars,int); 00139 00141 00147 vtkSetMacro(UseContinuousCellRange,int); 00148 vtkGetMacro(UseContinuousCellRange,int); 00149 vtkBooleanMacro(UseContinuousCellRange,int); 00151 00153 00157 void SetPointsDataTypeToDouble() { this->SetPointsDataType( VTK_DOUBLE ); } 00158 void SetPointsDataTypeToFloat() { this->SetPointsDataType( VTK_FLOAT ); } 00159 void SetPointsDataType(int type); 00160 int GetPointsDataType(); 00162 00164 00167 void SetOutputPointsPrecision(int precision); 00168 int GetOutputPointsPrecision() const; 00170 00171 virtual int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00172 00173 protected: 00174 vtkThreshold(); 00175 ~vtkThreshold(); 00176 00177 // Usual data generation method 00178 virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); 00179 00180 virtual int FillInputPortInformation(int port, vtkInformation *info); 00181 00182 00183 int AllScalars; 00184 double LowerThreshold; 00185 double UpperThreshold; 00186 int AttributeMode; 00187 int ComponentMode; 00188 int SelectedComponent; 00189 int OutputPointsPrecision; 00190 int UseContinuousCellRange; 00191 00192 //BTX 00193 int (vtkThreshold::*ThresholdFunction)(double s); 00194 //ETX 00195 00196 int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );}; 00197 int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );}; 00198 int Between(double s) {return ( s >= this->LowerThreshold ? 00199 ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );}; 00200 00201 int EvaluateComponents( vtkDataArray *scalars, vtkIdType id ); 00202 int EvaluateCell( vtkDataArray *scalars, vtkIdList* cellPts, int numCellPts ); 00203 int EvaluateCell( vtkDataArray *scalars, int c, vtkIdList* cellPts, int numCellPts ); 00204 private: 00205 vtkThreshold(const vtkThreshold&); // Not implemented. 00206 void operator=(const vtkThreshold&); // Not implemented. 00207 }; 00208 00209 #endif