vtkGdcmReader.h

Go to the documentation of this file.
00001 /*=========================================================================
00002                                                                                 
00003   Program:   gdcm
00004   Module:    $RCSfile: vtkGdcmReader.h,v $
00005   Language:  C++
00006   Date:      $Date: 2007/07/13 08:17:22 $
00007   Version:   $Revision: 1.34 $
00008                                                                                 
00009   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
00010   l'Image). All rights reserved. See Doc/License.txt or
00011   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
00012                                                                                 
00013      This software is distributed WITHOUT ANY WARRANTY; without even
00014      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00015      PURPOSE.  See the above copyright notices for more information.
00016                                                                                 
00017 =========================================================================*/
00018                                                                                 
00019 #ifndef __vtkGdcmReader_h
00020 #define __vtkGdcmReader_h
00021 
00022 #include "gdcmCommon.h" // To avoid warnings concerning the std
00023 #include "gdcmFile.h"
00024 
00025 #include <vtkImageReader.h>
00026 #include <list>
00027 #include <string>
00028 #include <vector>
00029 
00030 typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, GDCM_NAME_SPACE::File *);
00031 
00032 //-----------------------------------------------------------------------------
00033 class vtkLookupTable;
00034 
00035 //-----------------------------------------------------------------------------
00036 class VTK_EXPORT vtkGdcmReader : public vtkImageReader
00037 {
00038 public:
00039    static vtkGdcmReader *New();
00040    vtkTypeRevisionMacro(vtkGdcmReader, vtkImageReader);
00041    void PrintSelf(ostream& os, vtkIndent indent);
00042 
00043    virtual void RemoveAllFileName(void);
00044    virtual void AddFileName(const char *name);
00045    virtual void SetFileName(const char *name);
00046 
00047    //BTX
00048    void SetCoherentFileList( std::vector<GDCM_NAME_SPACE::File* > *cfl) {
00049                                                       CoherentFileList = cfl; }    
00050    //ETX
00051 
00052    //vtkSetMacro(AllowLightChecking, bool);
00053    //vtkGetMacro(AllowLightChecking, bool);
00054    //vtkBooleanMacro(AllowLightChecking, bool);
00055 
00056    //BTX
00057    
00059    
00060    void SetUserFunction (VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc )
00061                         { UserFunction = userFunc; } 
00062    //ETX
00063   
00064    // Description:
00065    // If this flag is set and the DICOM reader encounters a dicom file with 
00066    // lookup table the data will be kept as unsigned chars and a lookuptable 
00067    // will be exported and accessible through GetLookupTable() 
00068    vtkSetMacro(AllowLookupTable, bool);
00069    vtkGetMacro(AllowLookupTable, bool);
00070    vtkBooleanMacro(AllowLookupTable, bool);
00071 
00072    vtkGetObjectMacro(LookupTable, vtkLookupTable);
00073 
00074 // FIXME : HOW to doxygen a VTK macro?
00075 /*
00076  * \ brief Sets the LoadMode as a boolean string. 
00077  *        gdcm.LD_NOSEQ, gdcm.LD_NOSHADOW, gdcm.LD_NOSHADOWSEQ... 
00078  *        (nothing more, right now)
00079  *        WARNING : before using NO_SHADOW, be sure *all* your files
00080  *        contain accurate values in the 0x0000 element (if any) 
00081  *        of *each* Shadow Group. The parser will fail if the size is wrong !
00082  * @param   mode Load mode to be used    
00083  */
00084    vtkSetMacro(LoadMode, int);
00085    vtkGetMacro(LoadMode, int);
00086    vtkBooleanMacro(LoadMode, int);
00087  
00088 /*
00089  * \ brief drop images with duplicate position  
00090  *         and therefore calculate ZSpacing for the whole file set
00091  * @param   mode user wants to drop images with duplicate position    
00092  */   
00093    vtkSetMacro(DropDuplicatePositions, bool);
00094    vtkGetMacro(DropDuplicatePositions, bool);
00095    vtkBooleanMacro(DropDuplicatePositions, bool);      
00096 
00097 protected:
00098    vtkGdcmReader();
00099    ~vtkGdcmReader();
00100 
00101    virtual void ExecuteInformation();
00102    virtual void ExecuteData(vtkDataObject *output);
00103 
00104    //virtual void BuildData(vtkDataObject *output); // for VTK5.0
00105    virtual void BuildFileListFromPattern();
00106    virtual void LoadFileInformation();
00107    virtual void UpdateFileInformation();
00108    //BTX
00109    virtual void GetFileInformation(GDCM_NAME_SPACE::File *file);
00110    virtual bool TestFileInformation(GDCM_NAME_SPACE::File *file);
00111    //ETX
00112 
00113 private:
00114    void RemoveAllInternalFileName(void);
00115    void AddInternalFileName(const char *name);
00116    void RemoveAllInternalFile(void);
00117 
00118    //BTX
00119    void IncrementProgress(const unsigned long updateProgressTarget,
00120                           unsigned long &updateProgressCount);
00121    /*void LoadImageInMemory(std::string fileName, unsigned char *dest,
00122                           const unsigned long updateProgressTarget,
00123                           unsigned long &updateProgressCount);*/
00124 
00125    void LoadImageInMemory(GDCM_NAME_SPACE::File *f, unsigned char *dest,
00126                           const unsigned long updateProgressTarget,
00127                           unsigned long &updateProgressCount);
00128    //ETX
00129 
00130 // Variables
00131    //BTX
00132    typedef std::vector<GDCM_NAME_SPACE::File *> gdcmFileList;
00133    //ETX
00134 
00135    vtkLookupTable *LookupTable;
00136    vtkTimeStamp fileTime;
00137 
00138    bool AllowLookupTable;
00139    bool AllowLightChecking;
00140 
00141    //BTX
00142    // Number of columns of the image/volume to be loaded
00143    int NumColumns;
00144    // Number of lines of the image/volume to be loaded
00145    int NumLines;
00146    // Number of lines of the image/volume to be loaded
00147    int NumPlanes;
00148    // Total number of planes (or images) of the stack to be build.
00149    int TotalNumberOfPlanes;
00150    // Number of scalar components of the image to be loaded (1=monochrome 3=rgb)
00151    int NumComponents;
00152    // Type of the image[s]: 8/16/32 bits, signed/unsigned:
00153    std::string ImageType;
00154    // Pixel size (in number of bytes):
00155    size_t PixelSize;
00156    // List of filenames to be read in order to build a stack of images
00157    // or volume. The order in the list shall be the order of the images.
00158    std::list<std::string> FileNameList;
00159    gdcmFileList *CoherentFileList;
00160    bool OwnFile;
00161 
00162    // List of filenames created in ExecuteInformation and used in
00163    // ExecuteData.
00164    // If FileNameList isn't empty, InternalFileNameList is a copy of
00165    //    FileNameList
00166    // Otherwise, InternalFileNameList correspond to the list of 
00167    //    files patterned
00168    std::list<std::string> InternalFileNameList;
00169    gdcmFileList InternalFileList;
00170    //bool Execution;  // For VTK5.0
00171   
00172    //ETX
00173 
00179    int LoadMode;
00180     
00181    bool DropDuplicatePositions;
00182    
00184    VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
00185 
00186 };
00187 
00188 //-----------------------------------------------------------------------------
00189 #endif
00190 

Generated on Fri Aug 24 12:53:20 2007 for gdcm by  doxygen 1.4.6