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

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 =========================================================================*/
00064 #ifndef __vtkImageReslice_h
00065 #define __vtkImageReslice_h
00066 
00067 
00068 #include "vtkImageToImageFilter.h"
00069 
00070 // interpolation mode constants
00071 #define VTK_RESLICE_NEAREST 0
00072 #define VTK_RESLICE_LINEAR 1
00073 #define VTK_RESLICE_CUBIC 3
00074 
00075 class vtkImageData;
00076 class vtkAbstractTransform;
00077 class vtkMatrix4x4;
00078 class vtkImageStencilData;
00079 
00080 class VTK_IMAGING_EXPORT vtkImageReslice : public vtkImageToImageFilter
00081 {
00082 public:
00083   static vtkImageReslice *New();
00084   vtkTypeRevisionMacro(vtkImageReslice, vtkImageToImageFilter);
00085 
00086   virtual void PrintSelf(ostream& os, vtkIndent indent);
00087 
00089 
00101   virtual void SetResliceAxes(vtkMatrix4x4*);
00102   vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
00104 
00106 
00110   void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
00111                                       double y0, double y1, double y2,
00112                                       double z0, double z1, double z2);
00113   void SetResliceAxesDirectionCosines(const double x[3],
00114                                       const double y[3],
00115                                       const double z[3]) {
00116     this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
00117                                          y[0], y[1], y[2],
00118                                          z[0], z[1], z[2]); };
00119   void SetResliceAxesDirectionCosines(const double xyz[9]) {
00120     this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
00121                                          xyz[3], xyz[4], xyz[5],
00122                                          xyz[6], xyz[7], xyz[8]); };
00123   void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
00124   void GetResliceAxesDirectionCosines(double xyz[9]) {
00125     this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
00126   double *GetResliceAxesDirectionCosines() {
00127     this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
00128     return this->ResliceAxesDirectionCosines; };
00130 
00132 
00135   void SetResliceAxesOrigin(double x, double y, double z);
00136   void SetResliceAxesOrigin(const double xyz[3]) {
00137     this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
00138   void GetResliceAxesOrigin(double xyz[3]);
00139   double *GetResliceAxesOrigin() {
00140     this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
00141     return this->ResliceAxesOrigin; };
00143 
00145 
00152   virtual void SetResliceTransform(vtkAbstractTransform*);
00153   vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
00155 
00157 
00163   virtual void SetInformationInput(vtkImageData*);
00164   vtkGetObjectMacro(InformationInput, vtkImageData);
00166 
00168 
00172   vtkSetMacro(TransformInputSampling, int);
00173   vtkBooleanMacro(TransformInputSampling, int);
00174   vtkGetMacro(TransformInputSampling, int);
00176 
00178 
00180   vtkSetMacro(AutoCropOutput, int);
00181   vtkBooleanMacro(AutoCropOutput, int);
00182   vtkGetMacro(AutoCropOutput, int);
00184 
00186 
00187   vtkSetMacro(Wrap, int);
00188   vtkGetMacro(Wrap, int);
00189   vtkBooleanMacro(Wrap, int);
00191 
00193 
00195   vtkSetMacro(Mirror, int);
00196   vtkGetMacro(Mirror, int);
00197   vtkBooleanMacro(Mirror, int);
00199 
00201 
00202   vtkSetMacro(InterpolationMode, int);
00203   vtkGetMacro(InterpolationMode, int);
00204   void SetInterpolationModeToNearestNeighbor() {
00205     this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
00206   void SetInterpolationModeToLinear() {
00207     this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
00208   void SetInterpolationModeToCubic() {
00209     this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
00210   const char *GetInterpolationModeAsString();
00212 
00214 
00216   vtkSetMacro(Optimization, int);
00217   vtkGetMacro(Optimization, int);
00218   vtkBooleanMacro(Optimization, int);
00220 
00222 
00223   vtkSetVector4Macro(BackgroundColor, double);
00224   vtkGetVector4Macro(BackgroundColor, double);
00226 
00228 
00229   void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
00230   double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
00232 
00234 
00236   vtkSetVector3Macro(OutputSpacing, double);
00237   vtkGetVector3Macro(OutputSpacing, double);
00238   void SetOutputSpacingToDefault() {
00239     this->SetOutputSpacing(VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX); };
00241 
00243 
00245   vtkSetVector3Macro(OutputOrigin, double);
00246   vtkGetVector3Macro(OutputOrigin, double);
00247   void SetOutputOriginToDefault() {
00248     this->SetOutputOrigin(VTK_DOUBLE_MAX, VTK_DOUBLE_MAX, VTK_DOUBLE_MAX); };
00250 
00252 
00254   vtkSetVector6Macro(OutputExtent, int);
00255   vtkGetVector6Macro(OutputExtent, int);
00256   void SetOutputExtentToDefault() {
00257     this->SetOutputExtent(VTK_INT_MIN, VTK_INT_MAX,
00258                           VTK_INT_MIN, VTK_INT_MAX,
00259                           VTK_INT_MIN, VTK_INT_MAX); };
00261 
00263 
00269   vtkSetMacro(OutputDimensionality, int);
00270   vtkGetMacro(OutputDimensionality, int);
00272 
00275   unsigned long int GetMTime();
00276 
00278 
00283   void SetInterpolate(int t) {
00284     if (t && !this->GetInterpolate()) {
00285       this->SetInterpolationModeToLinear(); }
00286     else if (!t && this->GetInterpolate()) {
00287       this->SetInterpolationModeToNearestNeighbor(); } };
00288   void InterpolateOn() {
00289     this->SetInterpolate(1); };
00290   void InterpolateOff() {
00291     this->SetInterpolate(0); };
00292   int GetInterpolate() {
00293     return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
00295 
00297 
00300   void SetStencil(vtkImageStencilData *stencil);
00301   vtkImageStencilData *GetStencil();
00303 
00304 protected:
00305   vtkImageReslice();
00306   ~vtkImageReslice();
00307 
00308   vtkMatrix4x4 *ResliceAxes;
00309   double ResliceAxesDirectionCosines[9];
00310   double ResliceAxesOrigin[3];
00311   vtkAbstractTransform *ResliceTransform;
00312   vtkImageData *InformationInput;
00313   int Wrap;
00314   int Mirror;
00315   int InterpolationMode;
00316   int Optimization;
00317   double BackgroundColor[4];
00318   double OutputOrigin[3];
00319   double OutputSpacing[3];
00320   int OutputExtent[6];
00321   int OutputDimensionality;
00322   int TransformInputSampling;
00323   int AutoCropOutput;
00324 
00325   vtkMatrix4x4 *IndexMatrix;
00326   vtkAbstractTransform *OptimizedTransform;
00327 
00328   void GetAutoCroppedOutputBounds(vtkImageData *input, double bounds[6]);
00329   void ExecuteInformation(vtkImageData *input, vtkImageData *output);
00330   void ExecuteInformation();
00331   void ComputeInputUpdateExtents(vtkDataObject *output);
00332   void ComputeInputUpdateExtent(int inExt[6], int outExt[6]);
00333   void ThreadedExecute(vtkImageData *inData, vtkImageData *outData, 
00334                        int ext[6], int id);
00335 
00336   vtkMatrix4x4 *GetIndexMatrix();
00337   vtkAbstractTransform *GetOptimizedTransform() { 
00338     return this->OptimizedTransform; };
00339   void OptimizedComputeInputUpdateExtent(int inExt[6], int outExt[6]);
00340   void OptimizedThreadedExecute(vtkImageData *inData, vtkImageData *outData, 
00341                                 int ext[6], int id);
00342 private:
00343   vtkImageReslice(const vtkImageReslice&);  // Not implemented.
00344   void operator=(const vtkImageReslice&);  // Not implemented.
00345 };
00346 
00347 //----------------------------------------------------------------------------
00348 inline const char *vtkImageReslice::GetInterpolationModeAsString()
00349 {
00350   switch (this->InterpolationMode)
00351     {
00352     case VTK_RESLICE_NEAREST:
00353       return "NearestNeighbor";
00354     case VTK_RESLICE_LINEAR:
00355       return "Linear";
00356     case VTK_RESLICE_CUBIC:
00357       return "Cubic";
00358     default:
00359       return "";
00360     }
00361 }  
00362 
00363 #endif
00364 
00365 
00366 
00367 
00368