]> Creatis software - gdcm.git/blob - src/gdcmCommon.h
Remove useless accesses to the Dicom Dictionnary std::map
[gdcm.git] / src / gdcmCommon.h
1 /*=========================================================================
2                                                                                 
3   Program:   gdcm
4   Module:    $RCSfile: gdcmCommon.h,v $
5   Language:  C++
6   Date:      $Date: 2006/04/11 16:03:26 $
7   Version:   $Revision: 1.109 $
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 #include "gdcmMacro.h"
25 #include "gdcmVRKey.h"
26 #include <string>
27
28 //-----------------------------------------------------------------------------
29 #if defined(_WIN32) && defined(BUILD_SHARED_LIBS)
30   #ifdef gdcm_EXPORTS
31     #define GDCM_EXPORT __declspec( dllexport )
32   #else
33     #define GDCM_EXPORT __declspec( dllimport )
34   #endif
35 #else
36   #define GDCM_EXPORT
37 #endif
38
39 //-----------------------------------------------------------------------------
40 /// \brief namespace for Grass root DiCoM
41 namespace gdcm
42 {
43
44 // Centralize information about the gdcm dictionary in only one file:
45 #ifndef PUB_DICT_PATH
46 #  define PUB_DICT_PATH   "../Dicts/"
47 #endif
48 #define PUB_DICT_NAME     "DicomV3Dict"
49 #define PUB_DICT_FILENAME "gdcm.dic"
50 #define DICT_ELEM         "DicomDir.dic"
51 #define DICT_TS           "dicomTS.dic"
52 #define DICT_VR           "dicomVR.dic"
53 #define DICT_GROUP_NAME   "DictGroupName.dic"
54
55 GDCM_EXPORT extern const std::string GDCM_UNKNOWN;
56 GDCM_EXPORT extern const std::string GDCM_UNFOUND;
57 GDCM_EXPORT extern const std::string GDCM_BINLOADED;
58 GDCM_EXPORT extern const std::string GDCM_NOTLOADED;
59 GDCM_EXPORT extern const std::string GDCM_UNREAD;
60 GDCM_EXPORT extern const std::string GDCM_NOTASCII;
61 GDCM_EXPORT extern const std::string GDCM_PIXELDATA;
62
63 GDCM_EXPORT extern const std::string GDCM_VRUNKNOWN;
64
65 GDCM_EXPORT extern const char GDCM_FILESEPARATOR;
66
67 /// \brief TagKey is made to hold the standard Dicom Tag 
68 ///               (Group number, Element number)
69 /// Instead of using the two '16 bits integers' as the Hask Table key, we
70 /// converted into a string (e.g. 0x0018,0x0050 converted into "0018|0050")
71 /// It appears to be a huge waste of time.
72 /// We'll fix the mess up -without any change in the API- as soon as the bench
73 /// marks are fully performed.
74
75 #if defined(_MSC_VER) && (_MSC_VER == 1200)
76 // Doing everything within gdcm namespace to avoid polluting 3d party software
77 inline std::ostream& operator<<(std::ostream& _O, std::string _val)
78 {
79   return _O << _val.c_str();
80 }
81 #endif
82
83 /// \brief TagName is made to hold the 'non hexa" fields (VR, VM, Name) 
84 ///        of Dicom Entries
85 typedef std::string TagName;
86
87 /// \brief various types of a DICOM file (for internal use only)
88 enum FileType {
89 // note to developer : don't forget to add as well in vtkGdcmWriter.h !
90    Unknown = 0,
91    ExplicitVR, // DicomDir is in this case. Except when it's ImplicitVR !...
92    ImplicitVR,
93    ACR,
94    ACR_LIBIDO,
95    /// \todo FIXME : an encapsulated JPEG file may be 
96    ///              either ExplicitVR or ImplicitVR, right?
97    JPEG
98 };
99
100 /// \brief type of the elements composing a DICOMDIR (for internal use only)
101 enum DicomDirType {
102    DD_UNKNOWN = 0,
103    DD_META,
104    DD_PATIENT,
105    DD_STUDY,
106    DD_SERIE,
107    DD_IMAGE,
108    DD_VISIT
109 };
110
111 /// \brief comparison operators (as used in SerieHelper::AddRestriction() )
112 enum CompOperators {
113    GDCM_EQUAL = 0,
114    GDCM_DIFFERENT,
115    GDCM_GREATER,
116    GDCM_GREATEROREQUAL,
117    GDCM_LESS,
118    GDCM_LESSOREQUAL
119 };
120
121 /// \brief Loading mode
122 enum LodModeType
123 {
124    LD_ALL         = 0x00000000, // Load all
125    LD_NOSEQ       = 0x00000001, // Don't load Sequences
126    LD_NOSHADOW    = 0x00000002, // Don't load odd groups
127    LD_NOSHADOWSEQ = 0x00000004  // Don't load Sequences if they belong 
128                                 //            to an odd group
129                                 // (*exclusive* from LD_NOSEQ and LD_NOSHADOW)
130 };
131
132 /// \brief Only user knows what kind of image he is going to write  !
133 ///
134 /// -1) user created ex nihilo his own image and wants to write it as a Dicom image.
135 ///    USER_OWN_IMAGE
136 /// -2) user modified the pixels of an existing image.
137 ///    FILTERED_IMAGE
138 /// -3) user created a new image, using existing images (eg MIP, MPR, cartography image)
139 ///   CREATED_IMAGE
140 /// -4) user modified/added some tags *without processing* the pixels (anonymization...
141 ///   UNMODIFIED_PIXELS_IMAGE
142 enum ImageContentType
143 {
144 // note to developer : don't forget to add as well in vtkGdcmWriter.h !
145       USER_OWN_IMAGE = 1,
146       FILTERED_IMAGE,
147       CREATED_IMAGE,      
148       UNMODIFIED_PIXELS_IMAGE            
149 }; 
150   
151 /**
152  * \brief structure, for internal use only
153  */  
154 struct DicomElement
155 {
156    /// Dicom Group number
157    unsigned short int Group;
158    /// Dicom Element number
159    unsigned short int Elem;
160    /// Value Representation
161    VRKey VR;
162    /// value (coded as a std::string) of the Element
163    std::string Value;
164 };
165
166 } //namespace gdcm
167 //-----------------------------------------------------------------------------
168 #endif