Main Page | Directories | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

vtkEncodedGradientEstimator.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkEncodedGradientEstimator.h,v $
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 =========================================================================*/
00015 
00044 #ifndef __vtkEncodedGradientEstimator_h
00045 #define __vtkEncodedGradientEstimator_h
00046 
00047 #include "vtkObject.h"
00048 
00049 class vtkImageData;
00050 class vtkDirectionEncoder;
00051 class vtkMultiThreader;
00052 
00053 class VTK_RENDERING_EXPORT vtkEncodedGradientEstimator : public vtkObject
00054 {
00055 public:
00056   vtkTypeRevisionMacro(vtkEncodedGradientEstimator,vtkObject);
00057   void PrintSelf( ostream& os, vtkIndent indent );
00058 
00060 
00061   virtual void SetInput(vtkImageData*);
00062   vtkGetObjectMacro( Input, vtkImageData );
00064 
00066 
00067   vtkSetMacro( GradientMagnitudeScale, float );
00068   vtkGetMacro( GradientMagnitudeScale, float );
00069   vtkSetMacro( GradientMagnitudeBias, float );
00070   vtkGetMacro( GradientMagnitudeBias, float );
00072 
00074 
00076   vtkSetClampMacro( BoundsClip, int, 0, 1 );
00077   vtkGetMacro( BoundsClip, int );
00078   vtkBooleanMacro( BoundsClip, int );
00080   
00082 
00085   vtkSetVector6Macro( Bounds, int );
00086   vtkGetVectorMacro(  Bounds, int, 6 );
00088 
00090   void  Update( void );
00091 
00093   unsigned short  *GetEncodedNormals( void ); 
00094 
00096 
00097   int   GetEncodedNormalIndex( int xyz_index );
00098   int   GetEncodedNormalIndex( int x_index, int y_index, int z_index );
00100 
00102   unsigned char *GetGradientMagnitudes(void);
00103 
00105 
00107   vtkSetClampMacro( NumberOfThreads, int, 1, VTK_MAX_THREADS );
00108   vtkGetMacro( NumberOfThreads, int );
00110 
00112 
00114   void SetDirectionEncoder( vtkDirectionEncoder *direnc );
00115   vtkGetObjectMacro( DirectionEncoder, vtkDirectionEncoder );
00117 
00119 
00123   vtkSetMacro( ComputeGradientMagnitudes, int );
00124   vtkGetMacro( ComputeGradientMagnitudes, int );
00125   vtkBooleanMacro( ComputeGradientMagnitudes, int );
00127 
00129 
00133   vtkSetMacro( CylinderClip, int );
00134   vtkGetMacro( CylinderClip, int );
00135   vtkBooleanMacro( CylinderClip, int );
00137 
00139 
00140   vtkGetMacro( LastUpdateTimeInSeconds, float );
00141   vtkGetMacro( LastUpdateTimeInCPUSeconds, float );
00143 
00144   vtkGetMacro( UseCylinderClip, int );
00145   int *GetCircleLimits() { return this->CircleLimits; };
00146 
00148 
00154   void SetZeroNormalThreshold( float v );
00155   vtkGetMacro( ZeroNormalThreshold, float );
00157 
00159 
00161   vtkSetClampMacro( ZeroPad, int, 0, 1 );
00162   vtkGetMacro( ZeroPad, int );
00163   vtkBooleanMacro( ZeroPad, int );
00165   
00166   
00167   // These variables should be protected but are being
00168   // made public to be accessible to the templated function.
00169   // We used to have the templated function as a friend, but
00170   // this does not work with all compilers
00171 
00172   // The input scalar data on which the normals are computed
00173   vtkImageData         *Input;
00174 
00175   // The encoded normals (2 bytes) and the size of the encoded normals
00176   unsigned short        *EncodedNormals;
00177   int                   EncodedNormalsSize[3];
00178 
00179   // The magnitude of the gradient array and the size of this array
00180   unsigned char         *GradientMagnitudes;
00181 
00182   // The time at which the normals were last built
00183   vtkTimeStamp          BuildTime;
00184 
00185 //BTX
00186   vtkGetVectorMacro( InputSize, int, 3 );
00187   vtkGetVectorMacro( InputAspect, float, 3 );
00188 //ETX
00189   
00190 protected:
00191   vtkEncodedGradientEstimator();
00192   ~vtkEncodedGradientEstimator();
00193 
00194   virtual void ReportReferences(vtkGarbageCollector*);
00195   virtual void RemoveReferences();
00196 
00197   // The number of threads to use when encoding normals
00198   int                        NumberOfThreads;
00199 
00200   vtkMultiThreader           *Threader;
00201 
00202   vtkDirectionEncoder        *DirectionEncoder;
00203 
00204   virtual void               UpdateNormals( void ) = 0;
00205 
00206   float                      GradientMagnitudeScale;
00207   float                      GradientMagnitudeBias;
00208 
00209   float                      LastUpdateTimeInSeconds;
00210   float                      LastUpdateTimeInCPUSeconds;
00211 
00212   float                      ZeroNormalThreshold;
00213 
00214   int                        CylinderClip;
00215   int                        *CircleLimits;
00216   int                        CircleLimitsSize;
00217   int                        UseCylinderClip;
00218   void                       ComputeCircleLimits( int size );
00219   
00220   int                        BoundsClip;
00221   int                        Bounds[6];
00222 
00223   int                        InputSize[3];
00224   float                      InputAspect[3];
00225 
00226   int                        ComputeGradientMagnitudes;
00227   
00228   int                        ZeroPad;
00229   
00230 private:
00231   vtkEncodedGradientEstimator(const vtkEncodedGradientEstimator&);  // Not implemented.
00232   void operator=(const vtkEncodedGradientEstimator&);  // Not implemented.
00233 }; 
00234 
00235 
00236 #endif
00237