VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/dox/Filters/Core/vtkThreshold.h
Go to the documentation of this file.
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 protected:
00172   vtkThreshold();
00173   ~vtkThreshold();
00174 
00175   // Usual data generation method
00176   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00177 
00178   virtual int FillInputPortInformation(int port, vtkInformation *info);
00179 
00180 
00181   int    AllScalars;
00182   double LowerThreshold;
00183   double UpperThreshold;
00184   int    AttributeMode;
00185   int    ComponentMode;
00186   int    SelectedComponent;
00187   int OutputPointsPrecision;
00188   int UseContinuousCellRange;
00189 
00190   //BTX
00191   int (vtkThreshold::*ThresholdFunction)(double s);
00192   //ETX
00193 
00194   int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );};
00195   int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );};
00196   int Between(double s) {return ( s >= this->LowerThreshold ?
00197                                ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );};
00198 
00199   int EvaluateComponents( vtkDataArray *scalars, vtkIdType id );
00200   int EvaluateCell( vtkDataArray *scalars, vtkIdList* cellPts, int numCellPts );
00201   int EvaluateCell( vtkDataArray *scalars, int c, vtkIdList* cellPts, int numCellPts );
00202 private:
00203   vtkThreshold(const vtkThreshold&);  // Not implemented.
00204   void operator=(const vtkThreshold&);  // Not implemented.
00205 };
00206 
00207 #endif