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 VTK_NEAREST_INTERPOLATION
00065 #define VTK_RESLICE_LINEAR VTK_LINEAR_INTERPOLATION
00066 #define VTK_RESLICE_CUBIC VTK_CUBIC_INTERPOLATION
00067 
00068 class vtkImageData;
00069 class vtkAbstractTransform;
00070 class vtkMatrix4x4;
00071 class vtkImageStencilData;
00072 class vtkScalarsToColors;
00073 class vtkAbstractImageInterpolator;
00074 
00075 class VTK_IMAGING_EXPORT vtkImageReslice : public vtkThreadedImageAlgorithm
00076 {
00077 public:
00078   static vtkImageReslice *New();
00079   vtkTypeMacro(vtkImageReslice, vtkThreadedImageAlgorithm);
00080 
00081   virtual void PrintSelf(ostream& os, vtkIndent indent);
00082 
00084 
00096   virtual void SetResliceAxes(vtkMatrix4x4*);
00097   vtkGetObjectMacro(ResliceAxes, vtkMatrix4x4);
00099 
00101 
00105   void SetResliceAxesDirectionCosines(double x0, double x1, double x2,
00106                                       double y0, double y1, double y2,
00107                                       double z0, double z1, double z2);
00108   void SetResliceAxesDirectionCosines(const double x[3],
00109                                       const double y[3],
00110                                       const double z[3]) {
00111     this->SetResliceAxesDirectionCosines(x[0], x[1], x[2],
00112                                          y[0], y[1], y[2],
00113                                          z[0], z[1], z[2]); };
00114   void SetResliceAxesDirectionCosines(const double xyz[9]) {
00115     this->SetResliceAxesDirectionCosines(xyz[0], xyz[1], xyz[2],
00116                                          xyz[3], xyz[4], xyz[5],
00117                                          xyz[6], xyz[7], xyz[8]); };
00118   void GetResliceAxesDirectionCosines(double x[3], double y[3], double z[3]);
00119   void GetResliceAxesDirectionCosines(double xyz[9]) {
00120     this->GetResliceAxesDirectionCosines(&xyz[0], &xyz[3], &xyz[6]); };
00121   double *GetResliceAxesDirectionCosines() {
00122     this->GetResliceAxesDirectionCosines(this->ResliceAxesDirectionCosines);
00123     return this->ResliceAxesDirectionCosines; };
00125 
00127 
00130   void SetResliceAxesOrigin(double x, double y, double z);
00131   void SetResliceAxesOrigin(const double xyz[3]) {
00132     this->SetResliceAxesOrigin(xyz[0], xyz[1], xyz[2]); };
00133   void GetResliceAxesOrigin(double xyz[3]);
00134   double *GetResliceAxesOrigin() {
00135     this->GetResliceAxesOrigin(this->ResliceAxesOrigin);
00136     return this->ResliceAxesOrigin; };
00138 
00140 
00147   virtual void SetResliceTransform(vtkAbstractTransform*);
00148   vtkGetObjectMacro(ResliceTransform, vtkAbstractTransform);
00150 
00152 
00158   virtual void SetInformationInput(vtkImageData*);
00159   vtkGetObjectMacro(InformationInput, vtkImageData);
00161 
00163 
00167   vtkSetMacro(TransformInputSampling, int);
00168   vtkBooleanMacro(TransformInputSampling, int);
00169   vtkGetMacro(TransformInputSampling, int);
00171 
00173 
00176   vtkSetMacro(AutoCropOutput, int);
00177   vtkBooleanMacro(AutoCropOutput, int);
00178   vtkGetMacro(AutoCropOutput, int);
00180 
00182 
00183   vtkSetMacro(Wrap, int);
00184   vtkGetMacro(Wrap, int);
00185   vtkBooleanMacro(Wrap, int);
00187 
00189 
00191   vtkSetMacro(Mirror, int);
00192   vtkGetMacro(Mirror, int);
00193   vtkBooleanMacro(Mirror, int);
00195 
00197 
00204   vtkSetMacro(Border, int);
00205   vtkGetMacro(Border, int);
00206   vtkBooleanMacro(Border, int);
00208 
00210 
00211   vtkSetClampMacro(InterpolationMode, int,
00212                    VTK_RESLICE_NEAREST, VTK_RESLICE_CUBIC);
00213   vtkGetMacro(InterpolationMode, int);
00214   void SetInterpolationModeToNearestNeighbor() {
00215     this->SetInterpolationMode(VTK_RESLICE_NEAREST); };
00216   void SetInterpolationModeToLinear() {
00217     this->SetInterpolationMode(VTK_RESLICE_LINEAR); };
00218   void SetInterpolationModeToCubic() {
00219     this->SetInterpolationMode(VTK_RESLICE_CUBIC); };
00220   virtual const char *GetInterpolationModeAsString();
00222 
00224 
00226   virtual void SetInterpolator(vtkAbstractImageInterpolator *sampler);
00227   virtual vtkAbstractImageInterpolator *GetInterpolator();
00229 
00231 
00232   vtkSetClampMacro(SlabMode, int, VTK_IMAGE_SLAB_MIN, VTK_IMAGE_SLAB_SUM);
00233   vtkGetMacro(SlabMode, int);
00234   void SetSlabModeToMin() {
00235     this->SetSlabMode(VTK_IMAGE_SLAB_MIN); };
00236   void SetSlabModeToMax() {
00237     this->SetSlabMode(VTK_IMAGE_SLAB_MAX); };
00238   void SetSlabModeToMean() {
00239     this->SetSlabMode(VTK_IMAGE_SLAB_MEAN); };
00240   void SetSlabModeToSum() {
00241     this->SetSlabMode(VTK_IMAGE_SLAB_SUM); };
00242   virtual const char *GetSlabModeAsString();
00244 
00246 
00247   vtkSetMacro(SlabNumberOfSlices, int);
00248   vtkGetMacro(SlabNumberOfSlices, int);
00250 
00252 
00255   vtkSetMacro(SlabTrapezoidIntegration, int);
00256   vtkBooleanMacro(SlabTrapezoidIntegration, int);
00257   vtkGetMacro(SlabTrapezoidIntegration, int);
00259 
00261 
00263   vtkSetMacro(Optimization, int);
00264   vtkGetMacro(Optimization, int);
00265   vtkBooleanMacro(Optimization, int);
00267 
00269 
00270   vtkSetVector4Macro(BackgroundColor, double);
00271   vtkGetVector4Macro(BackgroundColor, double);
00273 
00275 
00276   void SetBackgroundLevel(double v) { this->SetBackgroundColor(v,v,v,v); };
00277   double GetBackgroundLevel() { return this->GetBackgroundColor()[0]; };
00279 
00281 
00283   virtual void SetOutputSpacing(double x, double y, double z);
00284   virtual void SetOutputSpacing(const double a[3]) {
00285     this->SetOutputSpacing(a[0], a[1], a[2]); };
00286   vtkGetVector3Macro(OutputSpacing, double);
00287   void SetOutputSpacingToDefault();
00289 
00291 
00293   virtual void SetOutputOrigin(double x, double y, double z);
00294   virtual void SetOutputOrigin(const double a[3]) {
00295     this->SetOutputOrigin(a[0], a[1], a[2]); };
00296   vtkGetVector3Macro(OutputOrigin, double);
00297   void SetOutputOriginToDefault();
00299 
00301 
00303   virtual void SetOutputExtent(int a, int b, int c, int d, int e, int f);
00304   virtual void SetOutputExtent(const int a[6]) {
00305     this->SetOutputExtent(a[0], a[1], a[2], a[3], a[4], a[5]); };
00306   vtkGetVector6Macro(OutputExtent, int);
00307   void SetOutputExtentToDefault();
00309 
00311 
00317   vtkSetMacro(OutputDimensionality, int);
00318   vtkGetMacro(OutputDimensionality, int);
00320 
00323   unsigned long int GetMTime();
00324 
00326   virtual void ReportReferences(vtkGarbageCollector*);
00327 
00329 
00334   void SetInterpolate(int t) {
00335     if (t && !this->GetInterpolate()) {
00336       this->SetInterpolationModeToLinear(); }
00337     else if (!t && this->GetInterpolate()) {
00338       this->SetInterpolationModeToNearestNeighbor(); } };
00339   void InterpolateOn() {
00340     this->SetInterpolate(1); };
00341   void InterpolateOff() {
00342     this->SetInterpolate(0); };
00343   int GetInterpolate() {
00344     return (this->GetInterpolationMode() != VTK_RESLICE_NEAREST); };
00346 
00348 
00351   void SetStencil(vtkImageStencilData *stencil);
00352   vtkImageStencilData *GetStencil();
00354 
00356 
00358   vtkSetMacro(GenerateStencilOutput, int);
00359   vtkGetMacro(GenerateStencilOutput, int);
00360   vtkBooleanMacro(GenerateStencilOutput, int);
00362 
00364 
00365   vtkAlgorithmOutput *GetStencilOutputPort() {
00366     return this->GetOutputPort(1); }
00367   vtkImageStencilData *GetStencilOutput();
00368   void SetStencilOutput(vtkImageStencilData *stencil);
00370 
00371 protected:
00372   vtkImageReslice();
00373   ~vtkImageReslice();
00374 
00375   vtkMatrix4x4 *ResliceAxes;
00376   double ResliceAxesDirectionCosines[9];
00377   double ResliceAxesOrigin[3];
00378   vtkAbstractTransform *ResliceTransform;
00379   vtkAbstractImageInterpolator *Interpolator;
00380   vtkImageData *InformationInput;
00381   int Wrap;
00382   int Mirror;
00383   int Border;
00384   int InterpolationMode;
00385   int Optimization;
00386   int SlabMode;
00387   int SlabNumberOfSlices;
00388   int SlabTrapezoidIntegration;
00389   double BackgroundColor[4];
00390   double OutputOrigin[3];
00391   double OutputSpacing[3];
00392   int OutputExtent[6];
00393   int OutputScalarType;
00394   int OutputDimensionality;
00395   int TransformInputSampling;
00396   int AutoCropOutput;
00397   int HitInputExtent;
00398   int UsePermuteExecute;
00399   int ComputeOutputSpacing;
00400   int ComputeOutputOrigin;
00401   int ComputeOutputExtent;
00402   int GenerateStencilOutput;
00403 
00404   vtkMatrix4x4 *IndexMatrix;
00405   vtkAbstractTransform *OptimizedTransform;
00406 
00409   int HasConvertScalars;
00410 
00413   virtual int ConvertScalarInfo(int &scalarType, int &numComponents);
00414 
00416 
00422   virtual void ConvertScalars(void *inPtr, void *outPtr,
00423                               int inputType, int inputNumComponents,
00424                               int count, int idX, int idY, int idZ,
00425                               int threadId);
00427 
00428   void ConvertScalarsBase(void *inPtr, void *outPtr,
00429                           int inputType, int inputNumComponents,
00430                           int count, int idX, int idY, int idZ, int threadId) {
00431     this->ConvertScalars(inPtr, outPtr, inputType, inputNumComponents,
00432                          count, idX, idY, idZ, threadId); }
00433 
00434   void GetAutoCroppedOutputBounds(vtkInformation *inInfo, double bounds[6]);
00435   virtual void AllocateOutputData(vtkImageData *output, int *uExtent);
00436   virtual vtkImageData *AllocateOutputData(vtkDataObject *);
00437   virtual int RequestInformation(vtkInformation *, vtkInformationVector **,
00438                                  vtkInformationVector *);
00439   virtual int RequestUpdateExtent(vtkInformation *, vtkInformationVector **,
00440                                   vtkInformationVector *);
00441   virtual int RequestData(vtkInformation *, vtkInformationVector **,
00442                           vtkInformationVector *);
00443   virtual void ThreadedRequestData(vtkInformation *request,
00444                                    vtkInformationVector **inputVector,
00445                                    vtkInformationVector *outputVector,
00446                                    vtkImageData ***inData,
00447                                    vtkImageData **outData, int ext[6], int id);
00448   virtual int FillInputPortInformation(int port, vtkInformation *info);
00449   virtual int FillOutputPortInformation(int port, vtkInformation *info);
00450 
00451   vtkMatrix4x4 *GetIndexMatrix(vtkInformation *inInfo,
00452                                vtkInformation *outInfo);
00453   vtkAbstractTransform *GetOptimizedTransform() {
00454     return this->OptimizedTransform; };
00455 
00456 private:
00457   vtkImageReslice(const vtkImageReslice&);  // Not implemented.
00458   void operator=(const vtkImageReslice&);  // Not implemented.
00459 };
00460 
00461 #endif