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