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