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   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   vtkSetVector3Macro(OutputSpacing, double);
00246   vtkGetVector3Macro(OutputSpacing, double);
00247   void SetOutputSpacingToDefault() {
00248     this->SetOutputSpacing(VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX); };
00250 
00252 
00254   vtkSetVector3Macro(OutputOrigin, double);
00255   vtkGetVector3Macro(OutputOrigin, double);
00256   void SetOutputOriginToDefault() {
00257     this->SetOutputOrigin(VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX); };
00259 
00261 
00263   vtkSetVector6Macro(OutputExtent, int);
00264   vtkGetVector6Macro(OutputExtent, int);
00265   void SetOutputExtentToDefault() {
00266     this->SetOutputExtent(VTK_INT_MIN, VTK_INT_MAX,
00267                           VTK_INT_MIN, VTK_INT_MAX,
00268                           VTK_INT_MIN, VTK_INT_MAX); };
00270 
00272 
00278   vtkSetMacro(OutputDimensionality, int);
00279   vtkGetMacro(OutputDimensionality, int);
00281 
00284   unsigned long int GetMTime();
00285 
00287   virtual void ReportReferences(vtkGarbageCollector*);
00288 
00290 
00295   void SetInterpolate(int t) {
00296     if (t && !this->GetInterpolate()) {
00297       this->SetInterpolationModeToLinear(); }
00298     else if (!t && this->GetInterpolate()) {
00299       this->SetInterpolationModeToNearestNeighbor(); } };
00300   void InterpolateOn() {
00301     this->SetInterpolate(1); };
00302   void InterpolateOff() {
00303     this->SetInterpolate(0); };
00304   int GetInterpolate() {
00305     return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
00307 
00309 
00312   void SetStencil(vtkImageStencilData *stencil);
00313   vtkImageStencilData *GetStencil();
00315 
00316 protected:
00317   vtkImageReslice();
00318   ~vtkImageReslice();
00319 
00320   vtkMatrix4x4 *ResliceAxes;
00321   double ResliceAxesDirectionCosines[9];
00322   double ResliceAxesOrigin[3];
00323   vtkAbstractTransform *ResliceTransform;
00324   vtkImageData *InformationInput;
00325   int Wrap;
00326   int Mirror;
00327   int Border;
00328   int InterpolationMode;
00329   int Optimization;
00330   double BackgroundColor[4];
00331   double OutputOrigin[3];
00332   double OutputSpacing[3];
00333   int OutputExtent[6];
00334   int OutputDimensionality;
00335   int TransformInputSampling;
00336   int AutoCropOutput;
00337   int HitInputExtent;
00338 
00339   vtkMatrix4x4 *IndexMatrix;
00340   vtkAbstractTransform *OptimizedTransform;
00341 
00342   void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
00343   virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
00344                                  vtkInformationVector *);
00345   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
00346                                   vtkInformationVector *);
00347   virtual void ThreadedRequestData(vtkInformation *request,
00348                                    vtkInformationVector **inputVector,
00349                                    vtkInformationVector *outputVector,
00350                                    vtkImageData ***inData,
00351                                    vtkImageData **outData, int ext[6], int id);
00352   virtual int FillInputPortInformation(int port, vtkInformation *info);
00353 
00354   vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
00355                                vtkInformation *outInfo);
00356   vtkAbstractTransform *GetOptimizedTransform() { 
00357     return this->OptimizedTransform; };
00358 
00359 private:
00360   vtkImageReslice(const vtkImageReslice&);  // Not implemented.
00361   void operator=(const vtkImageReslice&);  // Not implemented.
00362 };
00363 
00364 //----------------------------------------------------------------------------
00365 inline const char *vtkImageReslice::GetInterpolationModeAsString()
00366 {
00367   switch (this->InterpolationMode)
00368     {
00369     case VTK_RESLICE_NEAREST:
00370       return "NearestNeighbor";
00371     case VTK_RESLICE_LINEAR:
00372       return "Linear";
00373     case VTK_RESLICE_RESERVED_2:
00374       return "ReservedValue";
00375     case VTK_RESLICE_CUBIC:
00376       return "Cubic";
00377     default:
00378       return "";
00379     }
00380 }  
00381 
00382 #endif
00383 
00384 
00385 
00386 
00387