1 /*=========================================================================
4 Module: $RCSfile: gdcmCommon.h,v $
6 Date: $Date: 2005/10/18 18:39:49 $
7 Version: $Revision: 1.96 $
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"
23 #include "gdcmSystem.h"
27 // FIXME: Should rewrite this:
32 #if defined(_MSC_VER) && (_MSC_VER == 1200)
33 /* ostream operator for std::string since VS6 does not provide it*/
37 //-----------------------------------------------------------------------------
38 /// \brief namespace for Grass root DiCoM
42 // Centralize information about the gdcm dictionary in only one file:
44 # define PUB_DICT_PATH "../Dicts/"
46 #define PUB_DICT_NAME "DicomV3Dict"
47 #define PUB_DICT_FILENAME "gdcm.dic"
48 #define DICT_ELEM "DicomDir.dic"
49 #define DICT_TS "dicomTS.dic"
50 #define DICT_VR "dicomVR.dic"
51 #define DICT_GROUP_NAME "DictGroupName.dic"
53 GDCM_EXPORT extern const std::string GDCM_UNKNOWN;
54 GDCM_EXPORT extern const std::string GDCM_UNFOUND;
55 GDCM_EXPORT extern const std::string GDCM_BINLOADED;
56 GDCM_EXPORT extern const std::string GDCM_NOTLOADED;
57 GDCM_EXPORT extern const std::string GDCM_UNREAD;
58 GDCM_EXPORT extern const std::string GDCM_NOTASCII;
59 GDCM_EXPORT extern const std::string GDCM_PIXELDATA;
61 GDCM_EXPORT extern const std::string GDCM_VRUNKNOWN;
63 /// \brief TagKey is made to hold the standard Dicom Tag
64 /// (Group number, Element number)
65 /// Instead of using the two '16 bits integers' as the Hask Table key, we
66 /// converted into a string (e.g. 0x0018,0x0050 converted into "0018|0050")
67 /// It appears to be a huge waste of time.
68 /// We'll fix the mess up -without any change in the API- as soon as the bench
69 /// marks are fully performed.
76 /* ostream operator for TagKey */
77 inline std::ostream& operator<<(std::ostream& _O, TagKey _val)
79 _O.setf( std::ios::right);
80 return (_O << std::hex << std::setw( 4 ) << std::setfill( '0' )
81 << _val.tab[0] << '|' << std::setw( 4 ) << std::setfill( '0' )
82 << _val.tab[1] << std::setfill( ' ' ) << std::dec);
84 inline bool operator==(TagKey _self, TagKey _val)
86 return _self.tagkey == _val.tagkey;
88 inline bool operator<(TagKey _self, TagKey _val)
90 // This expression is a tad faster but PrintFile output
91 // is more difficult to read
92 //return _self.tagkey < _val.tagkey;
94 // More usal order of dicom tags:
95 if( _self.tab[0] == _val.tab[0] )
96 return _self.tab[1] < _val.tab[1];
97 return _self.tab[0] < _val.tab[0];
100 typedef std::string TagKey;
102 #if defined(_MSC_VER) && (_MSC_VER == 1200)
103 // Doing everything within gdcm namespace to avoid polluting 3d party software
104 inline std::ostream& operator<<(std::ostream& _O, std::string _val)
106 return _O << _val.c_str();
110 /// \brief TagName is made to hold the 'non hexa" fields (VR, VM, Name)
112 typedef std::string TagName;
114 /// \brief various types of a DICOM file (for internal use only)
117 ExplicitVR, // DicomDir is in this case. Except when it's ImplicitVR !...
124 /// \brief type of the elements composing a DICOMDIR (for internal use only)
135 /// \brief comparison operators (as used in SerieHelper::AddRestriction() )
145 /// \brief Loading mode
148 LD_ALL = 0x00000000, // Load all
149 LD_NOSEQ = 0x00000001, // Don't load Sequences
150 LD_NOSHADOW = 0x00000002, // Don't load odd groups
151 LD_NOSHADOWSEQ = 0x00000004 // Don't load Sequences if they belong
153 // (*exclusive* from LD_NOSEQ and LD_NOSHADOW)
157 * \brief structure, for internal use only
161 /// DicomGroup number
162 unsigned short int Group;
163 /// DicomElement number
164 unsigned short int Elem;
165 /// value (coded as a std::string) of the Element
170 //-----------------------------------------------------------------------------