7 #include "gdcmCommon.h"
8 #include "gdcmException.h"
9 #include "gdcmDictSet.h"
10 #include "gdcmElValue.h"
11 #include "gdcmElValSet.h"
15 typedef map<VRKey, VRAtr> VRHT; // Value Representation Hash Table
17 /// The purpose of an instance of gdcmHeader is to act as a container of
18 /// all the DICOM elements and their corresponding values (and
19 /// additionaly the corresponding DICOM dictionary entry) of the header
22 /// The typical usage of instances of class gdcmHeader is to classify a set of
23 /// dicom files according to header information e.g. to create a file hierarchy
24 /// reflecting the Patient/Study/Serie informations, or extracting a given
25 /// SerieId. Accesing the content (image[s] or volume[s]) is beyond the
26 /// functionality of this class and belongs to gdmcFile.
27 /// \note The various entries of the explicit value representation (VR) shall
28 /// be managed within a dictionary which is shared by all gdcmHeader
30 /// \note The gdcmHeader::Set*Tag* family members cannot be defined as
31 /// protected due to Swig limitations for as Has_a dependency between
32 /// gdcmFile and gdcmHeader.
34 class GDCM_EXPORT gdcmHeader {
35 void SkipBytes(guint32);
37 /// Pointer to the Value Representation Hash Table which contains all
38 /// the VR of the DICOM version3 public dictionary.
39 static VRHT *dicom_vr;
41 /// Global dictionary container
43 /// Public dictionary used to parse this header
45 /// Optional "shadow dictionary" (private elements) used to parse this
49 /// ELement VALueS parsed with the PUBlic dictionary.
51 /// ELement VALueS parsed with the SHAdow dictionary.
53 /// Refering underlying filename.
57 // FIXME sw should be an enum e.g.
63 /// Swap code e.g. little, big, bad-big, bad-little endian). Warning:
64 /// this code is not fixed during header parsing.
67 /// Size treshold above which an element value will NOT be loaded in
68 /// memory (to avoid loading the image/volume itself). By default,
69 /// this upper bound is fixed to 1024 bytes (which might look reasonable
70 /// when one considers the definition of the various VR contents).
71 guint32 MaxSizeLoadElementValue;
73 guint16 ReadInt16(void);
74 guint32 ReadInt32(void);
75 guint16 SwapShort(guint16);
76 guint32 SwapLong(guint32);
77 guint32 FindLengthOB(void);
78 void Initialise(void);
80 void InitVRDict(void);
81 void SwitchSwapToBigEndian(void);
82 void AddAndDefaultElements(void);
83 void SetMaxSizeLoadElementValue(long);
85 gdcmDictEntry * GetDictEntryByKey(guint16, guint16);
86 gdcmDictEntry * GetDictEntryByName(string name);
88 // ElValue related utilities
89 ElValue * ReadNextElement(void);
90 ElValue * NewElValueByKey(guint16 group, guint16 element);
91 ElValue * NewElValueByName(string name);
92 void FindLength(ElValue *);
93 void FindVR(ElValue *);
94 void LoadElementValue(ElValue *);
95 void LoadElementValueSafe(ElValue *);
96 void SkipElementValue(ElValue *);
97 void FixFoundLength(ElValue*, guint32);
98 bool IsAnInteger(ElValue *);
100 bool IsImplicitVRLittleEndianTransferSyntax(void);
101 bool IsExplicitVRLittleEndianTransferSyntax(void);
102 bool IsDeflatedExplicitVRLittleEndianTransferSyntax(void);
103 bool IsExplicitVRBigEndianTransferSyntax(void);
104 bool IsJPEGBaseLineProcess1TransferSyntax(void);
105 bool IsJPEGExtendedProcess2_4TransferSyntax(void);
106 bool IsJPEGExtendedProcess3_5TransferSyntax(void);
107 bool IsJPEGSpectralSelectionProcess6_8TransferSyntax(void);
109 bool IsJPEGLossless(void);
112 // FIXME: is this enum still necessary ??
119 ACR_LIBIDO}; // CLEANME
122 int anonymize(ostream&); // FIXME : anonymize should be a friend ?
124 void LoadElements(void);
125 virtual void ParseHeader(bool exception_on_error = false)
126 throw(gdcmFormatError);
127 gdcmHeader(const char *filename, bool exception_on_error = false)
128 throw(gdcmFileError);
129 virtual ~gdcmHeader();
131 size_t GetPixelOffset(void);
132 void GetPixels(size_t, void *);
133 int GetSwapCode(void) { return sw; }
135 // TODO Swig int SetPubDict(string filename);
136 // When some proprietary shadow groups are disclosed, we can set up
137 // an additional specific dictionary to access extra information.
138 // TODO Swig int SetShaDict(string filename);
140 string GetPubElValByName(string TagName);
141 string GetPubElValByNumber(guint16 group, guint16 element);
142 string GetPubElValRepByName(string TagName);
143 string GetPubElValRepByNumber(guint16 group, guint16 element);
145 TagElValueHT & GetPubElVal(void) { return PubElVals.GetTagHt(); };
146 void PrintPubElVal(ostream & os = cout);
147 void PrintPubDict(ostream & os = cout);
149 // TODO Swig string* GetShaTagNames();
150 string GetShaElValByName(string TagName);
151 string GetShaElValByNumber(guint16 group, guint16 element);
152 string GetShaElValRepByName(string TagName);
153 string GetShaElValRepByNumber(guint16 group, guint16 element);
155 string GetElValByName(string TagName);
156 string GetElValByNumber(guint16 group, guint16 element);
157 string GetElValRepByName(string TagName);
158 string GetElValRepByNumber(guint16 group, guint16 element);
160 int SetPubElValByName(string content, string TagName);
161 int SetPubElValByNumber(string content, guint16 group, guint16 element);
162 int SetShaElValByName(string content, string ShadowTagName);
163 int SetShaElValByNumber(string content, guint16 group, guint16 element);
165 int gdcmHeader::SetPubElValLengthByNumber(guint32 lgr, guint16 group,
168 ElValSet GetPubElVals() { return(PubElVals); }