]> Creatis software - gdcm.git/blob - src/gdcmCommon.h
* Remove useless constructor of gdcm::Document
[gdcm.git] / src / gdcmCommon.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmCommon.h,v $
5   Language:  C++
6   Date:      $Date: 2005/10/18 09:17:08 $
7   Version:   $Revision: 1.94 $
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 GDCMCOMMON_H
20 #define GDCMCOMMON_H
21
22 #include "gdcmConfigure.h"
23 #include "gdcmSystem.h"
24
25 //-----------------------------------------------------------------------------
26 /// \brief namespace for Grass root DiCoM
27 namespace gdcm
28 {
29
30 // Centralize information about the gdcm dictionary in only one file:
31 #ifndef PUB_DICT_PATH
32 #  define PUB_DICT_PATH   "../Dicts/"
33 #endif
34 #define PUB_DICT_NAME     "DicomV3Dict"
35 #define PUB_DICT_FILENAME "gdcm.dic"
36 #define DICT_ELEM         "DicomDir.dic"
37 #define DICT_TS           "dicomTS.dic"
38 #define DICT_VR           "dicomVR.dic"
39 #define DICT_GROUP_NAME   "DictGroupName.dic"
40
41 GDCM_EXPORT extern const std::string GDCM_UNKNOWN;
42 GDCM_EXPORT extern const std::string GDCM_UNFOUND;
43 GDCM_EXPORT extern const std::string GDCM_BINLOADED;
44 GDCM_EXPORT extern const std::string GDCM_NOTLOADED;
45 GDCM_EXPORT extern const std::string GDCM_UNREAD;
46 GDCM_EXPORT extern const std::string GDCM_NOTASCII;
47 GDCM_EXPORT extern const std::string GDCM_PIXELDATA;
48 /// \brief TagKey is made to hold the standard Dicom Tag 
49 ///               (Group number, Element number)
50 /// Instead of using the two '16 bits integers' as the Hask Table key, we
51 /// converted into a string (e.g. 0x0018,0x0050 converted into "0018|0050")
52 /// It appears to be a huge waste of time.
53 /// We'll fix the mess up -without any change in the API- as soon as the bench
54 /// marks are fully performed.
55
56 #if FASTTAGKEY
57 typedef union   {
58       uint16_t  tab[2];
59       uint32_t  tagkey;
60     } TagKey;
61 /* ostream operator for TagKey */
62 inline std::ostream& operator<<(std::ostream& _O, TagKey _val)
63 {
64   _O.setf( std::ios::right);
65   return (_O << std::hex << std::setw( 4 ) << std::setfill( '0' )
66      << _val.tab[0] << '|' << std::setw( 4 ) << std::setfill( '0' )
67      << _val.tab[1] << std::setfill( ' ' ) << std::dec);
68 }
69 inline bool operator==(TagKey _self, TagKey _val)
70 {
71   return _self.tagkey == _val.tagkey;
72 }
73 inline bool operator<(TagKey _self, TagKey _val)
74 {
75   // This expression is a tad faster but PrintFile output
76   // is more difficult to read
77   //return _self.tagkey < _val.tagkey;
78
79   // More usal order of dicom tags:
80   if( _self.tab[0] == _val.tab[0] )
81     return _self.tab[1] < _val.tab[1];
82   return _self.tab[0] < _val.tab[0];
83 }
84 #else
85 typedef std::string TagKey;
86 #endif
87 #if defined(_MSC_VER) && (_MSC_VER == 1200)
88 // Doing everything within gdcm namespace to avoid polluting 3d party software
89 inline std::ostream& operator<<(std::ostream& _O, std::string _val)
90 {
91   return _O << _val.c_str();
92 }
93 #endif
94
95 /// \brief TagName is made to hold the 'non hexa" fields (VR, VM, Name) 
96 ///        of Dicom Entries
97 typedef std::string TagName;
98
99 /// \brief various types of a DICOM file (for internal use only)
100 enum FileType {
101    Unknown = 0,
102    ExplicitVR, // DicomDir is in this case. Except when it's ImplicitVR !...
103    ImplicitVR,
104    ACR,
105    ACR_LIBIDO
106 };
107
108 /// \brief type of the elements composing a DICOMDIR (for internal use only)
109 enum DicomDirType {
110    DD_UNKNOWN = 0,
111    DD_META,
112    DD_PATIENT,
113    DD_STUDY,
114    DD_SERIE,
115    DD_IMAGE,
116    DD_VISIT
117 };
118
119 /// \brief comparison operators (as used in SerieHelper::AddRestriction() )
120 enum CompOperators {
121    GDCM_EQUAL = 0,
122    GDCM_DIFFERENT,
123    GDCM_GREATER,
124    GDCM_GREATEROREQUAL,
125    GDCM_LESS,
126    GDCM_LESSOREQUAL
127 };
128
129 /// \brief Loading mode
130 enum LodModeType
131 {
132    LD_ALL         = 0x00000000, // Load all
133    LD_NOSEQ       = 0x00000001, // Don't load Sequences
134    LD_NOSHADOW    = 0x00000002, // Don't load odd groups
135    LD_NOSHADOWSEQ = 0x00000004  // Don't load Sequences if they belong 
136                                 //            to an odd group
137                                 // (*exclusive* from LD_NOSEQ and LD_NOSHADOW)
138 };
139
140 /**
141  * \brief structure, for internal use only
142  */  
143 struct Element
144 {
145    /// DicomGroup number
146    unsigned short int Group;
147    /// DicomElement number
148    unsigned short int Elem;
149    /// value (coded as a std::string) of the Element
150    std::string Value;
151 };
152
153 } //namespace gdcm
154 //-----------------------------------------------------------------------------
155 #endif