Mercurial > hg > orthanc
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 |
rev | line source |
---|---|
4681 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium | |
6 * | |
7 * This program is free software: you can redistribute it and/or | |
8 * modify it under the terms of the GNU Lesser General Public License | |
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 | |
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 * Lesser General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Lesser General Public | |
18 * License along with this program. If not, see | |
19 * <http://www.gnu.org/licenses/>. | |
20 **/ | |
21 | |
22 | |
23 #pragma once | |
24 | |
25 #include "../OrthancFramework.h" | |
26 #include "../DicomFormat/DicomTag.h" | |
27 | |
28 #include <vector> | |
29 | |
30 namespace Orthanc | |
31 { | |
4682
d38a7040474a
FromDcmtkBridge::RemovePath() and FromDcmtkBridge::ReplacePath()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4681
diff
changeset
|
32 class ORTHANC_PUBLIC DicomPath |
4681 | 33 { |
34 private: | |
35 class PrefixItem | |
36 { | |
37 private: | |
38 DicomTag tag_; | |
39 bool isUniversal_; // Matches any index | |
40 size_t index_; | |
41 | |
42 PrefixItem(DicomTag tag, | |
43 bool isUniversal, | |
44 size_t index); | |
45 | |
46 public: | |
47 static PrefixItem CreateUniversal(const DicomTag& tag) | |
48 { | |
49 return PrefixItem(tag, true, 0 /* dummy value */); | |
50 } | |
51 | |
52 static PrefixItem CreateIndexed(const DicomTag& tag, | |
53 size_t index) | |
54 { | |
55 return PrefixItem(tag, false, index); | |
56 } | |
57 | |
58 const DicomTag& GetTag() const | |
59 { | |
60 return tag_; | |
61 } | |
62 | |
63 bool IsUniversal() const | |
64 { | |
65 return isUniversal_; | |
66 } | |
67 | |
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 | 71 }; |
72 | |
73 std::vector<PrefixItem> prefix_; | |
74 Orthanc::DicomTag finalTag_; | |
75 | |
76 static DicomTag ParseTag(const std::string& token); | |
77 | |
78 const PrefixItem& GetLevel(size_t i) const; | |
79 | |
80 public: | |
81 explicit DicomPath(const Orthanc::DicomTag& tag) : | |
82 finalTag_(tag) | |
83 { | |
84 } | |
85 | |
86 DicomPath(const Orthanc::DicomTag& sequence, | |
87 size_t index, | |
88 const Orthanc::DicomTag& tag); | |
89 | |
90 DicomPath(const Orthanc::DicomTag& sequence1, | |
91 size_t index1, | |
92 const Orthanc::DicomTag& sequence2, | |
93 size_t index2, | |
94 const Orthanc::DicomTag& tag); | |
95 | |
96 DicomPath(const Orthanc::DicomTag& sequence1, | |
97 size_t index1, | |
98 const Orthanc::DicomTag& sequence2, | |
99 size_t index2, | |
100 const Orthanc::DicomTag& sequence3, | |
101 size_t index3, | |
102 const Orthanc::DicomTag& tag); | |
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 | 108 void AddIndexedTagToPrefix(const Orthanc::DicomTag& tag, |
109 size_t index); | |
110 | |
111 void AddUniversalTagToPrefix(const Orthanc::DicomTag& tag); | |
112 | |
113 size_t GetPrefixLength() const | |
114 { | |
115 return prefix_.size(); | |
116 } | |
117 | |
118 const Orthanc::DicomTag& GetFinalTag() const | |
119 { | |
120 return finalTag_; | |
121 } | |
122 | |
123 const Orthanc::DicomTag& GetPrefixTag(size_t level) const | |
124 { | |
125 return GetLevel(level).GetTag(); | |
126 } | |
127 | |
128 bool IsPrefixUniversal(size_t level) const | |
129 { | |
130 return GetLevel(level).IsUniversal(); | |
131 } | |
132 | |
133 size_t GetPrefixIndex(size_t level) const | |
134 { | |
135 return GetLevel(level).GetIndex(); | |
136 } | |
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 | 145 std::string Format() const; |
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 | 151 }; |
152 } |