VTK
dox/Rendering/Volume/vtkVolumeRayCastSpaceLeapingImageFilter.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkFixedPointVolumeRayCastMapper.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 =========================================================================*/
00031 #ifndef __vtkVolumeRayCastSpaceLeapingImageFilter_h
00032 #define __vtkVolumeRayCastSpaceLeapingImageFilter_h
00033 
00034 #include "vtkRenderingVolumeModule.h" // For export macro
00035 #include "vtkThreadedImageAlgorithm.h"
00036 
00037 class vtkDataArray;
00038 
00039 class VTKRENDERINGVOLUME_EXPORT vtkVolumeRayCastSpaceLeapingImageFilter : public vtkThreadedImageAlgorithm
00040 {
00041 public:
00042   vtkTypeMacro(vtkVolumeRayCastSpaceLeapingImageFilter,vtkThreadedImageAlgorithm);
00043   void PrintSelf(ostream& os, vtkIndent indent);
00044 
00045   static vtkVolumeRayCastSpaceLeapingImageFilter *New();
00046 
00048 
00049   virtual void SetCurrentScalars( vtkDataArray * );
00050   vtkGetObjectMacro( CurrentScalars, vtkDataArray );
00052 
00054 
00055   vtkSetMacro( IndependentComponents, int );
00056   vtkGetMacro( IndependentComponents, int );
00058 
00060 
00061   vtkSetMacro( ComputeGradientOpacity, int );
00062   vtkGetMacro( ComputeGradientOpacity, int );
00063   vtkBooleanMacro( ComputeGradientOpacity, int );
00065 
00067 
00068   vtkSetMacro( ComputeMinMax, int );
00069   vtkGetMacro( ComputeMinMax, int );
00070   vtkBooleanMacro( ComputeMinMax, int );
00072 
00074 
00076   vtkSetMacro( UpdateGradientOpacityFlags, int );
00077   vtkGetMacro( UpdateGradientOpacityFlags, int );
00078   vtkBooleanMacro( UpdateGradientOpacityFlags, int );
00080 
00082 
00084   unsigned long GetLastMinMaxBuildTime()
00085     { return LastMinMaxBuildTime.GetMTime(); }
00087 
00089 
00091   unsigned long GetLastMinMaxFlagTime()
00092     { return LastMinMaxFlagTime.GetMTime(); }
00094 
00096 
00102   vtkSetVector4Macro( TableShift, float );
00103   vtkGetVector4Macro( TableShift, float );
00104   vtkSetVector4Macro( TableScale, float );
00105   vtkGetVector4Macro( TableScale, float );
00106   vtkSetVector4Macro( TableSize,  int   );
00107   vtkGetVector4Macro( TableSize,  int   );
00109 
00112   int GetNumberOfIndependentComponents();
00113 
00120   unsigned short * GetMinMaxVolume( int dims[4] );
00121 
00124   virtual void SetCache(vtkImageData * imageCache);
00125 
00127 
00130   static void ComputeInputExtentsForOutput( int inExt[6],
00131       int inDim[3], int outExt[6], vtkImageData *inData );
00133 
00135 
00137   unsigned short * GetMinNonZeroScalarIndex();
00138   unsigned char  * GetMinNonZeroGradientMagnitudeIndex();
00140 
00141   //BTX
00143 
00146   void SetGradientMagnitude( unsigned char ** gradientMagnitude );
00147   unsigned char **GetGradientMagnitude();
00149 
00151 
00153   void SetScalarOpacityTable( int c, unsigned short * t);
00154   void SetGradientOpacityTable( int c, unsigned short * t );
00155   //ETX
00157 
00159 
00161   vtkIdType ComputeOffset(const int ext[6], const int wholeExt[6],
00162       int nComponents);
00164 
00165   //BTX
00166   // This method helps debug. It writes out a specific component of the
00167   // computed min-max-volume structure
00168   //static void WriteMinMaxVolume( int component, unsigned short *minMaxVolume,
00169   //                           int minMaxVolumeSize[4], const char *filename );
00170   //ETX
00171 
00172 protected:
00173   vtkVolumeRayCastSpaceLeapingImageFilter();
00174   ~vtkVolumeRayCastSpaceLeapingImageFilter();
00175 
00176   int               IndependentComponents;
00177   vtkTimeStamp      LastMinMaxBuildTime;
00178   vtkTimeStamp      LastMinMaxFlagTime;
00179   vtkDataArray   *  CurrentScalars;
00180   float             TableShift[4];
00181   float             TableScale[4];
00182   int               TableSize[4];
00183   int               ComputeGradientOpacity;
00184   int               ComputeMinMax;
00185   int               UpdateGradientOpacityFlags;
00186   unsigned short *  MinNonZeroScalarIndex;
00187   unsigned char  *  MinNonZeroGradientMagnitudeIndex;
00188   unsigned char  ** GradientMagnitude;
00189   unsigned short  * ScalarOpacityTable[4];
00190   unsigned short  * GradientOpacityTable[4];
00191   vtkImageData    * Cache;
00192 
00193 
00194   void InternalRequestUpdateExtent(int *, int*);
00195 
00197 
00198   virtual int RequestUpdateExtent(vtkInformation *,
00199                                   vtkInformationVector **,
00200                                   vtkInformationVector *);
00201   void ThreadedRequestData(       vtkInformation *request,
00202                                   vtkInformationVector **inputVector,
00203                                   vtkInformationVector *outputVector,
00204                                   vtkImageData ***inData,
00205                                   vtkImageData **outData,
00206                                   int outExt[6], int id);
00207   virtual int RequestData(        vtkInformation* request,
00208                                   vtkInformationVector** inputVector,
00209                                   vtkInformationVector* outputVector);
00210   virtual int RequestInformation( vtkInformation *,
00211                                   vtkInformationVector**,
00212                                   vtkInformationVector *);
00214 
00218   void ComputeFirstNonZeroOpacityIndices();
00219 
00221 
00224   void FillScalarOpacityFlags(
00225       vtkImageData *minMaxVolume, int outExt[6] );
00227 
00229 
00232   void FillScalarAndGradientOpacityFlags(
00233       vtkImageData *minMaxVolume, int outExt[6] );
00235 
00237 
00240   virtual void AllocateOutputData(vtkImageData *out,
00241                                   vtkInformation* outInfo,
00242                                   int *uExtent);
00243   virtual vtkImageData *AllocateOutputData(vtkDataObject *out,
00244                                            vtkInformation *outInfo);
00246 
00247 private:
00248   vtkVolumeRayCastSpaceLeapingImageFilter(const vtkVolumeRayCastSpaceLeapingImageFilter&);  // Not implemented.
00249   void operator=(const vtkVolumeRayCastSpaceLeapingImageFilter&);  // Not implemented.
00250 };
00251 
00252 #endif