MeVisLab Toolbox Reference
DCMTree_Lib.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef DCM_TREE_LIB_H
14 #define DCM_TREE_LIB_H
15 
16 #ifdef _MSC_VER
17  // Disable some boost and system header warnings.
18  // 4242: conversion from "a" to "b", possible loss of data
19  // 4265: 'boost::exception_detail::error_info_container' : class has virtual functions, but destructor is not virtual
20  // 4350: behaviour change
21  // 4365: signed/unsigned mismatch
22  // 4512: assignment operator could not be generate
23  // 4548: expression before comma has no effect; expected expression with side-effect
24  // 4619: #pragma warning : there is no warning number '4284'
25  // 4623: default constructor was implicitly defined as deleted because a base class default constructor is inaccessible or deleted
26  #pragma warning (push)
27  #pragma warning (disable : 4242 4265 4350 4365 4512 4548 4619 4623)
28 #endif
29 
30 #include <utility>
31 #include <map>
32 #include <vector>
33 #include <string>
34 
35 #include <boost/smart_ptr.hpp>
36 
37 #if defined (__GNUC__) && (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 3)
38  // Including string.h here is required since gcc version 4.3. Older gcc
39  // versions provide it in a header file that is not included.
40  #include <string.h>
41 #endif
42 
43 #if defined (WIN32) && (_MSC_VER <= 1200) && defined(_XTREE_)
44 # pragma message("You do not have a patched XTREE file from $(MLAB_MeVisLab_Foundation)\\BuildTools\\win32\\patches\\msvc6\\XTREE or http://www.dinkumware.com/vc_fixes.html installed.")
45 # pragma message("Replace the old XTREE file in 'Program Files\\Microsoft Visual Studio\\VC98\\Include' with the patched version.")
46 # error "YOUR MODULE WILL NOT WORK."
47 #endif
48 
49 #ifdef _MSC_VER
50  #pragma warning (pop)
51 #endif
52 
53 #include "DCMTree_Defines.h"
54 #include "DCMTree_Serialization.h"
55 
56 
57 namespace DCMTree
58 {
59  class Tag;
60 
62  typedef boost::shared_ptr<Tag> TagPtr;
63  typedef boost::shared_ptr<const Tag> Const_TagPtr;
64 
65  class MFPixelTag;
67  typedef boost::shared_ptr<MFPixelTag> MFPixelTagPtr;
68  typedef boost::shared_ptr<const MFPixelTag> Const_MFPixelTagPtr;
69 
70  class Tree;
72  typedef boost::shared_ptr<Tree> TreePtr;
73  typedef boost::shared_ptr<const Tree> Const_TreePtr;
74 
75  class Message;
76  typedef boost::shared_ptr<Message> MessagePtr;
77  typedef boost::shared_ptr<const Message> Const_MessagePtr;
78 
79  class TagInfo;
81  typedef boost::shared_ptr<TagInfo> TagInfoPtr;
82  typedef boost::shared_ptr<const TagInfo> Const_TagInfoPtr;
83 
85  typedef std::vector<TreePtr> TreePtrVector;
86 
87  class Value;
88 
90  typedef boost::shared_ptr<Value> ValuePtr;
91  typedef boost::shared_ptr<const Value> Const_ValuePtr;
92 
94 
96  typedef boost::shared_ptr<CharacterSetConverter> CharacterSetConverterPtr;
97  typedef boost::shared_ptr<const CharacterSetConverter> Const_CharacterSetConverterPtr;
98 
99  typedef boost::shared_array<unsigned char> pixel_cont_t;
100 
105  struct PixelData {
106  PixelData() : _data(nullptr) {};
107  PixelData(const pixel_cont_t& data) : _data(data.get()),_sharedData(data) {};
108  PixelData(const unsigned char* data) : _data(data), _sharedData(pixel_cont_t()) {};
109 
110  operator bool() const {
111  return _data != nullptr;
112  }
113 
114  void operator=(const pixel_cont_t& data) {
115  _data = data.get();
116  _sharedData = data;
117  }
118 
119  void operator=(unsigned char* data) {
120  _data = data;
121  _sharedData = pixel_cont_t();
122  }
123 
124  const unsigned char* get() const { return _data; }
125 
126  private:
127  const unsigned char* _data;
128  pixel_cont_t _sharedData;
129  };
130 
131  class Dict;
132 
134  typedef boost::shared_ptr<Dict> DictPtr;
135  typedef boost::shared_ptr<const Dict> Const_DictPtr;
136 
137  class Exception;
138 
140  typedef boost::shared_ptr<Exception> ExceptionPtr;
141  typedef boost::shared_ptr<const Exception> Const_ExceptionPtr;
142 
144  class TagId;
145  typedef boost::shared_ptr<TagId> TagIdPtr;
146  typedef std::pair<TagIdPtr,TagIdPtr> TagIdPtrPair;
147  typedef unsigned int RawTagId;
148 
150  typedef std::vector<TagId> TagIdVector;
151 
153  typedef boost::shared_ptr<TagIdVector> TagIdVectorPtr;
154  typedef boost::shared_ptr<const TagIdVector> Const_TagIdVectorPtr;
155 
157  typedef std::map<TagId,TagPtr> TagPtrMap;
158  typedef std::map<TagId,Const_TagPtr> Const_TagPtrMap;
159  typedef boost::shared_ptr<Const_TagPtrMap> Const_TagPtrMapPtr;
160 
161  class Reader;
162 
164  typedef boost::shared_ptr<Reader> ReaderPtr;
165  typedef boost::shared_ptr<const Reader> Const_ReaderPtr;
166 
168  class StructuredMF;
169  typedef boost::shared_ptr<StructuredMF> StructuredMFPtr;
170  typedef boost::shared_ptr<const StructuredMF> Const_StructuredMFPtr;
171 
173  typedef std::pair<unsigned,unsigned> TagValueMultiplicity;
174 
176  class IOParameter;
177  typedef boost::shared_ptr<IOParameter> IOParameterPtr;
178 
181  {
182  Date( int year = 0, int month = 0, int day = 0 );
183 
184  unsigned short _year; // 0000-9999
185  unsigned char _month; // 00-12
186  unsigned char _day; // 00-31
187  };
188 
191  {
192  Time( int hour = 0, int minute = 0, int second = 0, int msec = 0 );
193 
194  unsigned char _hour; // 00-23
195  unsigned char _minute; // 00-59
196  unsigned char _second; // 00-59
197  double _fraction; // 0.0-0.999999
198  };
199 
201  typedef std::pair<Date,Time> DateTime;
202 
207  enum Vr
208  {
209  AE, AS, CS, DA, DS, DT, IS, LO, LT, PN, SH, ST, TM, UT,
210  UI, SS, US, AT, SL, UL, FL, FD, OB, OW, OL, OF, SQ, UN, UR, OD, UC, VRCOUNT
211  };
212 
213  typedef std::vector<Vr> VrVector;
214 
216  enum VRCType
217  {
221  TY_Att
222  };
223 
226  {
227  NoError, // warning only
231  };
232 
234  DCMTREE_EXPORT bool isType (Vr vr,VRCType vrctype);
235 
238  {
271  };
272 
280  {
283  Owned
284  };
285 
287 
291  DCMTREE_EXPORT std::string toString (const Vr vr);
292 
296  DCMTREE_EXPORT Vr toVr (const std::string &vrstr);
297 
301  DCMTREE_EXPORT bool isValidVrStr (const std::string &vrstr);
302 
307  DCMTREE_EXPORT std::string toString (const TransferSyntax syntax);
308 
312  DCMTREE_EXPORT std::string toString (const TagValueMultiplicity &mult);
313 }
314 
316 {
317  void serializeX (Sink &sink,const DCMTree::TransferSyntax &syntax);
319  void serializeX (Sink &sink,const DCMTree::Vr &vr);
321 }
322 
323 #endif
324 
325 
#define DCMTREE_EXPORT
class CharacterSetConverter is used for converting string values from one DICOM character set to anot...
base class to wrap parameters to be used for reading/writing messages this is needed because the tool...
class to hold data of an DICOM message, which is not part of the message itself.
Support for structured multi-frame (SMF) DICOM objects.
Class to wrap a tag-id.
Definition: DCMTree_TagId.h:40
Class to carry meta-information about a specific tag.
Class to store tag-values.
Definition: DCMTree_Value.h:45
Interface of a data sink for the serialization of objects.
Interface of a data source for the deserialization of objects.
void serializeX(Sink &sink, const DCMTree::TransferSyntax &syntax)
void deserializeX(Source &source, DCMTree::TransferSyntax &syntax)
class to dump a DCMTree dicom message into a human readable file this class could be used as a starte...
boost::shared_ptr< const Tag > Const_TagPtr
Definition: DCMTree_Lib.h:63
std::pair< Date, Time > DateTime
DateTime.
Definition: DCMTree_Lib.h:201
Vr
DICOM VR.
Definition: DCMTree_Lib.h:208
boost::shared_ptr< const StructuredMF > Const_StructuredMFPtr
Definition: DCMTree_Lib.h:170
boost::shared_ptr< Value > ValuePtr
shared-pointer to a tag-value
Definition: DCMTree_Lib.h:87
boost::shared_ptr< TagInfo > TagInfoPtr
shared pointer to a DCMTree::TagInfo
Definition: DCMTree_Lib.h:79
boost::shared_ptr< MFPixelTag > MFPixelTagPtr
shared-pointer to multi-frame tag
Definition: DCMTree_Lib.h:65
TagSelector
constants selecting a tag subset in a chain of incrementally modified DICOM trees.
Definition: DCMTree_Lib.h:280
@ Owned
Only tags contained in the front most tree, omitting all inherited tags.
Definition: DCMTree_Lib.h:283
@ NonRoot
Same as AllTags, except tags that are only contained in the root tree.
Definition: DCMTree_Lib.h:282
@ AllTags
Select all tags from all trees in the chain that are not deleted in a successor.
Definition: DCMTree_Lib.h:281
boost::shared_ptr< const CharacterSetConverter > Const_CharacterSetConverterPtr
boost::shared_ptr< const Value > Const_ValuePtr
Definition: DCMTree_Lib.h:91
std::map< TagId, TagPtr > TagPtrMap
a map from tag-id to TagPtr
Definition: DCMTree_Lib.h:157
boost::shared_ptr< Message > MessagePtr
Definition: DCMTree_Lib.h:75
boost::shared_ptr< StructuredMF > StructuredMFPtr
Definition: DCMTree_Lib.h:168
boost::shared_ptr< IOParameter > IOParameterPtr
boost::shared_ptr< const Tree > Const_TreePtr
Definition: DCMTree_Lib.h:73
boost::shared_ptr< const Message > Const_MessagePtr
Definition: DCMTree_Lib.h:77
DCMTREE_EXPORT bool isType(Vr vr, VRCType vrctype)
defines the mapping of vr to VRCType
TransferSyntax
DICOM transfer syntaxes.
Definition: DCMTree_Lib.h:238
@ JPEG_SPEC_HIER_21_23
Definition: DCMTree_Lib.h:258
@ INVALID_TRANSFER_SYNTAX
Definition: DCMTree_Lib.h:239
@ JPEG_FULL_PROG_NON_HIER_11_13
Definition: DCMTree_Lib.h:252
@ JPEG_2000_MC
Definition: DCMTree_Lib.h:270
@ JPEG_LOSSLESS_HIER_28
Definition: DCMTree_Lib.h:261
@ JPEG_2000_LOSSLESS_ONLY
Definition: DCMTree_Lib.h:264
@ MPEG2_MPML
Definition: DCMTree_Lib.h:268
@ JPEG_LOSSLESS_NON_HIER_14
Definition: DCMTree_Lib.h:253
@ IMPLICIT_BIG_ENDIAN
Definition: DCMTree_Lib.h:243
@ JPEG_SPEC_NON_HIER_7_9
Definition: DCMTree_Lib.h:250
@ EXPLICIT_BIG_ENDIAN
Definition: DCMTree_Lib.h:242
@ JPEG_SPEC_NON_HIER_6_8
Definition: DCMTree_Lib.h:249
@ JPEG_FULL_PROG_NON_HIER_10_12
Definition: DCMTree_Lib.h:251
@ JPEG_BASELINE
Definition: DCMTree_Lib.h:246
@ JPEG_2000_MC_LOSSLESS_ONLY
Definition: DCMTree_Lib.h:269
@ JPEG_LS_LOSSLESS
Definition: DCMTree_Lib.h:266
@ JPEG_LOSSLESS_HIER_29
Definition: DCMTree_Lib.h:262
@ JPEG_EXTENDED_HIER_17_19
Definition: DCMTree_Lib.h:256
@ JPEG_LOSSLESS_HIER_14
Definition: DCMTree_Lib.h:263
@ DEFLATED_EXPLICIT_LITTLE_ENDIAN
Definition: DCMTree_Lib.h:244
@ JPEG_LOSSLESS_NON_HIER_15
Definition: DCMTree_Lib.h:254
@ EXPLICIT_LITTLE_ENDIAN
Definition: DCMTree_Lib.h:241
@ JPEG_FULL_PROG_HIER_24_26
Definition: DCMTree_Lib.h:259
@ JPEG_SPEC_HIER_20_22
Definition: DCMTree_Lib.h:257
@ JPEG_EXTENDED_HIER_16_18
Definition: DCMTree_Lib.h:255
@ JPEG_EXTENDED_2_4
Definition: DCMTree_Lib.h:247
@ JPEG_LS_LOSSY
Definition: DCMTree_Lib.h:267
@ JPEG_EXTENDED_3_5
Definition: DCMTree_Lib.h:248
@ JPEG_FULL_PROG_HIER_25_27
Definition: DCMTree_Lib.h:260
@ IMPLICIT_LITTLE_ENDIAN
Definition: DCMTree_Lib.h:240
std::map< TagId, Const_TagPtr > Const_TagPtrMap
Definition: DCMTree_Lib.h:158
TransferSyntax defaultTransferSyntax()
VRCType
vr interpretation in C++
Definition: DCMTree_Lib.h:217
@ TY_DateTime
Definition: DCMTree_Lib.h:218
boost::shared_ptr< const Exception > Const_ExceptionPtr
Definition: DCMTree_Lib.h:141
boost::shared_array< unsigned char > pixel_cont_t
Definition: DCMTree_Lib.h:99
boost::shared_ptr< const TagInfo > Const_TagInfoPtr
Definition: DCMTree_Lib.h:82
boost::shared_ptr< const MFPixelTag > Const_MFPixelTagPtr
Definition: DCMTree_Lib.h:68
boost::shared_ptr< TagId > TagIdPtr
Definition: DCMTree_Lib.h:144
boost::shared_ptr< const TagIdVector > Const_TagIdVectorPtr
Definition: DCMTree_Lib.h:154
boost::shared_ptr< Const_TagPtrMap > Const_TagPtrMapPtr
Definition: DCMTree_Lib.h:159
boost::shared_ptr< Tag > TagPtr
shared-pointer to tag
Definition: DCMTree_Lib.h:59
boost::shared_ptr< const Reader > Const_ReaderPtr
Definition: DCMTree_Lib.h:165
std::vector< TreePtr > TreePtrVector
a vector of TreePtr - used for sequences
Definition: DCMTree_Lib.h:85
boost::shared_ptr< CharacterSetConverter > CharacterSetConverterPtr
shared-pointer to a DCMTree::CharacterSetConverter
std::pair< TagIdPtr, TagIdPtr > TagIdPtrPair
Definition: DCMTree_Lib.h:146
boost::shared_ptr< Exception > ExceptionPtr
shared-pointer to a DCMTree::Exception
Definition: DCMTree_Lib.h:137
boost::shared_ptr< const Dict > Const_DictPtr
Definition: DCMTree_Dict.h:53
std::vector< TagId > TagIdVector
a vector of TagIds
Definition: DCMTree_Lib.h:150
ErrorCode
Error codes used for logging warnings and errors.
Definition: DCMTree_Lib.h:226
@ InvalidData
Definition: DCMTree_Lib.h:229
@ WritingDataFailed
Definition: DCMTree_Lib.h:230
@ MissingTag
Definition: DCMTree_Lib.h:228
std::pair< unsigned, unsigned > TagValueMultiplicity
the multiplicity of a tag, first=min second=max
Definition: DCMTree_Lib.h:173
boost::shared_ptr< Tree > TreePtr
shared pointer to a DCMTree::Tree
Definition: DCMTree_Lib.h:70
boost::shared_ptr< TagIdVector > TagIdVectorPtr
a shared-pointer to a vector of TagIds
Definition: DCMTree_Lib.h:153
DCMTREE_EXPORT bool isValidVrStr(const std::string &vrstr)
check if the given string could be a valid/known vr
unsigned int RawTagId
Definition: DCMTree_Lib.h:147
DCMTREE_EXPORT std::string toString(const Vr vr)
convert a vr to a readable string
std::vector< Vr > VrVector
Definition: DCMTree_Lib.h:213
boost::shared_ptr< Reader > ReaderPtr
a shared-pointer to DCMTree::Reader
Definition: DCMTree_Lib.h:161
boost::shared_ptr< Dict > DictPtr
shared-pointer to a DCMTree::Dict
Definition: DCMTree_Dict.h:51
DCMTREE_EXPORT Vr toVr(const std::string &vrstr)
convert a string to a vr
boost::graph_traits< ml_graph_ptr >::vertex_descriptor source(graph_traits< ml_graph_ptr >::edge_descriptor e, const ml_graph_ptr)
Returns the vertex descriptor for u of the edge (u,v) represented by e.
Date class for DCMTree library.
Definition: DCMTree_Lib.h:181
unsigned short _year
Definition: DCMTree_Lib.h:184
unsigned char _month
Definition: DCMTree_Lib.h:185
Date(int year=0, int month=0, int day=0)
unsigned char _day
Definition: DCMTree_Lib.h:186
Contains pixel data which is either shared/ref counted or a direct pointer.
Definition: DCMTree_Lib.h:105
const unsigned char * get() const
Definition: DCMTree_Lib.h:124
PixelData(const unsigned char *data)
Definition: DCMTree_Lib.h:108
PixelData(const pixel_cont_t &data)
Definition: DCMTree_Lib.h:107
void operator=(const pixel_cont_t &data)
Definition: DCMTree_Lib.h:114
void operator=(unsigned char *data)
Definition: DCMTree_Lib.h:119
Time class for DCMTree library.
Definition: DCMTree_Lib.h:191
double _fraction
Definition: DCMTree_Lib.h:197
unsigned char _minute
Definition: DCMTree_Lib.h:195
unsigned char _second
Definition: DCMTree_Lib.h:196
Time(int hour=0, int minute=0, int second=0, int msec=0)
unsigned char _hour
Definition: DCMTree_Lib.h:194