]> Creatis software - gdcm.git/blob - vtk/vtkGdcmReader.h
Add macro to use DropDuplicatePositions directly
[gdcm.git] / vtk / vtkGdcmReader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: vtkGdcmReader.h,v $
5   Language:  C++
6   Date:      $Date: 2007/06/08 12:43:19 $
7   Version:   $Revision: 1.32 $
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::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::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    vtkSetMacro(AllowLookupTable, bool);
69    vtkGetMacro(AllowLookupTable, bool);
70    vtkBooleanMacro(AllowLookupTable, bool);
71
72    vtkGetObjectMacro(LookupTable, vtkLookupTable);
73
74 // FIXME : HOW to doxygen a VTK macro?
75 /*
76  * \ brief Sets the LoadMode as a boolean string. 
77  *        gdcm.LD_NOSEQ, gdcm.LD_NOSHADOW, gdcm.LD_NOSHADOWSEQ... 
78  *        (nothing more, right now)
79  *        WARNING : before using NO_SHADOW, be sure *all* your files
80  *        contain accurate values in the 0x0000 element (if any) 
81  *        of *each* Shadow Group. The parser will fail if the size is wrong !
82  * @param   mode Load mode to be used    
83  */
84    vtkSetMacro(LoadMode, int);
85    vtkGetMacro(LoadMode, int);
86    vtkBooleanMacro(LoadMode, int);
87  
88 /*
89  * \ brief drop images with duplicate position  
90  *         and therefore calculate ZSpacing for the whole file set
91  * @param   mode user wants to drop images with duplicate position    
92  */   
93    vtkSetMacro(DropDuplicatePositions, bool);
94    vtkGetMacro(DropDuplicatePositions, bool);
95    vtkBooleanMacro(DropDuplicatePositions, bool);      
96
97 protected:
98    vtkGdcmReader();
99    ~vtkGdcmReader();
100
101    virtual void ExecuteInformation();
102    virtual void ExecuteData(vtkDataObject *output);
103
104    //virtual void BuildData(vtkDataObject *output); // for VTK5.0
105    virtual void BuildFileListFromPattern();
106    virtual void LoadFileInformation();
107    virtual void UpdateFileInformation();
108    //BTX
109    virtual void GetFileInformation(gdcm::File *file);
110    virtual bool TestFileInformation(gdcm::File *file);
111    //ETX
112
113 private:
114    void RemoveAllInternalFileName(void);
115    void AddInternalFileName(const char *name);
116    void RemoveAllInternalFile(void);
117
118    //BTX
119    void IncrementProgress(const unsigned long updateProgressTarget,
120                           unsigned long &updateProgressCount);
121    /*void LoadImageInMemory(std::string fileName, unsigned char *dest,
122                           const unsigned long updateProgressTarget,
123                           unsigned long &updateProgressCount);*/
124
125    void LoadImageInMemory(gdcm::File *f, unsigned char *dest,
126                           const unsigned long updateProgressTarget,
127                           unsigned long &updateProgressCount);
128    //ETX
129
130 // Variables
131    //BTX
132    typedef std::vector<gdcm::File *> gdcmFileList;
133    //ETX
134
135    vtkLookupTable *LookupTable;
136    vtkTimeStamp fileTime;
137
138    bool AllowLookupTable;
139    bool AllowLightChecking;
140
141    //BTX
142    // Number of columns of the image/volume to be loaded
143    int NumColumns;
144    // Number of lines of the image/volume to be loaded
145    int NumLines;
146    // Number of lines of the image/volume to be loaded
147    int NumPlanes;
148    // Total number of planes (or images) of the stack to be build.
149    int TotalNumberOfPlanes;
150    // Number of scalar components of the image to be loaded (1=monochrome 3=rgb)
151    int NumComponents;
152    // Type of the image[s]: 8/16/32 bits, signed/unsigned:
153    std::string ImageType;
154    // Pixel size (in number of bytes):
155    size_t PixelSize;
156    // List of filenames to be read in order to build a stack of images
157    // or volume. The order in the list shall be the order of the images.
158    std::list<std::string> FileNameList;
159    gdcmFileList *CoherentFileList;
160    bool OwnFile;
161
162    // List of filenames created in ExecuteInformation and used in
163    // ExecuteData.
164    // If FileNameList isn't empty, InternalFileNameList is a copy of
165    //    FileNameList
166    // Otherwise, InternalFileNameList correspond to the list of 
167    //    files patterned
168    std::list<std::string> InternalFileNameList;
169    gdcmFileList InternalFileList;
170    //bool Execution;  // For VTK5.0
171   
172    //ETX
173
174    /// \brief Bit string integer (each one considered as a boolean)
175    ///        Bit 0 : Skip Sequences,    if possible
176    ///        Bit 1 : Skip Shadow Groups if possible
177    ///        Bit 2 : Skip Sequences inside a Shadow Group, if possible
178    ///        Probabely (?), some more to add
179    int LoadMode;
180     
181    bool DropDuplicatePositions;
182    
183    /// Pointer to a user suplied function to allow modification of pixel order
184    VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
185
186 };
187
188 //-----------------------------------------------------------------------------
189 #endif
190