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