00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef GDCMFILEHELPER_H
00020 #define GDCMFILEHELPER_H
00021
00022 #include <iostream>
00023 #include "gdcmBase.h"
00024
00025 namespace gdcm
00026 {
00027 class File;
00028 class ValEntry;
00029 class BinEntry;
00030 class SeqEntry;
00031 class PixelReadConvert;
00032 class PixelWriteConvert;
00033 class DocEntryArchive;
00034
00040 class GDCM_EXPORT FileHelper : public Base
00041 {
00042 public:
00043 enum FileMode
00044 {
00045 WMODE_RAW,
00046 WMODE_RGB
00047 };
00048
00049 public:
00050 FileHelper( );
00051 FileHelper( File *header );
00052 FileHelper( std::string const &filename );
00053
00054 virtual ~FileHelper();
00055
00056 void Print(std::ostream &os = std::cout, std::string const &indent = "");
00057
00059 File *GetFile() { return FileInternal; }
00060
00061
00062 bool SetValEntry(std::string const &content,
00063 uint16_t group, uint16_t elem);
00064 bool SetBinEntry(uint8_t *content, int lgth,
00065 uint16_t group, uint16_t elem);
00066
00067 ValEntry *InsertValEntry(std::string const &content,
00068 uint16_t group, uint16_t elem);
00069 BinEntry *InsertBinEntry(uint8_t *binArea, int lgth,
00070 uint16_t group, uint16_t elem);
00071 SeqEntry *InsertSeqEntry(uint16_t group, uint16_t elem);
00072
00073
00074 size_t GetImageDataSize();
00075 size_t GetImageDataRawSize();
00076
00077 uint8_t *GetImageData();
00078 uint8_t *GetImageDataRaw();
00079 size_t GetImageDataIntoVector(void *destination, size_t maxSize);
00080
00081 void SetImageData(uint8_t *data, size_t expectedSize);
00082
00083
00084 void SetUserData(uint8_t *data, size_t expectedSize);
00085 uint8_t *GetUserData();
00086 size_t GetUserDataSize();
00087
00088 uint8_t *GetRGBData();
00089 size_t GetRGBDataSize();
00090
00091 uint8_t *GetRawData();
00092 size_t GetRawDataSize();
00093
00094
00095 uint8_t* GetLutRGBA();
00096
00097
00098
00100 void SetWriteModeToRaw() { SetWriteMode(WMODE_RAW); };
00103 void SetWriteModeToRGB() { SetWriteMode(WMODE_RGB); };
00105 void SetWriteMode(FileMode mode) { WriteMode = mode; };
00107 FileMode GetWriteMode() { return WriteMode; };
00108
00109
00110
00112 void SetWriteTypeToDcmImplVR() { SetWriteType(ImplicitVR); };
00114 void SetWriteTypeToDcmExplVR() { SetWriteType(ExplicitVR); };
00116 void SetWriteTypeToAcr() { SetWriteType(ACR); };
00118 void SetWriteTypeToAcrLibido() { SetWriteType(ACR_LIBIDO); };
00121 void SetWriteType(FileType format) { WriteType = format; };
00124 FileType GetWriteType() { return WriteType; };
00125
00126
00127
00128
00129 bool WriteRawData (std::string const &fileName);
00130 bool WriteDcmImplVR(std::string const &fileName);
00131 bool WriteDcmExplVR(std::string const &fileName);
00132 bool WriteAcr (std::string const &fileName);
00133 bool Write (std::string const &fileName);
00134
00135 protected:
00136 bool CheckWriteIntegrity();
00137
00138 void SetWriteToRaw();
00139 void SetWriteToRGB();
00140 void RestoreWrite();
00141
00142 void SetWriteFileTypeToACR();
00143 void SetWriteFileTypeToExplicitVR();
00144 void SetWriteFileTypeToImplicitVR();
00145 void RestoreWriteFileType();
00146
00147 void SetWriteToLibido();
00148 void SetWriteToNoLibido();
00149 void RestoreWriteOfLibido();
00150
00151 ValEntry *CopyValEntry(uint16_t group, uint16_t elem);
00152 BinEntry *CopyBinEntry(uint16_t group, uint16_t elem,
00153 const std::string &vr);
00154
00155 private:
00156 void Initialize();
00157
00158 uint8_t *GetRaw();
00159
00160
00162 File *FileInternal;
00163
00167 bool SelfHeader;
00168
00170 bool Parsed;
00171
00172
00174 PixelReadConvert *PixelReadConverter;
00176 PixelWriteConvert *PixelWriteConverter;
00177
00178
00180 DocEntryArchive *Archive;
00181
00182
00184 FileMode WriteMode;
00186 FileType WriteType;
00187 };
00188 }
00189
00190
00191 #endif