annotate Plugins/Samples/Common/DicomPath.cpp @ 3821:f2488b645f5f transcoding

adding storage commitment to DicomAssociation
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 09 Apr 2020 18:29:42 +0200
parents 94f4a18a79cc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
3640
94f4a18a79cc upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3580
diff changeset
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU General Public License as
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * published by the Free Software Foundation, either version 3 of the
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * License, or (at your option) any later version.
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * In addition, as a special exception, the copyright holders of this
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * program give permission to link the code of its release with the
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * OpenSSL project's "OpenSSL" library (or with modified versions of it
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * that use the same license as the "OpenSSL" library), and distribute
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 * the linked executables. You must obey the GNU General Public License
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * in all respects for all of the code used other than "OpenSSL". If you
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * modify file(s) with this exception, you may extend this exception to
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * your version of the file(s), but you are not obligated to do so. If
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 * you do not wish to do so, delete this exception statement from your
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 * version. If you delete this exception statement from all source files
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 * in the program, then also delete it here.
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 *
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 * This program is distributed in the hope that it will be useful, but
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 * WITHOUT ANY WARRANTY; without even the implied warranty of
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 * General Public License for more details.
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 *
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 * You should have received a copy of the GNU General Public License
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 * along with this program. If not, see <http://www.gnu.org/licenses/>.
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 **/
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 #include "DicomPath.h"
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35
2237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
36 #include "OrthancPluginException.h"
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37
3580
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
38 #include <boost/lexical_cast.hpp>
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
39
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 namespace OrthancPlugins
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 const DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth) const
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 if (depth >= prefix_.size())
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
2237
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2179
diff changeset
46 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 else
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 return prefix_[depth];
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
3381
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
55 DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth)
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
56 {
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
57 if (depth >= prefix_.size())
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
58 {
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
59 ORTHANC_PLUGINS_THROW_EXCEPTION(ParameterOutOfRange);
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
60 }
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
61 else
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
62 {
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
63 return prefix_[depth];
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
64 }
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
65 }
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
66
a6c590cb8181 OrthancPlugins::DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3060
diff changeset
67
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 DicomPath::DicomPath(const DicomTag& sequence,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 size_t index,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 const DicomTag& tag) :
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 finalTag_(tag)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 AddToPrefix(sequence, index);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 DicomPath::DicomPath(const DicomTag& sequence1,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 size_t index1,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 const DicomTag& sequence2,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 size_t index2,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 const DicomTag& tag) :
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 finalTag_(tag)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 AddToPrefix(sequence1, index1);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 AddToPrefix(sequence2, index2);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 }
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 DicomPath::DicomPath(const DicomTag& sequence1,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 size_t index1,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 const DicomTag& sequence2,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 size_t index2,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 const DicomTag& sequence3,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 size_t index3,
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 const DicomTag& tag) :
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 finalTag_(tag)
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 {
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 AddToPrefix(sequence1, index1);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 AddToPrefix(sequence2, index2);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 AddToPrefix(sequence3, index3);
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 }
3580
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
102
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
103
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
104 std::string DicomPath::Format() const
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
105 {
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
106 std::string s;
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
107
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
108 for (size_t i = 0; i < GetPrefixLength(); i++)
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
109 {
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
110 s += (GetPrefixTag(i).FormatHexadecimal() + " / " +
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
111 boost::lexical_cast<std::string>(i) + " / ");
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
112 }
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
113
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
114 return s + GetFinalTag().FormatHexadecimal();
46a8050583a1 OrthancPlugins::DicomPath::Format()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3381
diff changeset
115 }
2179
de32f3b4ff09 shared toolbox to access DICOM datasets from plugins
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }