annotate OrthancStone/Sources/Toolbox/OrthancDatasets/DicomPath.cpp @ 1770:073484e33bee

fix offset of textures
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 12 May 2021 10:53:37 +0200
parents 9ac2a65d4172
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1504
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Stone of Orthanc
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
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
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #include "DicomPath.h"
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include <OrthancException.h>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #include <boost/lexical_cast.hpp>
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 namespace OrthancStone
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 const DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth) const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 if (depth >= prefix_.size())
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 return prefix_[depth];
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 DicomPath::Prefix& DicomPath::GetPrefixItem(size_t depth)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 if (depth >= prefix_.size())
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 else
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 return prefix_[depth];
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 DicomPath::DicomPath(const Orthanc::DicomTag& sequence,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 size_t index,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 const Orthanc::DicomTag& tag) :
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 finalTag_(tag)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 AddToPrefix(sequence, index);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 DicomPath::DicomPath(const Orthanc::DicomTag& sequence1,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 size_t index1,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 const Orthanc::DicomTag& sequence2,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 size_t index2,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 const Orthanc::DicomTag& tag) :
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 finalTag_(tag)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 AddToPrefix(sequence1, index1);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 AddToPrefix(sequence2, index2);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 DicomPath::DicomPath(const Orthanc::DicomTag& sequence1,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 size_t index1,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 const Orthanc::DicomTag& sequence2,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 size_t index2,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 const Orthanc::DicomTag& sequence3,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 size_t index3,
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 const Orthanc::DicomTag& tag) :
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 finalTag_(tag)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 AddToPrefix(sequence1, index1);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 AddToPrefix(sequence2, index2);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89 AddToPrefix(sequence3, index3);
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 static std::string FormatHexadecimal(const Orthanc::DicomTag& tag)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95 char buf[16];
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 sprintf(buf, "(%04x,%04x)", tag.GetGroup(), tag.GetElement());
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 return buf;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 std::string DicomPath::Format() const
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103 std::string s;
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 for (size_t i = 0; i < GetPrefixLength(); i++)
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 {
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 s += (FormatHexadecimal(GetPrefixTag(i)) + " / " +
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 boost::lexical_cast<std::string>(i) + " / ");
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 return s + FormatHexadecimal(GetFinalTag());
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 }
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 }