]> Creatis software - gdcm.git/blob - vtk/vtkGdcmReader.h
Add SetCoherentFileList() method, to use the 'file ordering' of
[gdcm.git] / vtk / vtkGdcmReader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: vtkGdcmReader.h,v $
5   Language:  C++
6   Date:      $Date: 2005/07/17 04:34:20 $
7   Version:   $Revision: 1.23 $
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 //-----------------------------------------------------------------------------
31 class vtkLookupTable;
32
33 //-----------------------------------------------------------------------------
34 class VTK_EXPORT vtkGdcmReader : public vtkImageReader
35 {
36 public:
37    static vtkGdcmReader *New();
38    vtkTypeRevisionMacro(vtkGdcmReader, vtkImageReader);
39    void PrintSelf(ostream& os, vtkIndent indent);
40
41    virtual void RemoveAllFileName(void);
42    virtual void AddFileName(const char *name);
43    virtual void SetFileName(const char *name);
44    void SetCoherentFileList( std::vector<gdcm::File* > *cfl) {
45                                                       CoherentFileList = cfl; };    
46    void SetCheckFileCoherenceLight();
47    
48    // Description:
49    // If this flag is set and the DICOM reader encounters a dicom file with 
50    // lookup table the data will be kept as unsigned chars and a lookuptable 
51    // will be exported and accessible through GetLookupTable() 
52    vtkSetMacro(AllowLookupTable, int);
53    vtkGetMacro(AllowLookupTable, int);
54    vtkBooleanMacro(AllowLookupTable, int);
55
56    vtkGetObjectMacro(LookupTable, vtkLookupTable);
57
58 /**
59  * \brief Sets the LoadMode as a boolean string. 
60  *        NO_SEQ, NO_SHADOW, NO_SHADOWSEQ... (nothing more, right now)
61  *        WARNING : before using NO_SHADOW, be sure *all* your files
62  *        contain accurate values in the 0x0000 element (if any) 
63  *        of *each* Shadow Group. The parser will fail if the size is wrong !
64  * @param   mode Load mode to be used    
65  */
66    void SetLoadMode (int mode) { LoadMode = mode; }
67
68 protected:
69    vtkGdcmReader();
70    ~vtkGdcmReader();
71
72    virtual void ExecuteInformation();
73    virtual void ExecuteData(vtkDataObject *output);
74    virtual void BuildFileListFromPattern();
75    virtual int CheckFileCoherence();
76    virtual int CheckFileCoherenceLight();
77    virtual int CheckFileCoherenceAlreadyDone();
78 private:
79    void RemoveAllInternalFileName(void);
80    void AddInternalFileName(const char* name);
81
82    //BTX
83    size_t LoadImageInMemory(std::string fileName, unsigned char *dest,
84                            const unsigned long updateProgressTarget,
85                            unsigned long &updateProgressCount);
86
87    size_t LoadImageInMemory(gdcm::File *f, unsigned char *dest,
88                            const unsigned long updateProgressTarget,
89                            unsigned long &updateProgressCount);
90
91    size_t DoTheLoadingJob (gdcm::File *f,
92                            unsigned char *dest,
93                            const unsigned long updateProgressTarget,
94                            unsigned long &updateProgressCount);
95    //ETX
96
97 // Variables
98    vtkLookupTable *LookupTable;
99    vtkTimeStamp fileTime;
100    int AllowLookupTable;
101    bool LightChecking;
102
103    //BTX
104    // Number of columns of the image/volume to be loaded
105    int NumColumns;
106    // Number of lines of the image/volume to be loaded
107    int NumLines;
108    // Total number of planes (or images) of the stack to be build.
109    int TotalNumberOfPlanes;
110    // Number of scalar components of the image to be loaded (1=monochrome 3=rgb)
111    int NumComponents;
112    // Type of the image[s]: 8/16/32 bits, signed/unsigned:
113    std::string ImageType;
114    // Pixel size (in number of bytes):
115    size_t PixelSize;
116    // List of filenames to be read in order to build a stack of images
117    // or volume. The order in the list shall be the order of the images.
118    std::list<std::string> FileNameList;
119
120    // List of filenames created in ExecuteInformation and used in
121    // ExecuteData.
122    // If FileNameList isn't empty, InternalFileNameList is a copy of
123    //    FileNameList
124    // Otherwise, InternalFileNameList correspond to the list of 
125    //    files patterned
126    std::list<std::string> InternalFileNameList;
127    std::vector<gdcm::File* > *CoherentFileList;
128   
129    //ETX
130
131    /// \brief Bit string integer (each one considered as a boolean)
132    ///        Bit 0 : Skip Sequences,    if possible
133    ///        Bit 1 : Skip Shadow Groups if possible
134   ///         Bit 2 : Skip Sequences inside a Shadow Group, if possible
135    ///        Probabely (?), some more to add
136    int LoadMode;
137
138 };
139
140 //-----------------------------------------------------------------------------
141 #endif
142