Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Toolbox/SortedFrames.h @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/Toolbox/SortedFrames.h@5d892f5dd9c4 |
children | 85e117739eca |
comparison
equal
deleted
inserted
replaced
1511:9dfeee74c1e6 | 1512:244ad1e4e76a |
---|---|
1 /** | |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
5 * Copyright (C) 2017-2020 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 Affero 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 * Affero General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU Affero General Public License | |
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 **/ | |
20 | |
21 | |
22 #pragma once | |
23 | |
24 #include "LinearAlgebra.h" | |
25 | |
26 namespace OrthancStone | |
27 { | |
28 class SortedFrames : public boost::noncopyable | |
29 { | |
30 private: | |
31 class Instance : public boost::noncopyable | |
32 { | |
33 private: | |
34 bool hasPosition_; | |
35 Orthanc::DicomMap tags_; | |
36 std::string sopInstanceUid_; | |
37 unsigned int numberOfFrames_; | |
38 Vector normal_; // Only used in "Sort()" | |
39 Vector position_; // Only used in "Sort()" | |
40 bool monochrome1_; | |
41 | |
42 public: | |
43 Instance(const Orthanc::DicomMap& tags); | |
44 | |
45 const Orthanc::DicomMap& GetTags() const | |
46 { | |
47 return tags_; | |
48 } | |
49 | |
50 const std::string& GetSopInstanceUid() const | |
51 { | |
52 return sopInstanceUid_; | |
53 } | |
54 | |
55 unsigned int GetNumberOfFrames() const | |
56 { | |
57 return numberOfFrames_; | |
58 } | |
59 | |
60 bool HasPosition() const | |
61 { | |
62 return hasPosition_; | |
63 } | |
64 | |
65 const Vector& GetNormal() const; | |
66 | |
67 const Vector& GetPosition() const; | |
68 | |
69 bool IsMonochrome1() const | |
70 { | |
71 return monochrome1_; | |
72 } | |
73 }; | |
74 | |
75 struct Frame | |
76 { | |
77 private: | |
78 const Instance* instance_; | |
79 unsigned int frameIndex_; | |
80 | |
81 public: | |
82 Frame(const Instance& instance, | |
83 unsigned int frameIndex); | |
84 | |
85 const Instance& GetInstance() const | |
86 { | |
87 return *instance_; | |
88 } | |
89 | |
90 unsigned int GetFrameIndex() const | |
91 { | |
92 return frameIndex_; | |
93 } | |
94 }; | |
95 | |
96 std::string studyInstanceUid_; | |
97 std::string seriesInstanceUid_; | |
98 std::vector<Instance*> instances_; | |
99 std::vector<Frame> frames_; | |
100 bool sorted_; | |
101 | |
102 const Instance& GetInstance(size_t index) const; | |
103 | |
104 const Frame& GetFrame(size_t index) const; | |
105 | |
106 void AddFramesOfInstance(std::set<size_t>& remainingInstances, | |
107 size_t index); | |
108 | |
109 void SortUsingIntegerTag(std::set<size_t>& remainingInstances, | |
110 const Orthanc::DicomTag& tag); | |
111 | |
112 void SortUsingSopInstanceUid(std::set<size_t>& remainingInstances); | |
113 | |
114 void SortUsing3DLocation(std::set<size_t>& remainingInstances); | |
115 | |
116 public: | |
117 SortedFrames() : | |
118 sorted_(true) | |
119 { | |
120 } | |
121 | |
122 ~SortedFrames() | |
123 { | |
124 Clear(); | |
125 } | |
126 | |
127 void Clear(); | |
128 | |
129 const std::string& GetStudyInstanceUid() const | |
130 { | |
131 return studyInstanceUid_; | |
132 } | |
133 | |
134 const std::string& GetSeriesInstanceUid() const | |
135 { | |
136 return seriesInstanceUid_; | |
137 } | |
138 | |
139 void AddInstance(const Orthanc::DicomMap& tags); | |
140 | |
141 size_t GetInstancesCount() const | |
142 { | |
143 return instances_.size(); | |
144 } | |
145 | |
146 const Orthanc::DicomMap& GetInstanceTags(size_t index) const | |
147 { | |
148 return GetInstance(index).GetTags(); | |
149 } | |
150 | |
151 const std::string& GetSopInstanceUid(size_t index) const | |
152 { | |
153 return GetInstance(index).GetSopInstanceUid(); | |
154 } | |
155 | |
156 bool IsSorted() const | |
157 { | |
158 return sorted_; | |
159 } | |
160 | |
161 size_t GetFramesCount() const; | |
162 | |
163 const Orthanc::DicomMap& GetFrameTags(size_t index) const | |
164 { | |
165 return GetFrame(index).GetInstance().GetTags(); | |
166 } | |
167 | |
168 const std::string& GetFrameSopInstanceUid(size_t index) const | |
169 { | |
170 return GetFrame(index).GetInstance().GetSopInstanceUid(); | |
171 } | |
172 | |
173 unsigned int GetFrameSiblingsCount(size_t index) const | |
174 { | |
175 return GetFrame(index).GetInstance().GetNumberOfFrames(); | |
176 } | |
177 | |
178 unsigned int GetFrameIndex(size_t index) const | |
179 { | |
180 return GetFrame(index).GetFrameIndex(); | |
181 } | |
182 | |
183 bool IsFrameMonochrome1(size_t index) const | |
184 { | |
185 return GetFrame(index).GetInstance().IsMonochrome1(); | |
186 } | |
187 | |
188 void Sort(); | |
189 }; | |
190 } |