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