1 /*=========================================================================
4 Module: $RCSfile: vtkGdcmReader.h,v $
6 Date: $Date: 2011/09/20 16:09:05 $
7 Version: $Revision: 1.41 $
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.
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.
17 ==========================================================================*/
18 #ifndef __vtkGdcmReader_h
19 #define __vtkGdcmReader_h
21 #include "gdcmCommon.h" // To avoid warnings concerning the std
24 #include <vtkImageReader.h>
29 typedef void (*VOID_FUNCTION_PUINT8_PFILE_POINTER)(uint8_t *, GDCM_NAME_SPACE::File *);
31 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
35 class VTK_EXPORT vtkGdcmReader : public vtkImageReader
38 static vtkGdcmReader *New();
39 vtkTypeRevisionMacro(vtkGdcmReader, vtkImageReader);
40 void PrintSelf(ostream& os, vtkIndent indent);
42 virtual void RemoveAllFileName(void);
43 virtual void AddFileName(const char *name);
44 virtual void SetFileName(const char *name);
47 void SetCoherentFileList( std::vector<GDCM_NAME_SPACE::File* > *cfl) {
48 CoherentFileList = cfl; }
51 //vtkSetMacro(AllowLightChecking, bool);
52 //vtkGetMacro(AllowLightChecking, bool);
53 //vtkBooleanMacro(AllowLightChecking, bool);
57 /// \todo fix possible problems around VTK pipelining
59 void SetUserFunction (VOID_FUNCTION_PUINT8_PFILE_POINTER userFunc )
60 { UserFunction = userFunc; }
64 // If this flag is set and the DICOM reader encounters a dicom file with
65 // lookup table the data will be kept as unsigned chars and a lookuptable
66 // will be exported and accessible through GetLookupTable()
68 vtkSetMacro(AllowLookupTable, bool);
69 vtkGetMacro(AllowLookupTable, bool);
70 vtkBooleanMacro(AllowLookupTable, bool);
72 vtkSetMacro(KeepOverlays, bool);
73 vtkGetMacro(KeepOverlays, bool);
74 vtkBooleanMacro(KeepOverlays, bool);
76 // Implementation note: when FileLowerLeft (gdcm2) is set to on, the image is not flipped
77 // upside down as VTK would expect, use this option only if you know what you are doing.
78 // vtkSetMacro(FileLowerLeft, bool);
79 // vtkGetMacro(FileLowerLeft, bool);
80 // vtkBooleanMacro(FileLowerLeft, bool);
82 vtkSetMacro(FlipY, bool);
83 vtkGetMacro(FlipY, bool);
84 vtkBooleanMacro(FlipY, bool);
86 vtkGetObjectMacro(LookupTable, vtkLookupTable);
88 // FIXME : HOW to doxygen a VTK macro?
90 * \ brief Sets the LoadMode as a boolean string.
91 * gdcm.LD_NOSEQ, gdcm.LD_NOSHADOW, gdcm.LD_NOSHADOWSEQ...
92 * (nothing more, right now)
93 * WARNING : before using NO_SHADOW, be sure *all* your files
94 * contain accurate values in the 0x0000 element (if any)
95 * of *each* Shadow Group. The parser will fail if the size is wrong !
96 * @param mode Load mode to be used
98 vtkSetMacro(LoadMode, int);
99 vtkGetMacro(LoadMode, int);
100 vtkBooleanMacro(LoadMode, int);
103 * \ brief drop images with duplicate position
104 * and therefore calculate ZSpacing for the whole file set
105 * @param mode user wants to drop images with duplicate position
107 vtkSetMacro(DropDuplicatePositions, bool);
108 vtkGetMacro(DropDuplicatePositions, bool);
109 vtkBooleanMacro(DropDuplicatePositions, bool);
115 virtual void ExecuteInformation();
116 virtual void ExecuteData(vtkDataObject *output);
118 //virtual void BuildData(vtkDataObject *output); // for VTK5.0
119 virtual void BuildFileListFromPattern();
120 virtual void LoadFileInformation();
121 virtual void UpdateFileInformation();
123 virtual void GetFileInformation(GDCM_NAME_SPACE::File *file);
124 virtual bool TestFileInformation(GDCM_NAME_SPACE::File *file);
128 void RemoveAllInternalFileName(void);
129 void AddInternalFileName(const char *name);
130 void RemoveAllInternalFile(void);
133 void IncrementProgress(const unsigned long updateProgressTarget,
134 unsigned long &updateProgressCount);
135 /*void LoadImageInMemory(std::string fileName, unsigned char *dest,
136 const unsigned long updateProgressTarget,
137 unsigned long &updateProgressCount);*/
139 void LoadImageInMemory(GDCM_NAME_SPACE::File *f, unsigned char *dest,
140 const unsigned long updateProgressTarget,
141 unsigned long &updateProgressCount);
146 typedef std::vector<GDCM_NAME_SPACE::File *> gdcmFileList;
149 vtkLookupTable *LookupTable;
150 vtkTimeStamp fileTime;
152 bool AllowLookupTable;
153 bool AllowLightChecking;
156 // Number of columns of the image/volume to be loaded
158 // Number of lines of the image/volume to be loaded
160 // Number of lines of the image/volume to be loaded
162 // Total number of planes (or images) of the stack to be build.
163 int TotalNumberOfPlanes;
164 // Number of scalar components of the image to be loaded (1=monochrome 3=rgb)
166 // Type of the image[s]: 8/16/32 bits, signed/unsigned:
167 std::string ImageType;
168 // Pixel size (in number of bytes):
170 // List of filenames to be read in order to build a stack of images
171 // or volume. The order in the list shall be the order of the images.
172 std::list<std::string> FileNameList;
173 gdcmFileList *CoherentFileList;
176 // List of filenames created in ExecuteInformation and used in
178 // If FileNameList isn't empty, InternalFileNameList is a copy of
180 // Otherwise, InternalFileNameList correspond to the list of
182 std::list<std::string> InternalFileNameList;
183 gdcmFileList InternalFileList;
184 //bool Execution; // For VTK5.0
188 /// \brief Bit string integer (each one considered as a boolean)
189 /// Bit 0 : Skip Sequences, if possible
190 /// Bit 1 : Skip Shadow Groups if possible
191 /// Bit 2 : Skip Sequences inside a Shadow Group, if possible
192 /// Probabely (?), some more to add
195 bool DropDuplicatePositions;
199 // bool FileLowerLeft;
202 /// Pointer to a user suplied function to allow modification of pixel order
203 VOID_FUNCTION_PUINT8_PFILE_POINTER UserFunction;
207 //-----------------------------------------------------------------------------