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