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