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

Imaging/vtkImageReslice.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkImageReslice.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 =========================================================================*/
00054 #ifndef __vtkImageReslice_h
00055 #define __vtkImageReslice_h
00056 
00057 
00058 #include "vtkImageToImageFilter.h"
00059 
00060 // interpolation mode constants
00061 #define VTK_RESLICE_NEAREST 0
00062 #define VTK_RESLICE_LINEAR 1
00063 #define VTK_RESLICE_CUBIC 3
00064 
00065 class vtkImageData;
00066 class vtkAbstractTransform;
00067 class vtkMatrix4x4;
00068 class vtkImageStencilData;
00069 
00070 class VTK_IMAGING_EXPORT vtkImageReslice : public vtkImageToImageFilter
00071 {
00072 public:
00073   static vtkImageReslice *New();
00074   vtkTypeRevisionMacro(vtkImageReslice, vtkImageToImageFilter);
00075 
00076   virtual void PrintSelf(ostream& os, vtkIndent indent);
00077 
00079 
00091   virtual void SetResliceAxes(vtkMatrix4x4*);
00092   vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
00094 
00096 
00100   void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
00101                                       double y0, double y1, double y2,
00102                                       double z0, double z1, double z2);
00103   void SetResliceAxesDirectionCosines(const double x[3],
00104                                       const double y[3],
00105                                       const double z[3]) {
00106     this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
00107                                          y[0], y[1], y[2],
00108                                          z[0], z[1], z[2]); };
00109   void SetResliceAxesDirectionCosines(const double xyz[9]) {
00110     this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
00111                                          xyz[3], xyz[4], xyz[5],
00112                                          xyz[6], xyz[7], xyz[8]); };
00113   void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
00114   void GetResliceAxesDirectionCosines(double xyz[9]) {
00115     this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
00116   double *GetResliceAxesDirectionCosines() {
00117     this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
00118     return this->ResliceAxesDirectionCosines; };
00120 
00122 
00125   void SetResliceAxesOrigin(double x, double y, double z);
00126   void SetResliceAxesOrigin(const double xyz[3]) {
00127     this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
00128   void GetResliceAxesOrigin(double xyz[3]);
00129   double *GetResliceAxesOrigin() {
00130     this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
00131     return this->ResliceAxesOrigin; };
00133 
00135 
00142   virtual void SetResliceTransform(vtkAbstractTransform*);
00143   vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
00145 
00147 
00153   virtual void SetInformationInput(vtkImageData*);
00154   vtkGetObjectMacro(InformationInput, vtkImageData);
00156 
00158 
00162   vtkSetMacro(TransformInputSampling, int);
00163   vtkBooleanMacro(TransformInputSampling, int);
00164   vtkGetMacro(TransformInputSampling, int);
00166 
00168 
00170   vtkSetMacro(AutoCropOutput, int);
00171   vtkBooleanMacro(AutoCropOutput, int);
00172   vtkGetMacro(AutoCropOutput, int);
00174 
00176 
00177   vtkSetMacro(Wrap, int);
00178   vtkGetMacro(Wrap, int);
00179   vtkBooleanMacro(Wrap, int);
00181 
00183 
00185   vtkSetMacro(Mirror, int);
00186   vtkGetMacro(Mirror, int);
00187   vtkBooleanMacro(Mirror, int);
00189 
00191 
00192   vtkSetMacro(InterpolationMode, int);
00193   vtkGetMacro(InterpolationMode, int);
00194   void SetInterpolationModeToNearestNeighbor() {
00195     this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
00196   void SetInterpolationModeToLinear() {
00197     this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
00198   void SetInterpolationModeToCubic() {
00199     this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
00200   const char *GetInterpolationModeAsString();
00202 
00204 
00206   vtkSetMacro(Optimization, int);
00207   vtkGetMacro(Optimization, int);
00208   vtkBooleanMacro(Optimization, int);
00210 
00212 
00213   vtkSetVector4Macro(BackgroundColor, double);
00214   vtkGetVector4Macro(BackgroundColor, double);
00216 
00218 
00219   void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
00220   double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
00222 
00224 
00226   vtkSetVector3Macro(OutputSpacing, double);
00227   vtkGetVector3Macro(OutputSpacing, double);
00228   void SetOutputSpacingToDefault() {
00229     this->SetOutputSpacing(VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX); };
00231 
00233 
00235   vtkSetVector3Macro(OutputOrigin, double);
00236   vtkGetVector3Macro(OutputOrigin, double);
00237   void SetOutputOriginToDefault() {
00238     this->SetOutputOrigin(VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX); };
00240 
00242 
00244   vtkSetVector6Macro(OutputExtent, int);
00245   vtkGetVector6Macro(OutputExtent, int);
00246   void SetOutputExtentToDefault() {
00247     this->SetOutputExtent(VTK_INT_MIN, VTK_INT_MAX,
00248                           VTK_INT_MIN, VTK_INT_MAX,
00249                           VTK_INT_MIN, VTK_INT_MAX); };
00251 
00253 
00259   vtkSetMacro(OutputDimensionality, int);
00260   vtkGetMacro(OutputDimensionality, int);
00262 
00265   unsigned long int GetMTime();
00266 
00268 
00273   void SetInterpolate(int t) {
00274     if (t && !this->GetInterpolate()) {
00275       this->SetInterpolationModeToLinear(); }
00276     else if (!t && this->GetInterpolate()) {
00277       this->SetInterpolationModeToNearestNeighbor(); } };
00278   void InterpolateOn() {
00279     this->SetInterpolate(1); };
00280   void InterpolateOff() {
00281     this->SetInterpolate(0); };
00282   int GetInterpolate() {
00283     return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
00285 
00287 
00290   void SetStencil(vtkImageStencilData *stencil);
00291   vtkImageStencilData *GetStencil();
00293 
00294 protected:
00295   vtkImageReslice();
00296   ~vtkImageReslice();
00297 
00298   vtkMatrix4x4 *ResliceAxes;
00299   double ResliceAxesDirectionCosines[9];
00300   double ResliceAxesOrigin[3];
00301   vtkAbstractTransform *ResliceTransform;
00302   vtkImageData *InformationInput;
00303   int Wrap;
00304   int Mirror;
00305   int InterpolationMode;
00306   int Optimization;
00307   double BackgroundColor[4];
00308   double OutputOrigin[3];
00309   double OutputSpacing[3];
00310   int OutputExtent[6];
00311   int OutputDimensionality;
00312   int TransformInputSampling;
00313   int AutoCropOutput;
00314 
00315   vtkMatrix4x4 *IndexMatrix;
00316   vtkAbstractTransform *OptimizedTransform;
00317 
00318   void GetAutoCroppedOutputBounds(vtkImageData *input, double bounds[6]);
00319   void ExecuteInformation(vtkImageData *input, vtkImageData *output);
00320   void ExecuteInformation();
00321   void ComputeInputUpdateExtents(vtkDataObject *output);
00322   void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
00323   void ThreadedExecute(vtkImageData *inData, vtkImageData *outData, 
00324                        int ext[6], int id);
00325 
00326   vtkMatrix4x4 *GetIndexMatrix();
00327   vtkAbstractTransform *GetOptimizedTransform() { 
00328     return this->OptimizedTransform; };
00329   void OptimizedComputeInputUpdateExtent(int inExt[6], int outExt[6]);
00330   void OptimizedThreadedExecute(vtkImageData *inData, vtkImageData *outData, 
00331                                 int ext[6], int id);
00332 private:
00333   vtkImageReslice(const vtkImageReslice&);  // Not implemented.
00334   void operator=(const vtkImageReslice&);  // Not implemented.
00335 };
00336 
00337 //----------------------------------------------------------------------------
00338 inline const char *vtkImageReslice::GetInterpolationModeAsString()
00339 {
00340   switch (this->InterpolationMode)
00341     {
00342     case VTK_RESLICE_NEAREST:
00343       return "NearestNeighbor";
00344     case VTK_RESLICE_LINEAR:
00345       return "Linear";
00346     case VTK_RESLICE_CUBIC:
00347       return "Cubic";
00348     default:
00349       return "";
00350     }
00351 }  
00352 
00353 #endif
00354 
00355 
00356 
00357 
00358