]> Creatis software - gdcm.git/blob - vtk/vtkGdcmReader.h
upgrades for 4DSplitter
[gdcm.git] / vtk / vtkGdcmReader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: vtkGdcmReader.h,v $
5   Language:  C++
6   Date:      $Date: 2011/03/29 07:36:02 $
7   Version:   $Revision: 1.39 $
8                                                                                 
9   Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de
10   l'Image). All rights reserved. See Doc/License.txt or
11   http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details.
12                                                                                 
13      This software is distributed WITHOUT ANY WARRANTY; without even
14      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15      PURPOSE.  See the above copyright notices for more information.
16                                                                                 
17 =========================================================================*/
18                                                                                 
19 #ifndef __vtkGdcmReader_h
20 #define __vtkGdcmReader_h
21
22 #include "gdcmCommon.h" // To avoid warnings concerning the std
23 #include "gdcmFile.h"
24
25 #include <vtkImageReader.h>
26 #include <list>
27 #include <string>
28 #include <vector>
29
30 typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, GDCM_NAME_SPACE::File *);
31
32 //-----------------------------------------------------------------------------
33 class vtkLookupTable;
34
35 //-----------------------------------------------------------------------------
36 class VTK_EXPORT vtkGdcmReader : public vtkImageReader
37 {
38 public:
39    static vtkGdcmReader *New();
40    vtkTypeRevisionMacro(vtkGdcmReader, vtkImageReader);
41    void PrintSelf(ostream& os, vtkIndent indent);
42
43    virtual void RemoveAllFileName(void);
44    virtual void AddFileName(const char *name);
45    virtual void SetFileName(const char *name);
46
47    //BTX
48    void SetCoherentFileList( std::vector<GDCM_NAME_SPACE::File* > *cfl) {
49                                                       CoherentFileList = cfl; }    
50    //ETX
51
52    //vtkSetMacro(AllowLightChecking, bool);
53    //vtkGetMacro(AllowLightChecking, bool);
54    //vtkBooleanMacro(AllowLightChecking, bool);
55
56    //BTX
57    
58    /// \todo fix possible problems around VTK pipelining
59    
60    void SetUserFunction (VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc )
61                         { UserFunction = userFunc; } 
62    //ETX
63   
64    // Description:
65    // If this flag is set and the DICOM reader encounters a dicom file with 
66    // lookup table the data will be kept as unsigned chars and a lookuptable 
67    // will be exported and accessible through GetLookupTable()
68
69    vtkSetMacro(AllowLookupTable, bool);
70    vtkGetMacro(AllowLookupTable, bool);
71    vtkBooleanMacro(AllowLookupTable, bool);
72
73    vtkSetMacro(KeepOverlays, bool);
74    vtkGetMacro(KeepOverlays, bool);
75    vtkBooleanMacro(KeepOverlays, bool);
76
77 //  Implementation note: when FileLowerLeft (gdcm2) is set to on the image is not flipped
78 // upside down as VTK would expect, use this option only if you know what you are doing.   
79   // vtkSetMacro(FileLowerLeft, bool);
80   // vtkGetMacro(FileLowerLeft, bool);
81   // vtkBooleanMacro(FileLowerLeft, bool);
82
83   vtkSetMacro(FlipY, bool);
84   vtkGetMacro(FlipY, bool);
85   vtkBooleanMacro(FlipY, bool);
86
87    vtkGetObjectMacro(LookupTable, vtkLookupTable);
88
89 // FIXME : HOW to doxygen a VTK macro?
90 /*
91  * \ brief Sets the LoadMode as a boolean string. 
92  *        gdcm.LD_NOSEQ, gdcm.LD_NOSHADOW, gdcm.LD_NOSHADOWSEQ... 
93  *        (nothing more, right now)
94  *        WARNING : before using NO_SHADOW, be sure *all* your files
95  *        contain accurate values in the 0x0000 element (if any) 
96  *        of *each* Shadow Group. The parser will fail if the size is wrong !
97  * @param   mode Load mode to be used    
98  */
99    vtkSetMacro(LoadMode, int);
100    vtkGetMacro(LoadMode, int);
101    vtkBooleanMacro(LoadMode, int);
102  
103 /*
104  * \ brief drop images with duplicate position  
105  *         and therefore calculate ZSpacing for the whole file set
106  * @param   mode user wants to drop images with duplicate position    
107  */   
108    vtkSetMacro(DropDuplicatePositions, bool);
109    vtkGetMacro(DropDuplicatePositions, bool);
110    vtkBooleanMacro(DropDuplicatePositions, bool);      
111
112 protected:
113    vtkGdcmReader();
114    ~vtkGdcmReader();
115
116    virtual void ExecuteInformation();
117    virtual void ExecuteData(vtkDataObject *output);
118
119    //virtual void BuildData(vtkDataObject *output); // for VTK5.0
120    virtual void BuildFileListFromPattern();
121    virtual void LoadFileInformation();
122    virtual void UpdateFileInformation();
123    //BTX
124    virtual void GetFileInformation(GDCM_NAME_SPACE::File *file);
125    virtual bool TestFileInformation(GDCM_NAME_SPACE::File *file);
126    //ETX
127
128 private:
129    void RemoveAllInternalFileName(void);
130    void AddInternalFileName(const char *name);
131    void RemoveAllInternalFile(void);
132
133    //BTX
134    void IncrementProgress(const unsigned long updateProgressTarget,
135                           unsigned long &updateProgressCount);
136    /*void LoadImageInMemory(std::string fileName, unsigned char *dest,
137                           const unsigned long updateProgressTarget,
138                           unsigned long &updateProgressCount);*/
139
140    void LoadImageInMemory(GDCM_NAME_SPACE::File *f, unsigned char *dest,
141                           const unsigned long updateProgressTarget,
142                           unsigned long &updateProgressCount);
143    //ETX
144
145 // Variables
146    //BTX
147    typedef std::vector<GDCM_NAME_SPACE::File *> gdcmFileList;
148    //ETX
149
150    vtkLookupTable *LookupTable;
151    vtkTimeStamp fileTime;
152
153    bool AllowLookupTable;
154    bool AllowLightChecking;
155
156    //BTX
157    // Number of columns of the image/volume to be loaded
158    int NumColumns;
159    // Number of lines of the image/volume to be loaded
160    int NumLines;
161    // Number of lines of the image/volume to be loaded
162    int NumPlanes;
163    // Total number of planes (or images) of the stack to be build.
164    int TotalNumberOfPlanes;
165    // Number of scalar components of the image to be loaded (1=monochrome 3=rgb)
166    int NumComponents;
167    // Type of the image[s]: 8/16/32 bits, signed/unsigned:
168    std::string ImageType;
169    // Pixel size (in number of bytes):
170    size_t PixelSize;
171    // List of filenames to be read in order to build a stack of images
172    // or volume. The order in the list shall be the order of the images.
173    std::list<std::string> FileNameList;
174    gdcmFileList *CoherentFileList;
175    bool OwnFile;
176
177    // List of filenames created in ExecuteInformation and used in
178    // ExecuteData.
179    // If FileNameList isn't empty, InternalFileNameList is a copy of
180    //    FileNameList
181    // Otherwise, InternalFileNameList correspond to the list of 
182    //    files patterned
183    std::list<std::string> InternalFileNameList;
184    gdcmFileList InternalFileList;
185    //bool Execution;  // For VTK5.0
186   
187    //ETX
188
189    /// \brief Bit string integer (each one considered as a boolean)
190    ///        Bit 0 : Skip Sequences,    if possible
191    ///        Bit 1 : Skip Shadow Groups if possible
192    ///        Bit 2 : Skip Sequences inside a Shadow Group, if possible
193    ///        Probabely (?), some more to add
194    int LoadMode;
195     
196    bool DropDuplicatePositions;
197    
198    bool KeepOverlays;
199    
200   // bool FileLowerLeft;
201    bool FlipY;
202
203    /// Pointer to a user suplied function to allow modification of pixel order
204    VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
205
206 };
207
208 //-----------------------------------------------------------------------------
209 #endif
210