1 /*=========================================================================
4 Module: $RCSfile: gdcmCommon.h,v $
6 Date: $Date: 2005/10/11 08:24:10 $
7 Version: $Revision: 1.93 $
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.
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.
17 =========================================================================*/
22 #include "gdcmConfigure.h"
24 //-----------------------------------------------------------------------------
25 //This is needed when compiling in debug mode
27 // 'identifier' : class 'type' needs to have dll-interface to be used by
28 // clients of class 'type2'
29 #pragma warning ( disable : 4251 )
30 // non dll-interface class 'type' used as base for dll-interface class 'type2'
31 #pragma warning ( disable : 4275 )
32 // 'identifier' : identifier was truncated to 'number' characters in the
34 #pragma warning ( disable : 4786 )
35 //'identifier' : decorated name length exceeded, name was truncated
36 #pragma warning ( disable : 4503 )
37 // C++ exception specification ignored except to indicate a
38 // function is not __declspec(nothrow)
39 #pragma warning ( disable : 4290 )
40 // signed/unsigned mismatch
41 #pragma warning ( disable : 4018 )
42 // return type for 'identifier' is '' (ie; not a UDT or reference to UDT. Will
43 // produce errors if applied using infix notation
44 #pragma warning ( disable : 4284 )
45 // 'type' : forcing value to bool 'true' or 'false' (performance warning)
46 // //#pragma warning ( disable : 4800 )
49 //-----------------------------------------------------------------------------
50 #ifdef CMAKE_HAVE_STDINT_H
53 #ifdef CMAKE_HAVE_INTTYPES_H
54 // Old system only have this
55 #include <inttypes.h> // For uint8_t uint16_t and uint32_t
57 // Broken plateforms do not respect C99 and do not provide those typedef
58 // Special case for recent Borland compiler, comes with stdint.h
59 #if defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560) \
60 || defined(__MINGW32__)
61 typedef signed char int8_t;
62 typedef signed short int16_t;
63 typedef signed int int32_t;
64 typedef unsigned char uint8_t;
65 typedef unsigned short uint16_t;
66 typedef unsigned int uint32_t;
68 #error "Sorry your plateform is not supported"
69 #endif // defined(_MSC_VER) || defined(__BORLANDC__) && (__BORLANDC__ < 0x0560) || defined(__MINGW32__)
70 #endif // CMAKE_HAVE_INTTYPES_H
71 #endif // CMAKE_HAVE_STDINT_H
73 // Basically for VS6 and bcc 5.5.1:
75 #define UINT32_MAX (4294967295U)
78 #if defined(_WIN32) && defined(BUILD_SHARED_LIBS)
80 #define GDCM_EXPORT __declspec( dllexport )
82 #define GDCM_EXPORT __declspec( dllimport )
91 // FIXME: Should rewrite this:
96 #if defined(_MSC_VER) && (_MSC_VER == 1200)
97 /* ostream operator for std::string since VS6 does not provide it*/
102 //-----------------------------------------------------------------------------
103 /// \brief namespace for Grass root DiCoM
107 // Centralize information about the gdcm dictionary in only one file:
108 #ifndef PUB_DICT_PATH
109 # define PUB_DICT_PATH "../Dicts/"
111 #define PUB_DICT_NAME "DicomV3Dict"
112 #define PUB_DICT_FILENAME "gdcm.dic"
113 #define DICT_ELEM "DicomDir.dic"
114 #define DICT_TS "dicomTS.dic"
115 #define DICT_VR "dicomVR.dic"
116 #define DICT_GROUP_NAME "DictGroupName.dic"
118 GDCM_EXPORT extern const std::string GDCM_UNKNOWN;
119 GDCM_EXPORT extern const std::string GDCM_UNFOUND;
120 GDCM_EXPORT extern const std::string GDCM_BINLOADED;
121 GDCM_EXPORT extern const std::string GDCM_NOTLOADED;
122 GDCM_EXPORT extern const std::string GDCM_UNREAD;
123 GDCM_EXPORT extern const std::string GDCM_NOTASCII;
124 GDCM_EXPORT extern const std::string GDCM_PIXELDATA;
125 /// \brief TagKey is made to hold the standard Dicom Tag
126 /// (Group number, Element number)
127 /// Instead of using the two '16 bits integers' as the Hask Table key, we
128 /// converted into a string (e.g. 0x0018,0x0050 converted into "0018|0050")
129 /// It appears to be a huge waste of time.
130 /// We'll fix the mess up -without any change in the API- as soon as the bench
131 /// marks are fully performed.
138 /* ostream operator for TagKey */
139 inline std::ostream& operator<<(std::ostream& _O, TagKey _val)
141 _O.setf( std::ios::right);
142 return (_O << std::hex << std::setw( 4 ) << std::setfill( '0' )
143 << _val.tab[0] << '|' << std::setw( 4 ) << std::setfill( '0' )
144 << _val.tab[1] << std::setfill( ' ' ) << std::dec);
146 inline bool operator==(TagKey _self, TagKey _val)
148 return _self.tagkey == _val.tagkey;
150 inline bool operator<(TagKey _self, TagKey _val)
152 // This expression is a tad faster but PrintFile output
153 // is more difficult to read
154 //return _self.tagkey < _val.tagkey;
156 // More usal order of dicom tags:
157 if( _self.tab[0] == _val.tab[0] )
158 return _self.tab[1] < _val.tab[1];
159 return _self.tab[0] < _val.tab[0];
162 typedef std::string TagKey;
164 #if defined(_MSC_VER) && (_MSC_VER == 1200)
165 // Doing everything within gdcm namespace to avoid polluting 3d party software
166 inline std::ostream& operator<<(std::ostream& _O, std::string _val)
168 return _O << _val.c_str();
172 /// \brief TagName is made to hold the 'non hexa" fields (VR, VM, Name)
174 typedef std::string TagName;
176 /// \brief various types of a DICOM file (for internal use only)
179 ExplicitVR, // DicomDir is in this case. Except when it's ImplicitVR !...
185 /// \brief type of the elements composing a DICOMDIR (for internal use only)
196 /// \brief comparison operators (as used in SerieHelper::AddRestriction() )
206 /// \brief Loading mode
209 LD_ALL = 0x00000000, // Load all
210 LD_NOSEQ = 0x00000001, // Don't load Sequences
211 LD_NOSHADOW = 0x00000002, // Don't load odd groups
212 LD_NOSHADOWSEQ = 0x00000004 // Don't load Sequences if they belong
214 // (*exclusive* from LD_NOSEQ and LD_NOSHADOW)
218 * \brief structure, for internal use only
222 /// DicomGroup number
223 unsigned short int Group;
224 /// DicomElement number
225 unsigned short int Elem;
226 /// value (coded as a std::string) of the Element
231 //-----------------------------------------------------------------------------