Mercurial > hg > orthanc-stone
annotate OrthancStone/Sources/Toolbox/OrthancDatasets/DicomPath.cpp @ 1812:db341679dc9f
ViewerViewport::StoneAnnotationsRegistry
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 25 May 2021 12:32:11 +0200 |
parents | 9ac2a65d4172 |
children |
rev | line source |
---|---|
1504 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1598
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1504 | 6 * |
7 * This program is free software: you can redistribute it and/or | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public License |
1504 | 9 * as published by the Free Software Foundation, either version 3 of |
10 * the License, or (at your option) any later version. | |
11 * | |
12 * This program is distributed in the hope that it will be useful, but | |
13 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
15 * Lesser General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1512
diff
changeset
|
16 * |
1598
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
18 * License along with this program. If not, see |
8563ea5d8ae4
relicensing some files, cf. osimis bm26 and chu agreement on 2020-05-20
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
19 * <http://www.gnu.org/licenses/>. |
1504 | 20 **/ |
21 | |
22 | |
23 #include "DicomPath.h" | |
24 | |
25 #include <OrthancException.h> | |
26 | |
27 #include <boost/lexical_cast.hpp> | |
28 | |
29 namespace OrthancStone | |
30 { | |
31 const DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth) const | |
32 { | |
33 if (depth >= prefix_.size()) | |
34 { | |
35 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
36 } | |
37 else | |
38 { | |
39 return prefix_[depth]; | |
40 } | |
41 } | |
42 | |
43 | |
44 DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth) | |
45 { | |
46 if (depth >= prefix_.size()) | |
47 { | |
48 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
49 } | |
50 else | |
51 { | |
52 return prefix_[depth]; | |
53 } | |
54 } | |
55 | |
56 | |
57 DicomPath::DicomPath(const Orthanc::DicomTag& sequence, | |
58 size_t index, | |
59 const Orthanc::DicomTag& tag) : | |
60 finalTag_(tag) | |
61 { | |
62 AddToPrefix(sequence, index); | |
63 } | |
64 | |
65 | |
66 DicomPath::DicomPath(const Orthanc::DicomTag& sequence1, | |
67 size_t index1, | |
68 const Orthanc::DicomTag& sequence2, | |
69 size_t index2, | |
70 const Orthanc::DicomTag& tag) : | |
71 finalTag_(tag) | |
72 { | |
73 AddToPrefix(sequence1, index1); | |
74 AddToPrefix(sequence2, index2); | |
75 } | |
76 | |
77 | |
78 DicomPath::DicomPath(const Orthanc::DicomTag& sequence1, | |
79 size_t index1, | |
80 const Orthanc::DicomTag& sequence2, | |
81 size_t index2, | |
82 const Orthanc::DicomTag& sequence3, | |
83 size_t index3, | |
84 const Orthanc::DicomTag& tag) : | |
85 finalTag_(tag) | |
86 { | |
87 AddToPrefix(sequence1, index1); | |
88 AddToPrefix(sequence2, index2); | |
89 AddToPrefix(sequence3, index3); | |
90 } | |
91 | |
92 | |
93 static std::string FormatHexadecimal(const Orthanc::DicomTag& tag) | |
94 { | |
95 char buf[16]; | |
96 sprintf(buf, "(%04x,%04x)", tag.GetGroup(), tag.GetElement()); | |
97 return buf; | |
98 } | |
99 | |
100 | |
101 std::string DicomPath::Format() const | |
102 { | |
103 std::string s; | |
104 | |
105 for (size_t i = 0; i < GetPrefixLength(); i++) | |
106 { | |
107 s += (FormatHexadecimal(GetPrefixTag(i)) + " / " + | |
108 boost::lexical_cast<std::string>(i) + " / "); | |
109 } | |
110 | |
111 return s + FormatHexadecimal(GetFinalTag()); | |
112 } | |
113 } |