VTK
dox/Imaging/Core/vtkImageReslice.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkImageReslice.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 =========================================================================*/
00057 #ifndef __vtkImageReslice_h
00058 #define __vtkImageReslice_h
00059 
00060 
00061 #include "vtkImagingCoreModule.h" // For export macro
00062 #include "vtkThreadedImageAlgorithm.h"
00063 
00064 // interpolation mode constants
00065 #define VTK_RESLICE_NEAREST VTK_NEAREST_INTERPOLATION
00066 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
00067 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
00068 
00069 class vtkImageData;
00070 class vtkAbstractTransform;
00071 class vtkMatrix4x4;
00072 class vtkImageStencilData;
00073 class vtkScalarsToColors;
00074 class vtkAbstractImageInterpolator;
00075 
00076 class VTKIMAGINGCORE_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
00077 {
00078 public:
00079   static vtkImageReslice *New();
00080   vtkTypeMacro(vtkImageReslice, vtkThreadedImageAlgorithm);
00081 
00082   virtual void PrintSelf(ostream& os, vtkIndent indent);
00083 
00085 
00097   virtual void SetResliceAxes(vtkMatrix4x4*);
00098   vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
00100 
00102 
00106   void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
00107                                       double y0, double y1, double y2,
00108                                       double z0, double z1, double z2);
00109   void SetResliceAxesDirectionCosines(const double x[3],
00110                                       const double y[3],
00111                                       const double z[3]) {
00112     this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
00113                                          y[0], y[1], y[2],
00114                                          z[0], z[1], z[2]); };
00115   void SetResliceAxesDirectionCosines(const double xyz[9]) {
00116     this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
00117                                          xyz[3], xyz[4], xyz[5],
00118                                          xyz[6], xyz[7], xyz[8]); };
00119   void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
00120   void GetResliceAxesDirectionCosines(double xyz[9]) {
00121     this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
00122   double *GetResliceAxesDirectionCosines() {
00123     this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
00124     return this->ResliceAxesDirectionCosines; };
00126 
00128 
00131   void SetResliceAxesOrigin(double x, double y, double z);
00132   void SetResliceAxesOrigin(const double xyz[3]) {
00133     this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
00134   void GetResliceAxesOrigin(double xyz[3]);
00135   double *GetResliceAxesOrigin() {
00136     this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
00137     return this->ResliceAxesOrigin; };
00139 
00141 
00148   virtual void SetResliceTransform(vtkAbstractTransform*);
00149   vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
00151 
00153 
00159   virtual void SetInformationInput(vtkImageData*);
00160   vtkGetObjectMacro(InformationInput, vtkImageData);
00162 
00164 
00168   vtkSetMacro(TransformInputSampling, int);
00169   vtkBooleanMacro(TransformInputSampling, int);
00170   vtkGetMacro(TransformInputSampling, int);
00172 
00174 
00177   vtkSetMacro(AutoCropOutput, int);
00178   vtkBooleanMacro(AutoCropOutput, int);
00179   vtkGetMacro(AutoCropOutput, int);
00181 
00183 
00184   vtkSetMacro(Wrap, int);
00185   vtkGetMacro(Wrap, int);
00186   vtkBooleanMacro(Wrap, int);
00188 
00190 
00192   vtkSetMacro(Mirror, int);
00193   vtkGetMacro(Mirror, int);
00194   vtkBooleanMacro(Mirror, int);
00196 
00198 
00205   vtkSetMacro(Border, int);
00206   vtkGetMacro(Border, int);
00207   vtkBooleanMacro(Border, int);
00209 
00211 
00212   vtkSetClampMacro(InterpolationMode, int,
00213                    VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
00214   vtkGetMacro(InterpolationMode, int);
00215   void SetInterpolationModeToNearestNeighbor() {
00216     this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
00217   void SetInterpolationModeToLinear() {
00218     this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
00219   void SetInterpolationModeToCubic() {
00220     this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
00221   virtual const char *GetInterpolationModeAsString();
00223 
00225 
00227   virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler);
00228   virtual vtkAbstractImageInterpolator *GetInterpolator();
00230 
00232 
00233   vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
00234   vtkGetMacro(SlabMode, int);
00235   void SetSlabModeToMin() {
00236     this->SetSlabMode(VTK_IMAGE_SLAB_MIN); };
00237   void SetSlabModeToMax() {
00238     this->SetSlabMode(VTK_IMAGE_SLAB_MAX); };
00239   void SetSlabModeToMean() {
00240     this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); };
00241   void SetSlabModeToSum() {
00242     this->SetSlabMode(VTK_IMAGE_SLAB_SUM); };
00243   virtual const char *GetSlabModeAsString();
00245 
00247 
00248   vtkSetMacro(SlabNumberOfSlices, int);
00249   vtkGetMacro(SlabNumberOfSlices, int);
00251 
00253 
00256   vtkSetMacro(SlabTrapezoidIntegration, int);
00257   vtkBooleanMacro(SlabTrapezoidIntegration, int);
00258   vtkGetMacro(SlabTrapezoidIntegration, int);
00260 
00262 
00264   vtkSetMacro(Optimization, int);
00265   vtkGetMacro(Optimization, int);
00266   vtkBooleanMacro(Optimization, int);
00268 
00270 
00271   vtkSetVector4Macro(BackgroundColor, double);
00272   vtkGetVector4Macro(BackgroundColor, double);
00274 
00276 
00277   void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
00278   double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
00280 
00282 
00284   virtual void SetOutputSpacing(double x, double y, double z);
00285   virtual void SetOutputSpacing(const double a[3]) {
00286     this->SetOutputSpacing(a[0], a[1], a[2]); };
00287   vtkGetVector3Macro(OutputSpacing, double);
00288   void SetOutputSpacingToDefault();
00290 
00292 
00294   virtual void SetOutputOrigin(double x, double y, double z);
00295   virtual void SetOutputOrigin(const double a[3]) {
00296     this->SetOutputOrigin(a[0], a[1], a[2]); };
00297   vtkGetVector3Macro(OutputOrigin, double);
00298   void SetOutputOriginToDefault();
00300 
00302 
00304   virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
00305   virtual void SetOutputExtent(const int a[6]) {
00306     this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
00307   vtkGetVector6Macro(OutputExtent, int);
00308   void SetOutputExtentToDefault();
00310 
00312 
00318   vtkSetMacro(OutputDimensionality, int);
00319   vtkGetMacro(OutputDimensionality, int);
00321 
00324   unsigned long int GetMTime();
00325 
00327   virtual void ReportReferences(vtkGarbageCollector*);
00328 
00330 
00335   void SetInterpolate(int t) {
00336     if (t && !this->GetInterpolate()) {
00337       this->SetInterpolationModeToLinear(); }
00338     else if (!t && this->GetInterpolate()) {
00339       this->SetInterpolationModeToNearestNeighbor(); } };
00340   void InterpolateOn() {
00341     this->SetInterpolate(1); };
00342   void InterpolateOff() {
00343     this->SetInterpolate(0); };
00344   int GetInterpolate() {
00345     return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
00347 
00349 
00352   void SetStencilData(vtkImageStencilData *stencil);
00353   vtkImageStencilData *GetStencil();
00355 
00357 
00359   vtkSetMacro(GenerateStencilOutput, int);
00360   vtkGetMacro(GenerateStencilOutput, int);
00361   vtkBooleanMacro(GenerateStencilOutput, int);
00363 
00365 
00366   vtkAlgorithmOutput *GetStencilOutputPort() {
00367     return this->GetOutputPort(1); }
00368   vtkImageStencilData *GetStencilOutput();
00369   void SetStencilOutput(vtkImageStencilData *stencil);
00371 
00372 protected:
00373   vtkImageReslice();
00374   ~vtkImageReslice();
00375 
00376   vtkMatrix4x4 *ResliceAxes;
00377   double ResliceAxesDirectionCosines[9];
00378   double ResliceAxesOrigin[3];
00379   vtkAbstractTransform *ResliceTransform;
00380   vtkAbstractImageInterpolator *Interpolator;
00381   vtkImageData *InformationInput;
00382   int Wrap;
00383   int Mirror;
00384   int Border;
00385   int InterpolationMode;
00386   int Optimization;
00387   int SlabMode;
00388   int SlabNumberOfSlices;
00389   int SlabTrapezoidIntegration;
00390   double BackgroundColor[4];
00391   double OutputOrigin[3];
00392   double OutputSpacing[3];
00393   int OutputExtent[6];
00394   int OutputScalarType;
00395   int OutputDimensionality;
00396   int TransformInputSampling;
00397   int AutoCropOutput;
00398   int HitInputExtent;
00399   int UsePermuteExecute;
00400   int ComputeOutputSpacing;
00401   int ComputeOutputOrigin;
00402   int ComputeOutputExtent;
00403   int GenerateStencilOutput;
00404 
00405   vtkMatrix4x4 *IndexMatrix;
00406   vtkAbstractTransform *OptimizedTransform;
00407 
00410   int HasConvertScalars;
00411 
00414   virtual int ConvertScalarInfo(int &scalarType, int &numComponents);
00415 
00417 
00423   virtual void ConvertScalars(void *inPtr, void *outPtr,
00424                               int inputType, int inputNumComponents,
00425                               int count, int idX, int idY, int idZ,
00426                               int threadId);
00428 
00429   void ConvertScalarsBase(void *inPtr, void *outPtr,
00430                           int inputType, int inputNumComponents,
00431                           int count, int idX, int idY, int idZ, int threadId) {
00432     this->ConvertScalars(inPtr, outPtr, inputType, inputNumComponents,
00433                          count, idX, idY, idZ, threadId); }
00434 
00435   void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
00436   virtual void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent);
00437   virtual vtkImageData *AllocateOutputData(vtkDataObject *, vtkInformation *);
00438   virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
00439                                  vtkInformationVector *);
00440   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
00441                                   vtkInformationVector *);
00442   virtual int RequestData(vtkInformation *, vtkInformationVector **,
00443                           vtkInformationVector *);
00444   virtual void ThreadedRequestData(vtkInformation *request,
00445                                    vtkInformationVector **inputVector,
00446                                    vtkInformationVector *outputVector,
00447                                    vtkImageData ***inData,
00448                                    vtkImageData **outData, int ext[6], int id);
00449   virtual int FillInputPortInformation(int port, vtkInformation *info);
00450   virtual int FillOutputPortInformation(int port, vtkInformation *info);
00451 
00452   vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
00453                                vtkInformation *outInfo);
00454   vtkAbstractTransform *GetOptimizedTransform() {
00455     return this->OptimizedTransform; };
00456 
00457 private:
00458   vtkImageReslice(const vtkImageReslice&);  // Not implemented.
00459   void operator=(const vtkImageReslice&);  // Not implemented.
00460 };
00461 
00462 #endif