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