Mercurial > hg > orthanc-stone
comparison OrthancStone/Sources/Loaders/OrthancSeriesVolumeProgressiveLoader.h @ 1512:244ad1e4e76a
reorganization of folders
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 07 Jul 2020 16:21:02 +0200 |
parents | Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h@dad6a2fe6fc7 |
children | 4fb8fdf03314 |
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 "../Loaders/IFetchingItemsSorter.h" | |
25 #include "../Loaders/IFetchingStrategy.h" | |
26 #include "../Messages/IObservable.h" | |
27 #include "../Messages/ObserverBase.h" | |
28 #include "../Oracle/GetOrthancImageCommand.h" | |
29 #include "../Oracle/GetOrthancWebViewerJpegCommand.h" | |
30 #include "../Oracle/IOracle.h" | |
31 #include "../Oracle/OrthancRestApiCommand.h" | |
32 #include "../Toolbox/SlicesSorter.h" | |
33 #include "../Volumes/DicomVolumeImage.h" | |
34 #include "../Volumes/IVolumeSlicer.h" | |
35 | |
36 #include "../Volumes/IGeometryProvider.h" | |
37 | |
38 | |
39 #include <boost/shared_ptr.hpp> | |
40 | |
41 namespace OrthancStone | |
42 { | |
43 class ILoadersContext; | |
44 /** | |
45 This class is used to manage the progressive loading of a volume that | |
46 is stored in a Dicom series. | |
47 */ | |
48 class OrthancSeriesVolumeProgressiveLoader : | |
49 public OrthancStone::ObserverBase<OrthancSeriesVolumeProgressiveLoader>, | |
50 public OrthancStone::IObservable, | |
51 public OrthancStone::IVolumeSlicer, | |
52 public IGeometryProvider | |
53 { | |
54 public: | |
55 class ISlicePostProcessor | |
56 { | |
57 public: | |
58 virtual void ProcessCTDicomSlice(const Orthanc::DicomMap& dicom) = 0; | |
59 }; | |
60 | |
61 private: | |
62 static const unsigned int QUALITY_00 = 0; | |
63 static const unsigned int QUALITY_01 = 1; | |
64 static const unsigned int QUALITY_02 = 2; | |
65 | |
66 class ExtractedSlice; | |
67 | |
68 | |
69 /** Helper class internal to OrthancSeriesVolumeProgressiveLoader */ | |
70 class SeriesGeometry : public boost::noncopyable | |
71 { | |
72 private: | |
73 void CheckSlice(size_t index, | |
74 const OrthancStone::DicomInstanceParameters& reference) const; | |
75 | |
76 void CheckVolume() const; | |
77 | |
78 void Clear(); | |
79 | |
80 void CheckSliceIndex(size_t index) const; | |
81 | |
82 std::unique_ptr<OrthancStone::VolumeImageGeometry> geometry_; | |
83 std::vector<OrthancStone::DicomInstanceParameters*> slices_; | |
84 std::vector<uint64_t> slicesRevision_; | |
85 | |
86 public: | |
87 ~SeriesGeometry() | |
88 { | |
89 Clear(); | |
90 } | |
91 | |
92 void ComputeGeometry(OrthancStone::SlicesSorter& slices); | |
93 | |
94 virtual bool HasGeometry() const | |
95 { | |
96 return geometry_.get() != NULL; | |
97 } | |
98 | |
99 virtual const OrthancStone::VolumeImageGeometry& GetImageGeometry() const; | |
100 | |
101 const OrthancStone::DicomInstanceParameters& GetSliceParameters(size_t index) const; | |
102 | |
103 uint64_t GetSliceRevision(size_t index) const; | |
104 | |
105 void IncrementSliceRevision(size_t index); | |
106 }; | |
107 | |
108 void ScheduleNextSliceDownload(); | |
109 | |
110 void LoadGeometry(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message); | |
111 | |
112 void SetSliceContent(unsigned int sliceIndex, | |
113 const Orthanc::ImageAccessor& image, | |
114 unsigned int quality); | |
115 | |
116 void LoadBestQualitySliceContent(const OrthancStone::GetOrthancImageCommand::SuccessMessage& message); | |
117 | |
118 void LoadJpegSliceContent(const OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage& message); | |
119 | |
120 OrthancStone::ILoadersContext& loadersContext_; | |
121 bool active_; | |
122 bool progressiveQuality_; | |
123 unsigned int simultaneousDownloads_; | |
124 SeriesGeometry seriesGeometry_; | |
125 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume_; | |
126 std::unique_ptr<OrthancStone::IFetchingItemsSorter::IFactory> sorter_; | |
127 std::unique_ptr<OrthancStone::IFetchingStrategy> strategy_; | |
128 | |
129 std::vector<unsigned int> slicesQuality_; | |
130 bool volumeImageReadyInHighQuality_; | |
131 | |
132 boost::shared_ptr<ISlicePostProcessor> slicePostProcessor_; | |
133 | |
134 /** See priority setters/getters below */ | |
135 int medadataSchedulingPriority_; | |
136 | |
137 /** See priority setters/getters below */ | |
138 int sliceSchedulingPriority_; | |
139 | |
140 OrthancSeriesVolumeProgressiveLoader( | |
141 OrthancStone::ILoadersContext& loadersContext, | |
142 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume, | |
143 bool progressiveQuality); | |
144 | |
145 public: | |
146 ORTHANC_STONE_DEFINE_ORIGIN_MESSAGE(__FILE__, __LINE__, VolumeImageReadyInHighQuality, OrthancSeriesVolumeProgressiveLoader); | |
147 | |
148 /** | |
149 See doc for the progressiveQuality_ field | |
150 */ | |
151 static boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> Create( | |
152 OrthancStone::ILoadersContext& context, | |
153 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume, | |
154 bool progressiveQuality = false); | |
155 | |
156 virtual ~OrthancSeriesVolumeProgressiveLoader(); | |
157 | |
158 void SetSimultaneousDownloads(unsigned int count); | |
159 | |
160 /** | |
161 Sets the relative priority of the requests for metadata. | |
162 - if p < PRIORITY_HIGH (-1) , the requests will be high priority | |
163 - if PRIORITY_LOW (100) > p > PRIORITY_HIGH , the requests will be medium priority | |
164 - if p > PRIORITY_LOW , the requests will be low priority | |
165 | |
166 Default is 0 (medium) | |
167 */ | |
168 void SetMetadataSchedulingPriority(int p); | |
169 | |
170 /** @see SetMetadataSchedulingPriority */ | |
171 int GetMetadataSchedulingPriority() const; | |
172 | |
173 /** Same as SetMetadataSchedulingPriority, for slices. Default is 0. */ | |
174 void SetSliceSchedulingPriority(int p); | |
175 | |
176 /** @see SetSliceSchedulingPriority */ | |
177 int GetSliceSchedulingPriority() const; | |
178 | |
179 /** Sets priorities for all requests. @see SetMetadataSchedulingPriority */ | |
180 void SetSchedulingPriority(int p); | |
181 | |
182 void SetDicomSlicePostProcessor(boost::shared_ptr<ISlicePostProcessor> slicePostProcessor) | |
183 { | |
184 // this will delete the previously stored slice processor, if any | |
185 slicePostProcessor_ = slicePostProcessor; | |
186 } | |
187 | |
188 boost::shared_ptr<ISlicePostProcessor> GetDicomSlicePostProcessor() | |
189 { | |
190 // this could be empty! | |
191 return slicePostProcessor_; | |
192 } | |
193 | |
194 bool IsVolumeImageReadyInHighQuality() const | |
195 { | |
196 return volumeImageReadyInHighQuality_; | |
197 } | |
198 | |
199 void LoadSeries(const std::string& seriesId); | |
200 | |
201 /** | |
202 This getter is used by clients that do not receive the geometry through | |
203 subscribing, for instance if they are created or listening only AFTER the | |
204 "geometry loaded" message is broadcast | |
205 */ | |
206 bool HasGeometry() const ORTHANC_OVERRIDE | |
207 { | |
208 return seriesGeometry_.HasGeometry(); | |
209 } | |
210 | |
211 /** | |
212 Same remark as HasGeometry | |
213 */ | |
214 const OrthancStone::VolumeImageGeometry& GetImageGeometry() const ORTHANC_OVERRIDE | |
215 { | |
216 return seriesGeometry_.GetImageGeometry(); | |
217 } | |
218 | |
219 /** | |
220 When a slice is requested, the strategy algorithm (that defines the | |
221 sequence of resources to be loaded from the server) is modified to | |
222 take into account this request (this is done in the ExtractedSlice ctor) | |
223 */ | |
224 virtual IExtractedSlice* | |
225 ExtractSlice(const OrthancStone::CoordinateSystem3D& cuttingPlane) ORTHANC_OVERRIDE; | |
226 }; | |
227 } |