0
|
1 /**
|
|
2 * Stone of Orthanc
|
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
|
|
4 * Department, University Hospital of Liege, Belgium
|
|
5 *
|
|
6 * This program is free software: you can redistribute it and/or
|
|
7 * modify it under the terms of the GNU General Public License as
|
|
8 * published by the Free Software Foundation, either version 3 of the
|
|
9 * License, or (at your option) any later version.
|
|
10 *
|
|
11 * In addition, as a special exception, the copyright holders of this
|
|
12 * program give permission to link the code of its release with the
|
|
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it
|
|
14 * that use the same license as the "OpenSSL" library), and distribute
|
|
15 * the linked executables. You must obey the GNU General Public License
|
|
16 * in all respects for all of the code used other than "OpenSSL". If you
|
|
17 * modify file(s) with this exception, you may extend this exception to
|
|
18 * your version of the file(s), but you are not obligated to do so. If
|
|
19 * you do not wish to do so, delete this exception statement from your
|
|
20 * version. If you delete this exception statement from all source files
|
|
21 * in the program, then also delete it here.
|
|
22 *
|
|
23 * This program is distributed in the hope that it will be useful, but
|
|
24 * WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
26 * General Public License for more details.
|
|
27 *
|
|
28 * You should have received a copy of the GNU General Public License
|
|
29 * along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
30 **/
|
|
31
|
|
32
|
|
33 #pragma once
|
|
34
|
|
35 #include "GeometryToolbox.h"
|
|
36 #include "../Messaging/IOrthancConnection.h"
|
|
37
|
|
38 #include <map>
|
|
39 #include <stdint.h>
|
|
40 #include <json/value.h>
|
|
41
|
|
42 namespace OrthancStone
|
|
43 {
|
|
44 // This class is NOT thread-safe
|
|
45 // This is a lightweight alternative to Orthanc::DicomMap
|
|
46 class DicomDataset : public boost::noncopyable
|
|
47 {
|
|
48 public:
|
|
49 typedef std::pair<uint16_t, uint16_t> Tag;
|
|
50
|
|
51 private:
|
|
52 typedef std::map<Tag, std::string> Values;
|
|
53
|
|
54 Values values_;
|
|
55
|
|
56 void Parse(const std::string& content);
|
|
57
|
|
58 void Parse(const Json::Value& content);
|
|
59
|
|
60 public:
|
|
61 DicomDataset(const std::string& content)
|
|
62 {
|
|
63 Parse(content);
|
|
64 }
|
|
65
|
|
66 DicomDataset(const Json::Value& content)
|
|
67 {
|
|
68 Parse(content);
|
|
69 }
|
|
70
|
|
71 DicomDataset(IOrthancConnection& orthanc,
|
|
72 const std::string& instanceId);
|
|
73
|
|
74 bool HasTag(const Tag& tag) const
|
|
75 {
|
|
76 return values_.find(tag) != values_.end();
|
|
77 }
|
|
78
|
|
79 std::string GetStringValue(const Tag& tag) const;
|
|
80
|
|
81 std::string GetStringValue(const Tag& tag,
|
|
82 const std::string& defaultValue) const;
|
|
83
|
|
84 float GetFloatValue(const Tag& tag) const;
|
|
85
|
|
86 double GetDoubleValue(const Tag& tag) const;
|
|
87
|
|
88 int GetIntegerValue(const Tag& tag) const;
|
|
89
|
|
90 unsigned int GetUnsignedIntegerValue(const Tag& tag) const;
|
|
91
|
|
92 void GetVectorValue(Vector& vector,
|
|
93 const Tag& tag,
|
|
94 size_t expectedSize) const;
|
|
95
|
|
96 void GetVectorValue(Vector& vector,
|
|
97 const Tag& tag) const;
|
|
98
|
|
99 void Print() const;
|
|
100
|
|
101 bool IsGrayscale() const;
|
|
102
|
|
103 void GetPixelSpacing(double& spacingX,
|
|
104 double& spacingY) const;
|
|
105 };
|
|
106
|
|
107
|
|
108 static const DicomDataset::Tag DICOM_TAG_COLUMNS(0x0028, 0x0011);
|
|
109 static const DicomDataset::Tag DICOM_TAG_IMAGE_ORIENTATION_PATIENT(0x0020, 0x0037);
|
|
110 static const DicomDataset::Tag DICOM_TAG_IMAGE_POSITION_PATIENT(0x0020, 0x0032);
|
|
111 static const DicomDataset::Tag DICOM_TAG_NUMBER_OF_FRAMES(0x0028, 0x0008);
|
|
112 static const DicomDataset::Tag DICOM_TAG_PIXEL_REPRESENTATION(0x0028, 0x0103);
|
|
113 static const DicomDataset::Tag DICOM_TAG_PIXEL_SPACING(0x0028, 0x0030);
|
|
114 static const DicomDataset::Tag DICOM_TAG_RESCALE_INTERCEPT(0x0028, 0x1052);
|
|
115 static const DicomDataset::Tag DICOM_TAG_RESCALE_SLOPE(0x0028, 0x1053);
|
|
116 static const DicomDataset::Tag DICOM_TAG_ROWS(0x0028, 0x0010);
|
|
117 static const DicomDataset::Tag DICOM_TAG_SLICE_THICKNESS(0x0018, 0x0050);
|
|
118 static const DicomDataset::Tag DICOM_TAG_WINDOW_CENTER(0x0028, 0x1050);
|
|
119 static const DicomDataset::Tag DICOM_TAG_WINDOW_WIDTH(0x0028, 0x1051);
|
|
120 static const DicomDataset::Tag DICOM_TAG_PHOTOMETRIC_INTERPRETATION(0x0028, 0x0004);
|
|
121 }
|