VTK
/Users/kitware/Dashboards/MyTests/VTK_BLD_Release_docs/Utilities/Doxygen/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 
00236   vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
00237   vtkGetMacro(SlabMode, int);
00238   void SetSlabModeToMin() {
00239     this->SetSlabMode(VTK_IMAGE_SLAB_MIN); };
00240   void SetSlabModeToMax() {
00241     this->SetSlabMode(VTK_IMAGE_SLAB_MAX); };
00242   void SetSlabModeToMean() {
00243     this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); };
00244   void SetSlabModeToSum() {
00245     this->SetSlabMode(VTK_IMAGE_SLAB_SUM); };
00246   virtual const char *GetSlabModeAsString();
00248 
00250 
00251   vtkSetMacro(SlabNumberOfSlices, int);
00252   vtkGetMacro(SlabNumberOfSlices, int);
00254 
00256 
00259   vtkSetMacro(SlabTrapezoidIntegration, int);
00260   vtkBooleanMacro(SlabTrapezoidIntegration, int);
00261   vtkGetMacro(SlabTrapezoidIntegration, int);
00263 
00265 
00272   vtkSetMacro(SlabSliceSpacingFraction, double);
00273   vtkGetMacro(SlabSliceSpacingFraction, double);
00275 
00277 
00279   vtkSetMacro(Optimization, int);
00280   vtkGetMacro(Optimization, int);
00281   vtkBooleanMacro(Optimization, int);
00283 
00285 
00290   vtkSetMacro(ScalarShift, double);
00291   vtkGetMacro(ScalarShift, double);
00293 
00295 
00300   vtkSetMacro(ScalarScale, double);
00301   vtkGetMacro(ScalarScale, double)
00303 
00305 
00313   vtkSetMacro(OutputScalarType, int);
00314   vtkGetMacro(OutputScalarType, int);
00316 
00318 
00319   vtkSetVector4Macro(BackgroundColor, double);
00320   vtkGetVector4Macro(BackgroundColor, double);
00322 
00324 
00325   void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
00326   double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
00328 
00330 
00332   virtual void SetOutputSpacing(double x, double y, double z);
00333   virtual void SetOutputSpacing(const double a[3]) {
00334     this->SetOutputSpacing(a[0], a[1], a[2]); };
00335   vtkGetVector3Macro(OutputSpacing, double);
00336   void SetOutputSpacingToDefault();
00338 
00340 
00342   virtual void SetOutputOrigin(double x, double y, double z);
00343   virtual void SetOutputOrigin(const double a[3]) {
00344     this->SetOutputOrigin(a[0], a[1], a[2]); };
00345   vtkGetVector3Macro(OutputOrigin, double);
00346   void SetOutputOriginToDefault();
00348 
00350 
00352   virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
00353   virtual void SetOutputExtent(const int a[6]) {
00354     this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
00355   vtkGetVector6Macro(OutputExtent, int);
00356   void SetOutputExtentToDefault();
00358 
00360 
00366   vtkSetMacro(OutputDimensionality, int);
00367   vtkGetMacro(OutputDimensionality, int);
00369 
00372   unsigned long int GetMTime();
00373 
00375   virtual void ReportReferences(vtkGarbageCollector*);
00376 
00378 
00383   void SetInterpolate(int t) {
00384     if (t && !this->GetInterpolate()) {
00385       this->SetInterpolationModeToLinear(); }
00386     else if (!t && this->GetInterpolate()) {
00387       this->SetInterpolationModeToNearestNeighbor(); } };
00388   void InterpolateOn() {
00389     this->SetInterpolate(1); };
00390   void InterpolateOff() {
00391     this->SetInterpolate(0); };
00392   int GetInterpolate() {
00393     return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
00395 
00397 
00400   void SetStencilData(vtkImageStencilData *stencil);
00401   vtkImageStencilData *GetStencil();
00403 
00405 
00407   vtkSetMacro(GenerateStencilOutput, int);
00408   vtkGetMacro(GenerateStencilOutput, int);
00409   vtkBooleanMacro(GenerateStencilOutput, int);
00411 
00413 
00414   vtkAlgorithmOutput *GetStencilOutputPort() {
00415     return this->GetOutputPort(1); }
00416   vtkImageStencilData *GetStencilOutput();
00417   void SetStencilOutput(vtkImageStencilData *stencil);
00419 
00420 protected:
00421   vtkImageReslice();
00422   ~vtkImageReslice();
00423 
00424   vtkMatrix4x4 *ResliceAxes;
00425   double ResliceAxesDirectionCosines[9];
00426   double ResliceAxesOrigin[3];
00427   vtkAbstractTransform *ResliceTransform;
00428   vtkAbstractImageInterpolator *Interpolator;
00429   vtkImageData *InformationInput;
00430   int Wrap;
00431   int Mirror;
00432   int Border;
00433   int InterpolationMode;
00434   int Optimization;
00435   int SlabMode;
00436   int SlabNumberOfSlices;
00437   int SlabTrapezoidIntegration;
00438   double SlabSliceSpacingFraction;
00439   double ScalarShift;
00440   double ScalarScale;
00441   double BackgroundColor[4];
00442   double OutputOrigin[3];
00443   double OutputSpacing[3];
00444   int OutputExtent[6];
00445   int OutputScalarType;
00446   int OutputDimensionality;
00447   int TransformInputSampling;
00448   int AutoCropOutput;
00449   int HitInputExtent;
00450   int UsePermuteExecute;
00451   int ComputeOutputSpacing;
00452   int ComputeOutputOrigin;
00453   int ComputeOutputExtent;
00454   int GenerateStencilOutput;
00455 
00456   vtkMatrix4x4 *IndexMatrix;
00457   vtkAbstractTransform *OptimizedTransform;
00458 
00461   int HasConvertScalars;
00462 
00465   virtual int ConvertScalarInfo(int &scalarType, int &numComponents);
00466 
00468 
00474   virtual void ConvertScalars(void *inPtr, void *outPtr,
00475                               int inputType, int inputNumComponents,
00476                               int count, int idX, int idY, int idZ,
00477                               int threadId);
00479 
00480   void ConvertScalarsBase(void *inPtr, void *outPtr,
00481                           int inputType, int inputNumComponents,
00482                           int count, int idX, int idY, int idZ, int threadId) {
00483     this->ConvertScalars(inPtr, outPtr, inputType, inputNumComponents,
00484                          count, idX, idY, idZ, threadId); }
00485 
00486   void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
00487   virtual void AllocateOutputData(vtkImageData *output, vtkInformation *outInfo, int *uExtent);
00488   virtual vtkImageData *AllocateOutputData(vtkDataObject *, vtkInformation *);
00489   virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
00490                                  vtkInformationVector *);
00491   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
00492                                   vtkInformationVector *);
00493   virtual int RequestData(vtkInformation *, vtkInformationVector **,
00494                           vtkInformationVector *);
00495   virtual void ThreadedRequestData(vtkInformation *request,
00496                                    vtkInformationVector **inputVector,
00497                                    vtkInformationVector *outputVector,
00498                                    vtkImageData ***inData,
00499                                    vtkImageData **outData, int ext[6], int id);
00500   virtual int FillInputPortInformation(int port, vtkInformation *info);
00501   virtual int FillOutputPortInformation(int port, vtkInformation *info);
00502 
00503   vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
00504                                vtkInformation *outInfo);
00505   vtkAbstractTransform *GetOptimizedTransform() {
00506     return this->OptimizedTransform; };
00507 
00508 private:
00509   vtkImageReslice(const vtkImageReslice&);  // Not implemented.
00510   void operator=(const vtkImageReslice&);  // Not implemented.
00511 };
00512 
00513 #endif