]> Creatis software - gdcm.git/blob - src/gdcmHeader.h
* src/gdcmUtil.[cxx|h] split in two. Additional file gdcmGlobal.[cxx|h]
[gdcm.git] / src / gdcmHeader.h
1 // gdcmHeader.h
2 //-----------------------------------------------------------------------------
3 #ifndef GDCMHEADER_H
4 #define GDCMHEADER_H
5
6 #include "gdcmCommon.h"
7 #include "gdcmParser.h"
8
9 //-----------------------------------------------------------------------------
10 /**
11  * \brief
12  * The purpose of an instance of gdcmHeader is to act as a container of
13  * all the DICOM elements and their corresponding values (and
14  * additionaly the corresponding DICOM dictionary entry) of the header
15  * of a DICOM file.
16  *
17  * The typical usage of instances of class gdcmHeader is to classify a set of
18  * dicom files according to header information e.g. to create a file hierarchy
19  * reflecting the Patient/Study/Serie informations, or extracting a given
20  * SerieId. Accessing the content (image[s] or volume[s]) is beyond the
21  * functionality of this class and belongs to gdmcFile.
22  * \note  The various entries of the explicit value representation (VR) shall
23  *        be managed within a dictionary which is shared by all gdcmHeader
24  *        instances.
25  * \note  The gdcmHeader::Set*Tag* family members cannot be defined as
26  *        protected due to Swig limitations for as Has_a dependency between
27  *        gdcmFile and gdcmHeader.
28  */
29 class GDCM_EXPORT gdcmHeader : public gdcmParser
30 {
31 public:
32    gdcmHeader(bool exception_on_error = false);
33    gdcmHeader(const char *filename, 
34               bool  exception_on_error = false, 
35               bool  enable_sequences   = false,
36               bool  skip_shadow        = false);
37  
38    virtual ~gdcmHeader();
39
40    // Standard values and informations contained in the header
41    virtual bool IsReadable(void);
42    bool IsJPEGBaseLineProcess1TransferSyntax(void);
43    bool IsJPEGExtendedProcess2_4TransferSyntax(void); 
44    bool IsJPEGExtendedProcess3_5TransferSyntax(void);
45    bool IsJPEGSpectralSelectionProcess6_8TransferSyntax(void); 
46    bool IsRLELossLessTransferSyntax(void); 
47    bool IsJPEGLossless(void); 
48    bool IsJPEG2000(void); 
49    bool IsDicomV3(void); 
50
51    // Some heuristic based accessors, end user intended 
52    // (to be moved to gdcmHeaderHelper?) 
53    int GetXSize(void);
54    int GetYSize(void);
55    int GetZSize(void);
56    int GetBitsStored(void);
57    int GetBitsAllocated(void);
58    int GetSamplesPerPixel(void);   
59    int GetPlanarConfiguration(void);
60
61    int GetPixelSize(void);   
62    std::string GetPixelType(void);  
63    size_t GetPixelOffset(void);
64    size_t GetPixelAreaLength(void);
65
66    bool   HasLUT(void);
67    int    GetLUTNbits(void);
68    unsigned char * GetLUTRGBA(void);
69
70    std::string GetTransfertSyntaxName(void);
71
72    // When some proprietary shadow groups are disclosed, we can set up
73    // an additional specific dictionary to access extra information.
74    
75    // OK : we still have *ONE* HeaderEntrySet, 
76    // with both Public and Shadow Elements
77    // parsed against THE Public Dictionary and A (single) Shadow Dictionary
78    
79    // TODO Swig int SetShaDict(std::string filename);
80    // TODO Swig int SetPubDict(std::string filename);
81    
82 // System access
83    /**
84     * \brief   the Header Entry Group Number of the 'Pixel Group' 
85     *          is not allways 0x7fe0
86     * @return  GrPixel
87     */
88    guint16 GetGrPixel(void)  {return GrPixel;}
89    
90    /// Accessor to \ref gdcmParser::NumPixel
91    guint16 GetNumPixel(void) {return NumPixel;}
92
93 // Entry
94
95    inline virtual std::string GetEntryByNumber  (guint16 group, guint16 element)
96       { return(gdcmParser::GetEntryByNumber(group,element)); }
97       
98    inline virtual std::string GetEntryVRByNumber(guint16 group, guint16 element)
99       { return(gdcmParser::GetEntryVRByNumber(group,element)); }
100       
101    inline virtual int GetEntryLengthByNumber(guint16 group, guint16 element)
102       { return(gdcmParser::GetEntryLengthByNumber(group,element)); }
103       
104    inline virtual std::string GetEntryByName    (std::string tagName) 
105       { return(gdcmParser::GetEntryByName(tagName)); }
106       
107    inline virtual std::string GetEntryVRByName  (std::string tagName)
108       { return(gdcmParser::GetEntryVRByName(tagName)); }
109       
110    inline virtual bool SetEntryByNumber(std::string content,guint16 group, guint16 element)
111       { return(gdcmParser::SetEntryByNumber(content,group,element)); }
112       
113    inline virtual bool SetEntryByName(std::string content,std::string tagName)
114       { return(gdcmParser::SetEntryByName(content,tagName)); }
115
116   inline virtual bool SetEntryLengthByNumber(guint32 l,guint16 group, guint16 element)
117       { return(gdcmParser::SetEntryLengthByNumber(l,group,element)); }
118
119    inline virtual void UpdateShaEntries(void)
120       { gdcmParser::UpdateShaEntries(); }
121
122    /// Read (used in gdcmFile)
123    void SetImageDataSize(size_t ExpectedSize);
124
125    bool operator<(gdcmHeader &header);
126
127 protected:
128    //CLEANME int write(std::ostream&);   
129    //CLEANME int anonymize(std::ostream&);//FIXME: anonymize should be a friend
130    bool anonymizeHeader(void);
131 private:
132
133 };
134
135 //-----------------------------------------------------------------------------
136 #endif