# 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-2010 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
    00049 class vtkStringArray;
    00050 class VTK_EXPORT vtkGDCMThreadedImageReader2 : public vtkThreadedImageAlgorithm
    00051 {
    00052 public:
    00053   static vtkGDCMThreadedImageReader2 *New();
    00054   vtkTypeRevisionMacro(vtkGDCMThreadedImageReader2,vtkThreadedImageAlgorithm);
    00055   virtual void PrintSelf(ostream& os, vtkIndent indent);
    00056
    00057   vtkGetMacro(FileLowerLeft,int);
    00058   vtkSetMacro(FileLowerLeft,int);
    00059   vtkBooleanMacro(FileLowerLeft,int);
    00060
    00061   vtkGetMacro(NumberOfOverlays,int);
    00062
    00063   vtkSetMacro(DataScalarType,int);
    00064   vtkGetMacro(DataScalarType,int);
    00065
    00066   vtkSetMacro(NumberOfScalarComponents,int);
    00067   vtkGetMacro(NumberOfScalarComponents,int);
    00068
    00069   vtkGetMacro(LoadOverlays,int);
    00070   vtkSetMacro(LoadOverlays,int);
    00071   vtkBooleanMacro(LoadOverlays,int);
    00072
    00073   vtkSetVector6Macro(DataExtent,int);
    00074   vtkGetVector6Macro(DataExtent,int);
    00075
    00076   vtkSetVector3Macro(DataOrigin,double);
    00077   vtkGetVector3Macro(DataOrigin,double);
    00078
    00079   vtkSetVector3Macro(DataSpacing,double);
    00080   vtkGetVector3Macro(DataSpacing,double);
    00081
    00082   //vtkGetStringMacro(FileName);
    00083   //vtkSetStringMacro(FileName);
    00084   virtual const char *GetFileName(int i = 0);
    00085   virtual void SetFileName(const char *filename);
    00086
    00087   virtual void SetFileNames(vtkStringArray*);
    00088   vtkGetObjectMacro(FileNames, vtkStringArray);
    00089
    00090   int SplitExtent(int splitExt[6], int startExt[6],
    00091                   int num, int total);
    00092
    00093   // Description:
    00094   // Explicitely set the Rescale Intercept (0028,1052)
    00095   vtkSetMacro(Shift,double);
    00096   vtkGetMacro(Shift,double);
    00097
    00098   // Description:
    00099   // Explicitely get/set the Rescale Slope (0028,1053)
    00100   vtkSetMacro(Scale,double);
    00101   vtkGetMacro(Scale,double);
    00102
    00103   // Description:
    00104   // Determine whether or not reader should use value from Shift/Scale
    00105   // Default is 1
    00106   vtkSetMacro(UseShiftScale,int);
    00107   vtkGetMacro(UseShiftScale,int);
    00108   vtkBooleanMacro(UseShiftScale,int);
    00109
    00110 protected:
    00111   vtkGDCMThreadedImageReader2();
    00112   ~vtkGDCMThreadedImageReader2();
    00113
    00114   int RequestInformation(vtkInformation *request,
    00115                          vtkInformationVector **inputVector,
    00116                          vtkInformationVector *outputVector);
    00117
    00118 protected:
    00119   void ThreadedRequestData (
    00120     vtkInformation * request,
    00121     vtkInformationVector** inputVector,
    00122     vtkInformationVector * outputVector,
    00123     vtkImageData ***inData,
    00124     vtkImageData **outData,
    00125     int outExt[6], int id);
    00126
    00127 private:
    00128   int FileLowerLeft;
    00129   char *FileName;
    00130   vtkStringArray *FileNames;
    00131   int LoadIconImage;
    00132   int DataExtent[6];
    00133   int LoadOverlays;
    00134   int NumberOfOverlays;
    00135   int DataScalarType;
    00136
    00137   int NumberOfScalarComponents;
    00138   double DataSpacing[3];
    00139   double DataOrigin[3];
    00140   int IconImageDataExtent[6];
    00141
    00142   double Shift;
    00143   double Scale;
    00144   int UseShiftScale;
    00145
    00146 private:
    00147   vtkGDCMThreadedImageReader2(const vtkGDCMThreadedImageReader2&);  // Not implemented.
    00148   void operator=(const vtkGDCMThreadedImageReader2&);  // Not implemented.
    00149 };
    00150
    00151 #endif