]> Creatis software - gdcm.git/blob - src/gdcmFile.h
ENH: Adding a deprecation mechanism to gdcm via two MACRO and two config options
[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 14:44:57 $
7   Version:   $Revision: 1.109 $
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 /**
79  * \brief DICOM elements and their corresponding values (and
80  * additionaly the corresponding DICOM dictionary entry) of the header
81  * of a DICOM file.
82  *
83  * The typical usage of instances of class File is to classify a set of
84  * dicom files according to header information e.g. to create a file hierarchy
85  * reflecting the Patient/Study/Serie informations, or extracting a given
86  * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
87  * functionality of this class and belongs to gdmcFile.
88  * \note  The various entries of the explicit value representation (VR) shall
89  *        be managed within a dictionary which is shared by all File
90  *        instances.
91  * \note  The File::Set*Tag* family members cannot be defined as
92  *        protected due to Swig limitations for as Has_a dependency between
93  *        File and FileHelper.
94  */
95 class GDCM_EXPORT File : public Document
96 {
97 public:
98    File();
99    File( std::string const &filename );
100    ~File();
101
102    // Loading
103    GDCM_LEGACY(bool Load( std::string const &filename ));
104    bool Load(); 
105    // Standard values and informations contained in the header
106    bool IsReadable();
107
108    // Some heuristic based accessors, end user intended 
109    int GetImageNumber();
110    ModalityType GetModality();
111
112    int GetXSize();
113    int GetYSize();
114    int GetZSize();
115
116    float GetXSpacing();
117    float GetYSpacing();
118    float GetZSpacing();
119
120    float GetXOrigin();
121    float GetYOrigin();
122    float GetZOrigin();
123
124    void GetImageOrientationPatient( float iop[6] );
125
126    int GetBitsStored();
127    int GetBitsAllocated();
128    int GetHighBitPosition();
129    int GetSamplesPerPixel();
130    int GetPlanarConfiguration();
131    int GetPixelSize();
132    std::string GetPixelType();
133    bool IsSignedPixelData();
134    bool IsMonochrome();
135    bool IsMonochrome1();
136    bool IsPaletteColor();
137    bool IsYBRFull();
138
139    bool HasLUT();
140    int GetLUTNbits();
141
142    // For rescaling graylevel:
143    float GetRescaleIntercept();
144    float GetRescaleSlope();
145
146    int GetNumberOfScalarComponents();
147    int GetNumberOfScalarComponentsRaw();
148
149    /// Accessor to \ref File::GrPixel
150    uint16_t GetGrPixel()  { return GrPixel; }
151    /// Accessor to \ref File::NumPixel
152    uint16_t GetNumPixel() { return NumPixel; }
153
154    size_t GetPixelOffset();
155    size_t GetPixelAreaLength();
156
157    /// returns the RLE info
158    RLEFramesInfo *GetRLEInfo() { return RLEInfo; }
159    /// Returns the JPEG Fragments info
160    JPEGFragmentsInfo *GetJPEGInfo() { return JPEGInfo; }
161
162 // Anonymization process
163    void AddAnonymizeElement (uint16_t group, uint16_t elem, 
164                              std::string const &value);
165    /// Clears the list of elements to be anonymized
166    void ClearAnonymizeList() { AnonymizeList.clear(); }      
167    void AnonymizeNoLoad();
168    /// Replace patient's own information by info from the Anonymization list
169    bool AnonymizeFile();
170
171    bool Write(std::string fileName, FileType filetype);
172
173 protected:
174  
175    /// Store the RLE frames info obtained during parsing of pixels.
176    RLEFramesInfo *RLEInfo;
177    /// Store the JPEG fragments info obtained during parsing of pixels.
178    JPEGFragmentsInfo *JPEGInfo;
179
180    /// \brief In some cases (e.g. for some ACR-NEMA images) the Entry Element
181    /// Number of the 'Pixel Element' is *not* found at 0x0010. In order to
182    /// make things easier the parser shall store the proper value in
183    /// NumPixel to provide a unique access facility. 
184    uint16_t NumPixel;
185    /// \brief In some cases (e.g. for some ACR-NEMA images) the header entry for
186    /// the group of pixels is *not* found at 0x7fe0. 
187    /// In order to make things easier the parser shall store the proper value
188    /// in GrPixel to provide a unique access facility.
189    uint16_t GrPixel;
190
191 private:
192    bool DoTheLoadingJob();
193    void ComputeRLEInfo();
194    void ComputeJPEGFragmentInfo();
195    bool     ReadTag(uint16_t, uint16_t);
196    uint32_t ReadTagLength(uint16_t, uint16_t);
197    void ReadAndSkipEncapsulatedBasicOffsetTable();
198
199 };
200 } // end namespace gdcm
201
202 //-----------------------------------------------------------------------------
203 #endif