]> Creatis software - gdcm.git/blob - src/gdcmHeader.h
ENH: Adding 'gdcm' namespace. Be nice with me this was a ~13000 lines patch. Also...
[gdcm.git] / src / gdcmHeader.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmHeader.h,v $
5   Language:  C++
6   Date:      $Date: 2004/10/12 04:35:46 $
7   Version:   $Revision: 1.89 $
8                                                                                 
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.
12                                                                                 
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.
16                                                                                 
17 =========================================================================*/
18
19 #ifndef GDCMHEADER_H
20 #define GDCMHEADER_H
21
22 #include "gdcmCommon.h"
23 #include "gdcmDocument.h"
24 namespace gdcm 
25 {
26
27
28 //-----------------------------------------------------------------------------
29 /**
30  * \brief
31  * The purpose of an instance of Header is to act as a container of
32  * all the DICOM elements and their corresponding values (and
33  * additionaly the corresponding DICOM dictionary entry) of the header
34  * of a DICOM file.
35  *
36  * The typical usage of instances of class Header is to classify a set of
37  * dicom files according to header information e.g. to create a file hierarchy
38  * reflecting the Patient/Study/Serie informations, or extracting a given
39  * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
40  * functionality of this class and belongs to gdmcFile.
41  * \note  The various entries of the explicit value representation (VR) shall
42  *        be managed within a dictionary which is shared by all Header
43  *        instances.
44  * \note  The Header::Set*Tag* family members cannot be defined as
45  *        protected due to Swig limitations for as Has_a dependency between
46  *        File and Header.
47  */
48
49 //-----------------------------------------------------------------------------
50 // Dicom Part 3.3 Compliant
51 enum ModalityType {
52    Unknow,
53    AU,       // Voice Audio
54    AS,       // Angioscopy
55    BI,       // Biomagnetic Imaging
56    CF,       // Cinefluorography
57    CP,       // Culposcopy
58    CR,       // Computed Radiography
59    CS,       // Cystoscopy
60    CT,       // Computed Tomography
61    DD,       // Duplex Dopler
62    DF,       // Digital Fluoroscopy
63    DG,       // Diaphanography
64    DM,       // Digital Microscopy
65    DS,       // Digital Substraction Angiography
66    DX,       // Digital Radiography
67    ECG,      // Echocardiography
68    EPS,      // Basic Cardiac EP
69    ES,       // Endoscopy
70    FA,       // Fluorescein Angiography
71    FS,       // Fundoscopy
72    HC,       // Hard Copy
73    HD,       // Hemodynamic
74    LP,       // Laparoscopy
75    LS,       // Laser Surface Scan
76    MA,       // Magnetic Resonance Angiography
77    MR,       // Magnetic Resonance
78    NM,       // Nuclear Medicine
79    OT,       // Other
80    PT,       // Positron Emission Tomography
81    RF,       // Radio Fluoroscopy
82    RG,       // Radiographic Imaging
83    RTDOSE,   // Radiotherapy Dose
84    RTIMAGE,  // Radiotherapy Image
85    RTPLAN,   // Radiotherapy Plan
86    RTSTRUCT, // Radiotherapy Structure Set
87    SM,       // Microscopic Imaging
88    ST,       // Single-photon Emission Computed Tomography
89    TG,       // Thermography
90    US,       // Ultrasound
91    VF,       // Videofluorography
92    XA,       // X-Ray Angiography
93    XC        // Photographic Imaging
94 };
95 //-----------------------------------------------------------------------------
96
97 class GDCM_EXPORT Header : public Document
98 {
99 protected:
100    /// \brief In some cases (e.g. for some ACR-NEMA images) the Header Entry Element
101    /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to
102    /// make things easier the parser shall store the proper value in
103    /// NumPixel to provide a unique access facility. See also the constructor
104    /// \ref Header::Header
105    uint16_t NumPixel;
106    /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for
107    /// the group of pixels is *not* found at 0x7fe0. In order to
108    /// make things easier the parser shall store the proper value in
109    /// GrPixel to provide a unique access facility. See also the constructor
110    /// \ref Header::Header
111    uint16_t GrPixel;
112
113 public:
114    Header();
115    Header( std::string const & filename );
116  
117    virtual ~Header();
118
119    // Standard values and informations contained in the header
120    virtual bool IsReadable();
121
122    // Some heuristic based accessors, end user intended 
123    int GetBitsStored();
124    int GetBitsAllocated();
125    int GetSamplesPerPixel();
126    int GetPlanarConfiguration();
127    int GetPixelSize();
128    int GetHighBitPosition();
129    bool IsSignedPixelData();
130    bool IsMonochrome();
131    bool IsPaletteColor();
132    bool IsYBRFull();
133
134    std::string GetPixelType();
135    size_t GetPixelOffset();
136    size_t GetPixelAreaLength();
137
138    //Some image informations needed for third package imaging library
139    int GetXSize();
140    int GetYSize();
141    int GetZSize();
142
143    float GetXSpacing();
144    float GetYSpacing();
145    float GetZSpacing();
146    //void GetSpacing(float &x, float &y, float &z);
147
148    // Useful for rescaling graylevel:
149    float GetRescaleIntercept();
150    float GetRescaleSlope();
151
152    int GetNumberOfScalarComponents();
153    int GetNumberOfScalarComponentsRaw();
154
155    int GetImageNumber();
156    ModalityType GetModality();
157
158    float GetXOrigin();
159    float GetYOrigin();
160    float GetZOrigin();
161    //void GetOrigin(float &x, float &y, float &z);
162
163    bool   HasLUT();
164    int    GetLUTNbits();
165    unsigned char * GetLUTRGBA();
166
167    std::string GetTransfertSyntaxName();
168
169    /// Accessor to \ref Header::GrPixel
170    uint16_t GetGrPixel()  { return GrPixel; }
171    
172    /// Accessor to \ref Header::NumPixel
173    uint16_t GetNumPixel() { return NumPixel; }
174
175    /// Read (used in File)
176    void SetImageDataSize(size_t expectedSize);
177
178    void Write(FILE* fp, FileType filetype);
179  
180 protected:
181    bool AnonymizeHeader();
182    void GetImageOrientationPatient( float iop[6] );
183
184 private:
185   friend class SerieHeader;
186 };
187 } // end namespace gdcm
188
189 //-----------------------------------------------------------------------------
190 #endif