00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00042 #ifndef __vtkThreshold_h
00043 #define __vtkThreshold_h
00044 
00045 #include "vtkUnstructuredGridAlgorithm.h"
00046 
00047 #define VTK_ATTRIBUTE_MODE_DEFAULT         0
00048 #define VTK_ATTRIBUTE_MODE_USE_POINT_DATA  1
00049 #define VTK_ATTRIBUTE_MODE_USE_CELL_DATA   2
00050 
00051 
00052 #define VTK_COMPONENT_MODE_USE_SELECTED    0
00053 #define VTK_COMPONENT_MODE_USE_ALL         1
00054 #define VTK_COMPONENT_MODE_USE_ANY         2
00055 
00056 class vtkDataArray;
00057 
00058 class VTK_GRAPHICS_EXPORT vtkThreshold : public vtkUnstructuredGridAlgorithm
00059 {
00060 public:
00061   static vtkThreshold *New();
00062   vtkTypeMacro(vtkThreshold,vtkUnstructuredGridAlgorithm);
00063   void PrintSelf(ostream& os, vtkIndent indent);
00064 
00067   void ThresholdByLower(double lower);
00068 
00071   void ThresholdByUpper(double upper);
00072 
00075   void ThresholdBetween(double lower, double upper);
00076 
00078 
00079   vtkGetMacro(UpperThreshold,double);
00080   vtkGetMacro(LowerThreshold,double);
00082 
00084 
00090   vtkSetMacro(AttributeMode,int);
00091   vtkGetMacro(AttributeMode,int);
00092   void SetAttributeModeToDefault() 
00093     {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_DEFAULT);};
00094   void SetAttributeModeToUsePointData() 
00095     {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_POINT_DATA);};
00096   void SetAttributeModeToUseCellData() 
00097     {this->SetAttributeMode(VTK_ATTRIBUTE_MODE_USE_CELL_DATA);};
00098   const char *GetAttributeModeAsString();
00100 
00102 
00108   vtkSetClampMacro(ComponentMode,int,
00109                    VTK_COMPONENT_MODE_USE_SELECTED,
00110                    VTK_COMPONENT_MODE_USE_ANY);
00111   vtkGetMacro(ComponentMode,int);
00112   void SetComponentModeToUseSelected() 
00113     {this->SetComponentMode(VTK_COMPONENT_MODE_USE_SELECTED);};
00114   void SetComponentModeToUseAll() 
00115     {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ALL);};
00116   void SetComponentModeToUseAny() 
00117     {this->SetComponentMode(VTK_COMPONENT_MODE_USE_ANY);};
00118   const char *GetComponentModeAsString();
00120   
00122 
00124   vtkSetClampMacro(SelectedComponent,int,0,VTK_INT_MAX);
00125   vtkGetMacro(SelectedComponent,int);
00127   
00129 
00133   vtkSetMacro(AllScalars,int);
00134   vtkGetMacro(AllScalars,int);
00135   vtkBooleanMacro(AllScalars,int);
00137 
00139 
00141   void SetPointsDataTypeToDouble() { this->SetPointsDataType( VTK_DOUBLE ); }
00142   void SetPointsDataTypeToFloat()  { this->SetPointsDataType( VTK_FLOAT  ); }
00143   vtkSetMacro( PointsDataType, int );
00144   vtkGetMacro( PointsDataType, int );
00146   
00147 protected:
00148   vtkThreshold();
00149   ~vtkThreshold();
00150 
00151   
00152   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00153 
00154   virtual int FillInputPortInformation(int port, vtkInformation *info);
00155 
00156   virtual int ProcessRequest(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00157 
00158   int    AllScalars;
00159   double LowerThreshold;
00160   double UpperThreshold;
00161   int    AttributeMode;
00162   int    ComponentMode;
00163   int    SelectedComponent;
00164   int    PointsDataType;
00165   
00166   
00167   int (vtkThreshold::*ThresholdFunction)(double s);
00168   
00169 
00170   int Lower(double s) {return ( s <= this->LowerThreshold ? 1 : 0 );};
00171   int Upper(double s) {return ( s >= this->UpperThreshold ? 1 : 0 );};
00172   int Between(double s) {return ( s >= this->LowerThreshold ? 
00173                                ( s <= this->UpperThreshold ? 1 : 0 ) : 0 );};
00174 
00175   int EvaluateComponents( vtkDataArray *scalars, vtkIdType id );
00176   
00177 private:
00178   vtkThreshold(const vtkThreshold&);  
00179   void operator=(const vtkThreshold&);  
00180 };
00181 
00182 #endif