1 /*=========================================================================
4 Module: $RCSfile: gdcmFileHelper.h,v $
6 Date: $Date: 2005/07/19 15:19:27 $
7 Version: $Revision: 1.19 $
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 =========================================================================*/
19 #ifndef GDCMFILEHELPER_H
20 #define GDCMFILEHELPER_H
22 #include "gdcmDebug.h"
32 class PixelReadConvert;
33 class PixelWriteConvert;
34 class DocEntryArchive;
35 //-----------------------------------------------------------------------------
37 * \brief In addition to Dicom header exploration, this class is designed
38 * for accessing the image/volume content. One can also use it to
39 * write Dicom/ACR-NEMA/RAW files.
41 class GDCM_EXPORT FileHelper : public Base
52 FileHelper( File *header );
53 GDCM_LEGACY(FileHelper( std::string const &filename ));
55 virtual ~FileHelper();
57 void Print(std::ostream &os = std::cout, std::string const &indent = "");
59 /// Accessor to \ref File
60 File *GetFile() { return FileInternal; }
63 void SetLoadMode(int loadMode);
64 void SetFileName(std::string const &fileName);
68 bool SetValEntry(std::string const &content,
69 uint16_t group, uint16_t elem);
70 bool SetBinEntry(uint8_t *content, int lgth,
71 uint16_t group, uint16_t elem);
73 ValEntry *InsertValEntry(std::string const &content,
74 uint16_t group, uint16_t elem);
75 BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
76 uint16_t group, uint16_t elem);
77 SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
80 size_t GetImageDataSize();
81 size_t GetImageDataRawSize();
83 uint8_t *GetImageData();
84 uint8_t *GetImageDataRaw();
85 size_t GetImageDataIntoVector(void *destination, size_t maxSize);
87 void SetImageData(uint8_t *data, size_t expectedSize);
90 void SetUserData(uint8_t *data, size_t expectedSize);
91 uint8_t *GetUserData();
92 size_t GetUserDataSize();
93 // RBG data (from file)
94 uint8_t *GetRGBData();
95 size_t GetRGBDataSize();
96 // RAW data (from file)
97 uint8_t *GetRawData();
98 size_t GetRawDataSize();
101 uint8_t* GetLutRGBA();
102 int GetLutItemNumber();
103 int GetLutItemSize();
107 /// \brief Tells the writer we want to keep 'Grey pixels + Palettes color'
108 /// when possible (as opposed to convert 'Palettes color' to RGB)
109 void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); };
110 /// \brief Tells the writer we want to write RGB image when possible
111 /// (as opposed to 'Grey pixels + Palettes color')
112 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
113 /// \brief Sets the Write Mode ( )
114 void SetWriteMode(FileMode mode) { WriteMode = mode; };
115 /// \brief Gets the Write Mode ( )
116 FileMode GetWriteMode() { return WriteMode; };
120 /// \brief Tells the writer we want to write as Implicit VR
121 void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); };
122 /// \brief Tells the writer we want to write as Explicit VR
123 void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); };
124 /// \brief Tells the writer we want to write as ACR-NEMA
125 void SetWriteTypeToAcr() { SetWriteType(ACR); };
126 /// \brief Tells the writer we want to write as LibIDO
127 void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); };
128 /// \brief Tells the writer which format we want to write
129 /// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
130 void SetWriteType(FileType format) { WriteType = format; };
131 /// \brief Gets the format we talled the write we wanted to write
132 /// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
133 FileType GetWriteType() { return WriteType; };
135 // Write pixels of ONE image on hard drive
136 // No test is made on processor "endianness"
137 // The user must call his reader correctly
138 bool WriteRawData (std::string const &fileName);
139 bool WriteDcmImplVR(std::string const &fileName);
140 bool WriteDcmExplVR(std::string const &fileName);
141 bool WriteAcr (std::string const &fileName);
142 bool Write (std::string const &fileName);
145 bool CheckWriteIntegrity();
147 void SetWriteToRaw();
148 void SetWriteToRGB();
151 void SetWriteFileTypeToACR();
152 void SetWriteFileTypeToExplicitVR();
153 void SetWriteFileTypeToImplicitVR();
154 void RestoreWriteFileType();
156 void SetWriteToLibido();
157 void SetWriteToNoLibido();
158 void RestoreWriteOfLibido();
160 ValEntry *CopyValEntry(uint16_t group, uint16_t elem);
161 BinEntry *CopyBinEntry(uint16_t group, uint16_t elem,
162 const std::string &vr);
163 void CheckMandatoryElements();
164 void RestoreWriteMandatory();
171 // members variables:
172 /// gdcm::File to use to load the file
175 /// \brief Whether the underlying \ref gdcm::File was loaded by
176 /// the constructor or passed to the constructor.
177 /// When false the destructor is in charge of deletion.
180 /// Wether already parsed or not
183 // Utility pixel converter
184 /// \brief Pointer to the PixelReadConverter
185 PixelReadConvert *PixelReadConverter;
186 /// \brief Pointer to the PixelWriteConverter
187 PixelWriteConvert *PixelWriteConverter;
189 // Utility header archive
190 /// \brief Pointer to the DocEntryArchive (used while writting process)
191 DocEntryArchive *Archive;
194 /// \brief (WMODE_RAW, WMODE_RGB)
196 /// \brief (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
199 } // end namespace gdcm
201 //-----------------------------------------------------------------------------