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