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