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