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