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#ifdef _MSC_VER
44 #pragma warning (pop)
45#endif
46
47#include "DCMTree_Defines.h"
49
50
51namespace DCMTree
52{
53 class Tag;
54
56 typedef boost::shared_ptr<Tag> TagPtr;
57 typedef boost::shared_ptr<const Tag> Const_TagPtr;
58
59 class MFPixelTag;
61 typedef boost::shared_ptr<MFPixelTag> MFPixelTagPtr;
62 typedef boost::shared_ptr<const MFPixelTag> Const_MFPixelTagPtr;
63
64 class Tree;
66 typedef boost::shared_ptr<Tree> TreePtr;
67 typedef boost::shared_ptr<const Tree> Const_TreePtr;
68
69 class Message;
70 typedef boost::shared_ptr<Message> MessagePtr;
71 typedef boost::shared_ptr<const Message> Const_MessagePtr;
72
73 class TagInfo;
75 typedef boost::shared_ptr<TagInfo> TagInfoPtr;
76 typedef boost::shared_ptr<const TagInfo> Const_TagInfoPtr;
77
79 typedef std::vector<TreePtr> TreePtrVector;
80
81 class Value;
82
84 typedef boost::shared_ptr<Value> ValuePtr;
85 typedef boost::shared_ptr<const Value> Const_ValuePtr;
86
88
90 typedef boost::shared_ptr<CharacterSetConverter> CharacterSetConverterPtr;
91 typedef boost::shared_ptr<const CharacterSetConverter> Const_CharacterSetConverterPtr;
92
93 typedef boost::shared_array<unsigned char> pixel_cont_t;
94
99 struct PixelData {
100 PixelData() : _data(nullptr) {};
101 PixelData(const pixel_cont_t& data) : _data(data.get()),_sharedData(data) {};
102 PixelData(const unsigned char* data) : _data(data), _sharedData(pixel_cont_t()) {};
103
104 operator bool() const {
105 return _data != nullptr;
106 }
107
108 void operator=(const pixel_cont_t& data) {
109 _data = data.get();
110 _sharedData = data;
111 }
112
113 void operator=(unsigned char* data) {
114 _data = data;
115 _sharedData = pixel_cont_t();
116 }
117
118 const unsigned char* get() const { return _data; }
119
120 private:
121 const unsigned char* _data;
122 pixel_cont_t _sharedData;
123 };
124
125 class Dict;
126
128 typedef boost::shared_ptr<Dict> DictPtr;
129 typedef boost::shared_ptr<const Dict> Const_DictPtr;
130
131 class Exception;
132
134 typedef boost::shared_ptr<Exception> ExceptionPtr;
135 typedef boost::shared_ptr<const Exception> Const_ExceptionPtr;
136
138 class TagId;
139 typedef boost::shared_ptr<TagId> TagIdPtr;
140 typedef std::pair<TagIdPtr,TagIdPtr> TagIdPtrPair;
141 typedef unsigned int RawTagId;
142
144 typedef std::vector<TagId> TagIdVector;
145
147 typedef boost::shared_ptr<TagIdVector> TagIdVectorPtr;
148 typedef boost::shared_ptr<const TagIdVector> Const_TagIdVectorPtr;
149
151 typedef std::map<TagId,TagPtr> TagPtrMap;
152 typedef std::map<TagId,Const_TagPtr> Const_TagPtrMap;
153 typedef boost::shared_ptr<Const_TagPtrMap> Const_TagPtrMapPtr;
154
155 class Reader;
156
158 typedef boost::shared_ptr<Reader> ReaderPtr;
159 typedef boost::shared_ptr<const Reader> Const_ReaderPtr;
160
162 class StructuredMF;
163 typedef boost::shared_ptr<StructuredMF> StructuredMFPtr;
164 typedef boost::shared_ptr<const StructuredMF> Const_StructuredMFPtr;
165
167 typedef std::pair<unsigned,unsigned> TagValueMultiplicity;
168
170 class IOParameter;
171 typedef boost::shared_ptr<IOParameter> IOParameterPtr;
172
175 {
176 Date( int year = 0, int month = 0, int day = 0 );
177
178 unsigned short _year; // 0000-9999
179 unsigned char _month; // 00-12
180 unsigned char _day; // 00-31
181 };
182
185 {
186 Time( int hour = 0, int minute = 0, int second = 0, int msec = 0 );
187
188 unsigned char _hour; // 00-23
189 unsigned char _minute; // 00-59
190 unsigned char _second; // 00-59
191 double _fraction; // 0.0-0.999999
192 };
193
195 typedef std::pair<Date,Time> DateTime;
196
201 enum Vr
202 {
203 AE, AS, CS, DA, DS, DT, IS, LO, LT, PN, SH, ST, TM, UT,
204 UI, SS, US, AT, SL, UL, FL, FD, OB, OW, OL, OF, SQ, UN, UR, OD, UC, VRCOUNT
205 };
206
207 typedef std::vector<Vr> VrVector;
208
217
226
229
266
279
281
285 DCMTREE_EXPORT std::string toString (const Vr vr);
286
290 DCMTREE_EXPORT Vr toVr (const std::string &vrstr);
291
295 DCMTREE_EXPORT bool isValidVrStr (const std::string &vrstr);
296
301 DCMTREE_EXPORT std::string toString (const TransferSyntax syntax);
302
307}
308
310{
313 void serializeX (Sink &sink,const DCMTree::Vr &vr);
314 void deserializeX (Source &source,DCMTree::Vr &vr);
315}
316
317#endif
318
319
#define DCMTREE_EXPORT
The class CharacterSetConverter is used for converting string values from one DICOM character set to ...
Base class to wrap parameters to be used for reading/writing messages.
Class to hold data of an DICOM message that is not part of the message itself.
Support for structured multi-frame (SMF) DICOM objects.
Class to wrap a tag ID.
Class to carry meta information about a specific tag.
Class to store tag values.
Interface of a data sink for the serialization of objects.
Interface of a data source for the deserialization of objects.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
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.
boost::shared_ptr< const Tag > Const_TagPtr
Definition DCMTree_Lib.h:57
std::pair< Date, Time > DateTime
DateTime.
Vr
DICOM VR.
boost::shared_ptr< const StructuredMF > Const_StructuredMFPtr
boost::shared_ptr< Value > ValuePtr
Shared pointer to a tag value.
Definition DCMTree_Lib.h:84
boost::shared_ptr< TagInfo > TagInfoPtr
Shared pointer to a DCMTree::TagInfo.
Definition DCMTree_Lib.h:75
boost::shared_ptr< MFPixelTag > MFPixelTagPtr
Shared pointer to multi-frame tag.
Definition DCMTree_Lib.h:61
TagSelector
Constants selecting a tag subset in a chain of incrementally modified DICOM trees.
@ Owned
Only tags contained in the front most tree, omitting all inherited tags.
@ NonRoot
Same as AllTags, except tags that are only contained in the root tree.
@ AllTags
Select all tags from all trees in the chain that are not deleted in a successor.
boost::shared_ptr< const CharacterSetConverter > Const_CharacterSetConverterPtr
boost::shared_ptr< const Value > Const_ValuePtr
Definition DCMTree_Lib.h:85
std::map< TagId, TagPtr > TagPtrMap
A map from tag ID to TagPtr.
boost::shared_ptr< Message > MessagePtr
Definition DCMTree_Lib.h:70
boost::shared_ptr< StructuredMF > StructuredMFPtr
boost::shared_ptr< IOParameter > IOParameterPtr
boost::shared_ptr< const Tree > Const_TreePtr
Definition DCMTree_Lib.h:67
boost::shared_ptr< const Message > Const_MessagePtr
Definition DCMTree_Lib.h:71
DCMTREE_EXPORT bool isType(Vr vr, VRCType vrctype)
Defines the mapping of VR to VRCType.
TransferSyntax
DICOM transfer syntaxes.
@ JPEG_SPEC_HIER_21_23
@ INVALID_TRANSFER_SYNTAX
@ JPEG_FULL_PROG_NON_HIER_11_13
@ JPEG_LOSSLESS_HIER_28
@ JPEG_2000_LOSSLESS_ONLY
@ JPEG_LOSSLESS_NON_HIER_14
@ IMPLICIT_BIG_ENDIAN
@ JPEG_SPEC_NON_HIER_7_9
@ EXPLICIT_BIG_ENDIAN
@ JPEG_SPEC_NON_HIER_6_8
@ JPEG_FULL_PROG_NON_HIER_10_12
@ JPEG_BASELINE
@ JPEG_2000_MC_LOSSLESS_ONLY
@ JPEG_LS_LOSSLESS
@ JPEG_LOSSLESS_HIER_29
@ JPEG_EXTENDED_HIER_17_19
@ JPEG_LOSSLESS_HIER_14
@ DEFLATED_EXPLICIT_LITTLE_ENDIAN
@ JPEG_LOSSLESS_NON_HIER_15
@ EXPLICIT_LITTLE_ENDIAN
@ JPEG_FULL_PROG_HIER_24_26
@ JPEG_SPEC_HIER_20_22
@ JPEG_EXTENDED_HIER_16_18
@ JPEG_EXTENDED_2_4
@ JPEG_LS_LOSSY
@ JPEG_EXTENDED_3_5
@ JPEG_FULL_PROG_HIER_25_27
@ IMPLICIT_LITTLE_ENDIAN
std::map< TagId, Const_TagPtr > Const_TagPtrMap
TransferSyntax defaultTransferSyntax()
VRCType
VR interpretation in C++.
boost::shared_ptr< const Exception > Const_ExceptionPtr
boost::shared_array< unsigned char > pixel_cont_t
Definition DCMTree_Lib.h:93
boost::shared_ptr< const TagInfo > Const_TagInfoPtr
Definition DCMTree_Lib.h:76
boost::shared_ptr< const MFPixelTag > Const_MFPixelTagPtr
Definition DCMTree_Lib.h:62
boost::shared_ptr< TagId > TagIdPtr
boost::shared_ptr< const TagIdVector > Const_TagIdVectorPtr
boost::shared_ptr< Const_TagPtrMap > Const_TagPtrMapPtr
boost::shared_ptr< Tag > TagPtr
Shared pointer to tag.
Definition DCMTree_Lib.h:56
boost::shared_ptr< const Reader > Const_ReaderPtr
std::vector< TreePtr > TreePtrVector
A vector of TreePtr - used for sequences.
Definition DCMTree_Lib.h:79
boost::shared_ptr< CharacterSetConverter > CharacterSetConverterPtr
Shared pointer to a DCMTree::CharacterSetConverter.
std::pair< TagIdPtr, TagIdPtr > TagIdPtrPair
boost::shared_ptr< Exception > ExceptionPtr
Shared pointer to a DCMTree::Exception.
boost::shared_ptr< const Dict > Const_DictPtr
std::vector< TagId > TagIdVector
A vector of TagIds.
ErrorCode
Error codes used for logging warnings and errors.
@ WritingDataFailed
std::pair< unsigned, unsigned > TagValueMultiplicity
The multiplicity of a tag, first=min second=max.
boost::shared_ptr< Tree > TreePtr
Shared pointer to a DCMTree::Tree.
Definition DCMTree_Lib.h:66
boost::shared_ptr< TagIdVector > TagIdVectorPtr
A shared pointer to a vector of TagIds.
DCMTREE_EXPORT bool isValidVrStr(const std::string &vrstr)
Check whether the given string could be a valid/known VR.
unsigned int RawTagId
DCMTREE_EXPORT std::string toString(const Vr vr)
Converts a VR to a readable string.
std::vector< Vr > VrVector
boost::shared_ptr< Reader > ReaderPtr
A shared pointer to DCMTree::Reader.
boost::shared_ptr< Dict > DictPtr
Shared pointer to a DCMTree::Dict.
DCMTREE_EXPORT Vr toVr(const std::string &vrstr)
Converts a string to a VR.
Date class for DCMTree library.
unsigned short _year
unsigned char _month
Date(int year=0, int month=0, int day=0)
unsigned char _day
Contains pixel data that is either shared/ref-counted or a direct pointer.
Definition DCMTree_Lib.h:99
const unsigned char * get() const
PixelData(const unsigned char *data)
PixelData(const pixel_cont_t &data)
void operator=(const pixel_cont_t &data)
void operator=(unsigned char *data)
Time class for DCMTree library.
unsigned char _minute
unsigned char _second
Time(int hour=0, int minute=0, int second=0, int msec=0)
unsigned char _hour