# vtkGDCMThreadedImageReader2.h

Go to the documentation of this file.

    00001 /*=========================================================================
    00002
    00003   Program: GDCM (Grassroots DICOM). A DICOM library
    00004   Module:  $URL$
    00005
    00006   Copyright (c) 2006-2009 Mathieu Malaterre
    00007   All rights reserved.
    00008   See Copyright.txt or http://gdcm.sourceforge.net/Copyright.html 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 =========================================================================*/
    00015 // .NAME vtkGDCMThreadedImageReader2 - read DICOM files with multiple threads
    00016 // .SECTION Description
    00017 // vtkGDCMThreadedImageReader2 is a source object that reads some DICOM files
    00018 // This reader is threaded. Meaning that on a multiple core CPU with N cpu, it will
    00019 // read approx N times faster than when reading in a single thread assuming the IO is
    00020 // not a bottleneck operation.
    00021 // If looking for a single threaded class see: vtkGDCMImageReader
    00022 //
    00023 // .SECTION Warning: Advanced users only. Do not use this class in the general case,
    00024 // you have to understand how physicaly medium works first (sequencial reading for
    00025 // instance) before playing with this class
    00026 //
    00027 // .SECTION Implementation note: when FileLowerLeft is set to on the image is not flipped
    00028 // upside down as VTK would expect, use this option only if you know what you are doing
    00029 //
    00030 // .SECTION FIXME: need to implement the other mode where FileLowerLeft is set to OFF
    00031 //
    00032 // .SECTION FIXME: need to implement reading of series of 3D files
    00033 //
    00034 // .SECTION Implementation note: this class is meant to superseed vtkGDCMThreadedImageReader
    00035 // because it had support for ProgressEvent support even from python layer. There is a
    00036 // subtle trick down in the threading mechanism in VTK were the main thread (talking to the
    00037 // python interpreter) is also part of the execution process (and the N-1 other thread
    00038 // are just there to execute the remaining of ThreadedRequestData), this separation into
    00039 // two types of thread is necessary to acheive a working implementation of UpdateProgress
    00040
    00041 // .SECTION See Also
    00042 // vtkMedicalImageReader2 vtkMedicalImageProperties vtkGDCMImageReader
    00043
    00044 #ifndef __vtkGDCMThreadedImageReader2_h
    00045 #define __vtkGDCMThreadedImageReader2_h
    00046
    00047 #include "vtkThreadedImageAlgorithm.h"
    00048 #include "gdcmTypes.h" // GDCM_EXPORT
    00049
    00050 class vtkStringArray;
    00051 class GDCM_EXPORT vtkGDCMThreadedImageReader2 : public vtkThreadedImageAlgorithm
    00052 {
    00053 public:
    00054   static vtkGDCMThreadedImageReader2 *New();
    00055   vtkTypeRevisionMacro(vtkGDCMThreadedImageReader2,vtkThreadedImageAlgorithm);
    00056   virtual void PrintSelf(ostream& os, vtkIndent indent);
    00057
    00058   vtkGetMacro(FileLowerLeft,int);
    00059   vtkSetMacro(FileLowerLeft,int);
    00060   vtkBooleanMacro(FileLowerLeft,int);
    00061
    00062   vtkGetMacro(NumberOfOverlays,int);
    00063
    00064   vtkSetMacro(DataScalarType,int);
    00065   vtkGetMacro(DataScalarType,int);
    00066
    00067   vtkSetMacro(NumberOfScalarComponents,int);
    00068   vtkGetMacro(NumberOfScalarComponents,int);
    00069
    00070   vtkGetMacro(LoadOverlays,int);
    00071   vtkSetMacro(LoadOverlays,int);
    00072   vtkBooleanMacro(LoadOverlays,int);
    00073
    00074   vtkSetVector6Macro(DataExtent,int);
    00075   vtkGetVector6Macro(DataExtent,int);
    00076
    00077   vtkSetVector3Macro(DataOrigin,double);
    00078   vtkGetVector3Macro(DataOrigin,double);
    00079
    00080   vtkSetVector3Macro(DataSpacing,double);
    00081   vtkGetVector3Macro(DataSpacing,double);
    00082
    00083   //vtkGetStringMacro(FileName);
    00084   //vtkSetStringMacro(FileName);
    00085   virtual const char *GetFileName(int i = 0);
    00086   virtual void SetFileName(const char *filename);
    00087
    00088   virtual void SetFileNames(vtkStringArray*);
    00089   vtkGetObjectMacro(FileNames, vtkStringArray);
    00090
    00091   int SplitExtent(int splitExt[6], int startExt[6],
    00092                   int num, int total);
    00093
    00094   // Description:
    00095   // Explicitely set the Rescale Intercept (0028,1052)
    00096   vtkSetMacro(Shift,double);
    00097   vtkGetMacro(Shift,double);
    00098
    00099   // Description:
    00100   // Explicitely get/set the Rescale Slope (0028,1053)
    00101   vtkSetMacro(Scale,double);
    00102   vtkGetMacro(Scale,double);
    00103
    00104   // Description:
    00105   // Determine whether or not reader should use value from Shift/Scale
    00106   // Default is 1
    00107   vtkSetMacro(UseShiftScale,int);
    00108   vtkGetMacro(UseShiftScale,int);
    00109   vtkBooleanMacro(UseShiftScale,int);
    00110
    00111 protected:
    00112   vtkGDCMThreadedImageReader2();
    00113   ~vtkGDCMThreadedImageReader2();
    00114
    00115   int RequestInformation(vtkInformation *request,
    00116                          vtkInformationVector **inputVector,
    00117                          vtkInformationVector *outputVector);
    00118
    00119 protected:
    00120   void ThreadedRequestData (
    00121     vtkInformation * request,
    00122     vtkInformationVector** inputVector,
    00123     vtkInformationVector * outputVector,
    00124     vtkImageData ***inData,
    00125     vtkImageData **outData,
    00126     int outExt[6], int id);
    00127
    00128 private:
    00129   int FileLowerLeft;
    00130   char *FileName;
    00131   vtkStringArray *FileNames;
    00132   int LoadIconImage;
    00133   int DataExtent[6];
    00134   int LoadOverlays;
    00135   int NumberOfOverlays;
    00136   int DataScalarType;
    00137
    00138   int NumberOfScalarComponents;
    00139   double DataSpacing[3];
    00140   double DataOrigin[3];
    00141   int IconImageDataExtent[6];
    00142
    00143   double Shift;
    00144   double Scale;
    00145   int UseShiftScale;
    00146
    00147 private:
    00148   vtkGDCMThreadedImageReader2(const vtkGDCMThreadedImageReader2&);  // Not implemented.
    00149   void operator=(const vtkGDCMThreadedImageReader2&);  // Not implemented.
    00150 };
    00151
    00152 #endif