annotate OrthancFramework/Sources/DicomFormat/DicomPath.h @ 4689:ead3b81f4541

added DicomPath::SetPrefixIndex()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 10 Jun 2021 10:54:14 +0200
parents 7182f5732480
children 13efc0967cea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 /**
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 * Orthanc - A Lightweight, RESTful DICOM Store
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 * Department, University Hospital of Liege, Belgium
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 *
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 * This program is free software: you can redistribute it and/or
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public License
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 * as published by the Free Software Foundation, either version 3 of
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 * the License, or (at your option) any later version.
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 *
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 * This program is distributed in the hope that it will be useful, but
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 * Lesser General Public License for more details.
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 *
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 * License along with this program. If not, see
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 * <http://www.gnu.org/licenses/>.
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 **/
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 #pragma once
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 #include "../OrthancFramework.h"
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 #include "../DicomFormat/DicomTag.h"
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 #include <vector>
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 namespace Orthanc
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 {
4682
d38a7040474a FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4681
diff changeset
32 class ORTHANC_PUBLIC DicomPath
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 private:
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 class PrefixItem
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 private:
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 DicomTag tag_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 bool isUniversal_; // Matches any index
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 size_t index_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 PrefixItem(DicomTag tag,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 bool isUniversal,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 size_t index);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 public:
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 static PrefixItem CreateUniversal(const DicomTag& tag)
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 return PrefixItem(tag, true, 0 /* dummy value */);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 static PrefixItem CreateIndexed(const DicomTag& tag,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53 size_t index)
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 return PrefixItem(tag, false, index);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 const DicomTag& GetTag() const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 return tag_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 bool IsUniversal() const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 return isUniversal_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 size_t GetIndex() const;
4689
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
69
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
70 void SetIndex(size_t index);
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 };
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 std::vector<PrefixItem> prefix_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 Orthanc::DicomTag finalTag_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 static DicomTag ParseTag(const std::string& token);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 const PrefixItem& GetLevel(size_t i) const;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 public:
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 explicit DicomPath(const Orthanc::DicomTag& tag) :
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 finalTag_(tag)
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 DicomPath(const Orthanc::DicomTag& sequence,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 size_t index,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90 DicomPath(const Orthanc::DicomTag& sequence1,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91 size_t index1,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 const Orthanc::DicomTag& sequence2,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 size_t index2,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 DicomPath(const Orthanc::DicomTag& sequence1,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 size_t index1,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98 const Orthanc::DicomTag& sequence2,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 size_t index2,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 const Orthanc::DicomTag& sequence3,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 size_t index3,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
104 DicomPath(const std::vector<Orthanc::DicomTag>& parentTags,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
105 const std::vector<size_t> parentIndexes,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
106 const Orthanc::DicomTag& finalTag);
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
107
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 void AddIndexedTagToPrefix(const Orthanc::DicomTag& tag,
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 size_t index);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 void AddUniversalTagToPrefix(const Orthanc::DicomTag& tag);
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113 size_t GetPrefixLength() const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 return prefix_.size();
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 const Orthanc::DicomTag& GetFinalTag() const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 return finalTag_;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 const Orthanc::DicomTag& GetPrefixTag(size_t level) const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125 return GetLevel(level).GetTag();
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 bool IsPrefixUniversal(size_t level) const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 return GetLevel(level).IsUniversal();
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 size_t GetPrefixIndex(size_t level) const
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 {
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 return GetLevel(level).GetIndex();
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136 }
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137
4682
d38a7040474a FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4681
diff changeset
138 bool HasUniversal() const;
d38a7040474a FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4681
diff changeset
139
4689
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
140 // This method is used for an optimization in Stone
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
141 // (cf. "DicomStructureSet.cpp")
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
142 void SetPrefixIndex(size_t level,
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
143 size_t index);
ead3b81f4541 added DicomPath::SetPrefixIndex()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4683
diff changeset
144
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 std::string Format() const;
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146
4682
d38a7040474a FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4681
diff changeset
147 static DicomPath Parse(const std::string& s);
4683
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
148
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
149 static bool IsMatch(const DicomPath& pattern,
7182f5732480 use of DicomPath in ParsedDicomFile
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4682
diff changeset
150 const DicomPath& path);
4681
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 };
c5528c7847a6 new class DicomPath
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 }