1 /*=========================================================================
4 Module: $RCSfile: gdcmFileHelper.h,v $
6 Date: $Date: 2005/06/17 12:35:00 $
7 Version: $Revision: 1.17 $
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
31 class PixelReadConvert;
32 class PixelWriteConvert;
33 class DocEntryArchive;
34 //-----------------------------------------------------------------------------
36 * \brief In addition to Dicom header exploration, this class is designed
37 * for accessing the image/volume content. One can also use it to
38 * write Dicom/ACR-NEMA/RAW files.
40 class GDCM_EXPORT FileHelper : public Base
51 FileHelper( File *header );
52 FileHelper( std::string const &filename );
54 virtual ~FileHelper();
56 void Print(std::ostream &os = std::cout, std::string const &indent = "");
58 /// Accessor to \ref File
59 File *GetFile() { return FileInternal; }
62 bool SetValEntry(std::string const &content,
63 uint16_t group, uint16_t elem);
64 bool SetBinEntry(uint8_t *content, int lgth,
65 uint16_t group, uint16_t elem);
67 ValEntry *InsertValEntry(std::string const &content,
68 uint16_t group, uint16_t elem);
69 BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
70 uint16_t group, uint16_t elem);
71 SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
74 size_t GetImageDataSize();
75 size_t GetImageDataRawSize();
77 uint8_t *GetImageData();
78 uint8_t *GetImageDataRaw();
79 size_t GetImageDataIntoVector(void *destination, size_t maxSize);
81 void SetImageData(uint8_t *data, size_t expectedSize);
84 void SetUserData(uint8_t *data, size_t expectedSize);
85 uint8_t *GetUserData();
86 size_t GetUserDataSize();
87 // RBG data (from file)
88 uint8_t *GetRGBData();
89 size_t GetRGBDataSize();
90 // RAW data (from file)
91 uint8_t *GetRawData();
92 size_t GetRawDataSize();
95 uint8_t* GetLutRGBA();
96 int GetLutItemNumber();
101 /// \brief Tells the writer we want to keep 'Grey pixels + Palettes color'
102 /// when possible (as opposed to convert 'Palettes color' to RGB)
103 void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); };
104 /// \brief Tells the writer we want to write RGB image when possible
105 /// (as opposed to 'Grey pixels + Palettes color')
106 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
107 /// \brief Sets the Write Mode ( )
108 void SetWriteMode(FileMode mode) { WriteMode = mode; };
109 /// \brief Gets the Write Mode ( )
110 FileMode GetWriteMode() { return WriteMode; };
114 /// \brief Tells the writer we want to write as Implicit VR
115 void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); };
116 /// \brief Tells the writer we want to write as Explicit VR
117 void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); };
118 /// \brief Tells the writer we want to write as ACR-NEMA
119 void SetWriteTypeToAcr() { SetWriteType(ACR); };
120 /// \brief Tells the writer we want to write as LibIDO
121 void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); };
122 /// \brief Tells the writer which format we want to write
123 /// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
124 void SetWriteType(FileType format) { WriteType = format; };
125 /// \brief Gets the format we talled the write we wanted to write
126 /// (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
127 FileType GetWriteType() { return WriteType; };
129 // Write pixels of ONE image on hard drive
130 // No test is made on processor "endianness"
131 // The user must call his reader correctly
132 bool WriteRawData (std::string const &fileName);
133 bool WriteDcmImplVR(std::string const &fileName);
134 bool WriteDcmExplVR(std::string const &fileName);
135 bool WriteAcr (std::string const &fileName);
136 bool Write (std::string const &fileName);
139 bool CheckWriteIntegrity();
141 void SetWriteToRaw();
142 void SetWriteToRGB();
145 void SetWriteFileTypeToACR();
146 void SetWriteFileTypeToExplicitVR();
147 void SetWriteFileTypeToImplicitVR();
148 void RestoreWriteFileType();
150 void SetWriteToLibido();
151 void SetWriteToNoLibido();
152 void RestoreWriteOfLibido();
154 ValEntry *CopyValEntry(uint16_t group, uint16_t elem);
155 BinEntry *CopyBinEntry(uint16_t group, uint16_t elem,
156 const std::string &vr);
157 void CheckMandatoryElements();
158 void RestoreWriteMandatory();
165 // members variables:
166 /// gdcm::File to use to load the file
169 /// \brief Whether the underlying \ref gdcm::File was loaded by
170 /// the constructor or passed to the constructor.
171 /// When false the destructor is in charge of deletion.
174 /// Wether already parsed or not
177 // Utility pixel converter
178 /// \brief Pointer to the PixelReadConverter
179 PixelReadConvert *PixelReadConverter;
180 /// \brief Pointer to the PixelWriteConverter
181 PixelWriteConvert *PixelWriteConverter;
183 // Utility header archive
184 /// \brief Pointer to the DocEntryArchive (used while writting process)
185 DocEntryArchive *Archive;
188 /// \brief (WMODE_RAW, WMODE_RGB)
190 /// \brief (ImplicitVR, ExplicitVR, ACR, ACR_LIBIDO)
193 } // end namespace gdcm
195 //-----------------------------------------------------------------------------