VTK
dox/Imaging/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 "vtkThreadedImageAlgorithm.h"
00062 
00063 // interpolation mode constants
00064 #define VTK_RESLICE_NEAREST 0
00065 #define VTK_RESLICE_LINEAR 1
00066 #define VTK_RESLICE_RESERVED_2 2
00067 #define VTK_RESLICE_CUBIC 3
00068 
00069 class vtkImageData;
00070 class vtkAbstractTransform;
00071 class vtkMatrix4x4;
00072 class vtkImageStencilData;
00073 
00074 class VTK_IMAGING_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
00075 {
00076 public:
00077   static vtkImageReslice *New();
00078   vtkTypeMacro(vtkImageReslice, vtkThreadedImageAlgorithm);
00079 
00080   virtual void PrintSelf(ostream& os, vtkIndent indent);
00081 
00083 
00095   virtual void SetResliceAxes(vtkMatrix4x4*);
00096   vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
00098 
00100 
00104   void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
00105                                       double y0, double y1, double y2,
00106                                       double z0, double z1, double z2);
00107   void SetResliceAxesDirectionCosines(const double x[3],
00108                                       const double y[3],
00109                                       const double z[3]) {
00110     this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
00111                                          y[0], y[1], y[2],
00112                                          z[0], z[1], z[2]); };
00113   void SetResliceAxesDirectionCosines(const double xyz[9]) {
00114     this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
00115                                          xyz[3], xyz[4], xyz[5],
00116                                          xyz[6], xyz[7], xyz[8]); };
00117   void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
00118   void GetResliceAxesDirectionCosines(double xyz[9]) {
00119     this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
00120   double *GetResliceAxesDirectionCosines() {
00121     this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
00122     return this->ResliceAxesDirectionCosines; };
00124 
00126 
00129   void SetResliceAxesOrigin(double x, double y, double z);
00130   void SetResliceAxesOrigin(const double xyz[3]) {
00131     this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
00132   void GetResliceAxesOrigin(double xyz[3]);
00133   double *GetResliceAxesOrigin() {
00134     this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
00135     return this->ResliceAxesOrigin; };
00137 
00139 
00146   virtual void SetResliceTransform(vtkAbstractTransform*);
00147   vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
00149 
00151 
00157   virtual void SetInformationInput(vtkImageData*);
00158   vtkGetObjectMacro(InformationInput, vtkImageData);
00160 
00162 
00166   vtkSetMacro(TransformInputSampling, int);
00167   vtkBooleanMacro(TransformInputSampling, int);
00168   vtkGetMacro(TransformInputSampling, int);
00170 
00172 
00175   vtkSetMacro(AutoCropOutput, int);
00176   vtkBooleanMacro(AutoCropOutput, int);
00177   vtkGetMacro(AutoCropOutput, int);
00179 
00181 
00182   vtkSetMacro(Wrap, int);
00183   vtkGetMacro(Wrap, int);
00184   vtkBooleanMacro(Wrap, int);
00186 
00188 
00190   vtkSetMacro(Mirror, int);
00191   vtkGetMacro(Mirror, int);
00192   vtkBooleanMacro(Mirror, int);
00194 
00196 
00203   vtkSetMacro(Border, int);
00204   vtkGetMacro(Border, int);
00205   vtkBooleanMacro(Border, int);
00207 
00209 
00210   vtkSetClampMacro(InterpolationMode, int,
00211                    VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
00212   vtkGetMacro(InterpolationMode, int);
00213   void SetInterpolationModeToNearestNeighbor() {
00214     this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
00215   void SetInterpolationModeToLinear() {
00216     this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
00217   void SetInterpolationModeToCubic() {
00218     this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
00219   virtual const char *GetInterpolationModeAsString();
00221 
00223 
00225   vtkSetMacro(Optimization, int);
00226   vtkGetMacro(Optimization, int);
00227   vtkBooleanMacro(Optimization, int);
00229 
00231 
00232   vtkSetVector4Macro(BackgroundColor, double);
00233   vtkGetVector4Macro(BackgroundColor, double);
00235 
00237 
00238   void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
00239   double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
00241 
00243 
00245   virtual void SetOutputSpacing(double x, double y, double z);
00246   virtual void SetOutputSpacing(const double a[3]) {
00247     this->SetOutputSpacing(a[0], a[1], a[2]); };
00248   vtkGetVector3Macro(OutputSpacing, double);
00249   void SetOutputSpacingToDefault();
00251 
00253 
00255   virtual void SetOutputOrigin(double x, double y, double z);
00256   virtual void SetOutputOrigin(const double a[3]) {
00257     this->SetOutputOrigin(a[0], a[1], a[2]); };
00258   vtkGetVector3Macro(OutputOrigin, double);
00259   void SetOutputOriginToDefault();
00261 
00263 
00265   virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
00266   virtual void SetOutputExtent(const int a[6]) {
00267     this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
00268   vtkGetVector6Macro(OutputExtent, int);
00269   void SetOutputExtentToDefault();
00271 
00273 
00279   vtkSetMacro(OutputDimensionality, int);
00280   vtkGetMacro(OutputDimensionality, int);
00282 
00285   unsigned long int GetMTime();
00286 
00288   virtual void ReportReferences(vtkGarbageCollector*);
00289 
00291 
00296   void SetInterpolate(int t) {
00297     if (t && !this->GetInterpolate()) {
00298       this->SetInterpolationModeToLinear(); }
00299     else if (!t && this->GetInterpolate()) {
00300       this->SetInterpolationModeToNearestNeighbor(); } };
00301   void InterpolateOn() {
00302     this->SetInterpolate(1); };
00303   void InterpolateOff() {
00304     this->SetInterpolate(0); };
00305   int GetInterpolate() {
00306     return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
00308 
00310 
00313   void SetStencil(vtkImageStencilData *stencil);
00314   vtkImageStencilData *GetStencil();
00316 
00317 protected:
00318   vtkImageReslice();
00319   ~vtkImageReslice();
00320 
00321   vtkMatrix4x4 *ResliceAxes;
00322   double ResliceAxesDirectionCosines[9];
00323   double ResliceAxesOrigin[3];
00324   vtkAbstractTransform *ResliceTransform;
00325   vtkImageData *InformationInput;
00326   int Wrap;
00327   int Mirror;
00328   int Border;
00329   int InterpolationMode;
00330   int Optimization;
00331   double BackgroundColor[4];
00332   double OutputOrigin[3];
00333   double OutputSpacing[3];
00334   int OutputExtent[6];
00335   int OutputDimensionality;
00336   int TransformInputSampling;
00337   int AutoCropOutput;
00338   int HitInputExtent;
00339   int ComputeOutputSpacing;
00340   int ComputeOutputOrigin;
00341   int ComputeOutputExtent;
00342 
00343   vtkMatrix4x4 *IndexMatrix;
00344   vtkAbstractTransform *OptimizedTransform;
00345 
00346   void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
00347   virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
00348                                  vtkInformationVector *);
00349   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
00350                                   vtkInformationVector *);
00351   virtual void ThreadedRequestData(vtkInformation *request,
00352                                    vtkInformationVector **inputVector,
00353                                    vtkInformationVector *outputVector,
00354                                    vtkImageData ***inData,
00355                                    vtkImageData **outData, int ext[6], int id);
00356   virtual int FillInputPortInformation(int port, vtkInformation *info);
00357 
00358   vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
00359                                vtkInformation *outInfo);
00360   vtkAbstractTransform *GetOptimizedTransform() { 
00361     return this->OptimizedTransform; };
00362 
00363 private:
00364   vtkImageReslice(const vtkImageReslice&);  // Not implemented.
00365   void operator=(const vtkImageReslice&);  // Not implemented.
00366 };
00367 
00368 #endif