Mercurial > hg > orthanc-stone
annotate Framework/Deprecated/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp @ 1327:4f8db2d202c8 broker
OrthancSeriesProgressiveLoader now has two modes that
can be selected at object creation :
- progressive (will first load jpeg50, then jpeg90 then PAM)
- non-progressive (will directly load PAM (uncompressed))
Please note that the slice loading order remains dynamic
and depending upon the slice that the client code wishes
to extract from the volume.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Wed, 25 Mar 2020 14:34:27 +0100 |
parents | 7702ad9b7011 |
children |
rev | line source |
---|---|
814 | 1 /** |
2 * Stone of Orthanc | |
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics | |
4 * Department, University Hospital of Liege, Belgium | |
1271
0ca50d275b9a
upgrade to year 2020
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1225
diff
changeset
|
5 * Copyright (C) 2017-2020 Osimis S.A., Belgium |
814 | 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 #include "OrthancSeriesVolumeProgressiveLoader.h" | |
23 | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
24 #include "../../StoneException.h" |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
25 #include "../../Loaders/ILoadersContext.h" |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
26 #include "../../Loaders/BasicFetchingItemsSorter.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
27 #include "../../Loaders/BasicFetchingStrategy.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
28 #include "../../Toolbox/GeometryToolbox.h" |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
29 #include "../../Volumes/DicomVolumeImageMPRSlicer.h" |
814 | 30 |
31 #include <Core/Images/ImageProcessing.h> | |
32 #include <Core/OrthancException.h> | |
33 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
34 namespace Deprecated |
814 | 35 { |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
36 using OrthancStone::ILoadersContext; |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
37 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
38 class OrthancSeriesVolumeProgressiveLoader::ExtractedSlice : public OrthancStone::DicomVolumeImageMPRSlicer::Slice |
814 | 39 { |
40 private: | |
41 const OrthancSeriesVolumeProgressiveLoader& that_; | |
42 | |
43 public: | |
44 ExtractedSlice(const OrthancSeriesVolumeProgressiveLoader& that, | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
45 const OrthancStone::CoordinateSystem3D& plane) : |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
46 OrthancStone::DicomVolumeImageMPRSlicer::Slice(*that.volume_, plane), |
814 | 47 that_(that) |
48 { | |
819 | 49 if (IsValid()) |
817
68f888812af4
simplification of DicomVolumeImageMPRSlicer::ExtractedSlice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
50 { |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
51 if (GetProjection() == OrthancStone::VolumeProjection_Axial) |
819 | 52 { |
53 // For coronal and sagittal projections, we take the global | |
54 // revision of the volume because even if a single slice changes, | |
55 // this means the projection will yield a different result --> | |
56 // we must increase the revision as soon as any slice changes | |
57 SetRevision(that_.seriesGeometry_.GetSliceRevision(GetSliceIndex())); | |
58 } | |
817
68f888812af4
simplification of DicomVolumeImageMPRSlicer::ExtractedSlice
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
814
diff
changeset
|
59 |
819 | 60 if (that_.strategy_.get() != NULL && |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
61 GetProjection() == OrthancStone::VolumeProjection_Axial) |
819 | 62 { |
63 that_.strategy_->SetCurrent(GetSliceIndex()); | |
64 } | |
814 | 65 } |
66 } | |
67 }; | |
68 | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
69 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSlice( |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
70 size_t index, const OrthancStone::DicomInstanceParameters& reference) const |
814 | 71 { |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
72 const OrthancStone::DicomInstanceParameters& slice = *slices_[index]; |
814 | 73 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
74 if (!OrthancStone::GeometryToolbox::IsParallel( |
814 | 75 reference.GetGeometry().GetNormal(), |
76 slice.GetGeometry().GetNormal())) | |
77 { | |
78 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, | |
79 "A slice in the volume image is not parallel to the others"); | |
80 } | |
81 | |
82 if (reference.GetExpectedPixelFormat() != slice.GetExpectedPixelFormat()) | |
83 { | |
84 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageFormat, | |
85 "The pixel format changes across the slices of the volume image"); | |
86 } | |
87 | |
88 if (reference.GetImageInformation().GetWidth() != slice.GetImageInformation().GetWidth() || | |
89 reference.GetImageInformation().GetHeight() != slice.GetImageInformation().GetHeight()) | |
90 { | |
91 throw Orthanc::OrthancException(Orthanc::ErrorCode_IncompatibleImageSize, | |
92 "The width/height of slices are not constant in the volume image"); | |
93 } | |
94 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
95 if (!OrthancStone::LinearAlgebra::IsNear(reference.GetPixelSpacingX(), slice.GetPixelSpacingX()) || |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
96 !OrthancStone::LinearAlgebra::IsNear(reference.GetPixelSpacingY(), slice.GetPixelSpacingY())) |
814 | 97 { |
98 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, | |
99 "The pixel spacing of the slices change across the volume image"); | |
100 } | |
101 } | |
102 | |
103 | |
104 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckVolume() const | |
105 { | |
106 for (size_t i = 0; i < slices_.size(); i++) | |
107 { | |
108 assert(slices_[i] != NULL); | |
109 if (slices_[i]->GetImageInformation().GetNumberOfFrames() != 1) | |
110 { | |
111 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, | |
112 "This class does not support multi-frame images"); | |
113 } | |
114 } | |
115 | |
116 if (slices_.size() != 0) | |
117 { | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
118 const OrthancStone::DicomInstanceParameters& reference = *slices_[0]; |
814 | 119 |
120 for (size_t i = 1; i < slices_.size(); i++) | |
121 { | |
122 CheckSlice(i, reference); | |
123 } | |
124 } | |
125 } | |
126 | |
127 | |
128 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::Clear() | |
129 { | |
130 for (size_t i = 0; i < slices_.size(); i++) | |
131 { | |
132 assert(slices_[i] != NULL); | |
133 delete slices_[i]; | |
134 } | |
135 | |
136 slices_.clear(); | |
137 slicesRevision_.clear(); | |
138 } | |
139 | |
140 | |
141 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSliceIndex(size_t index) const | |
142 { | |
143 if (!HasGeometry()) | |
144 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
145 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::CheckSliceIndex(size_t index): (!HasGeometry())"; |
814 | 146 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
147 } | |
148 else if (index >= slices_.size()) | |
149 { | |
150 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
151 } | |
152 else | |
153 { | |
154 assert(slices_.size() == GetImageGeometry().GetDepth() && | |
155 slices_.size() == slicesRevision_.size()); | |
156 } | |
157 } | |
158 | |
159 | |
160 // WARNING: The payload of "slices" must be of class "DicomInstanceParameters" | |
161 // (called with the slices created in LoadGeometry) | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
162 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::ComputeGeometry(OrthancStone::SlicesSorter& slices) |
814 | 163 { |
164 Clear(); | |
165 | |
166 if (!slices.Sort()) | |
167 { | |
168 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange, | |
169 "Cannot sort the 3D slices of a DICOM series"); | |
170 } | |
171 | |
172 if (slices.GetSlicesCount() == 0) | |
173 { | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
174 geometry_.reset(new OrthancStone::VolumeImageGeometry); |
814 | 175 } |
176 else | |
177 { | |
178 slices_.reserve(slices.GetSlicesCount()); | |
179 slicesRevision_.resize(slices.GetSlicesCount(), 0); | |
180 | |
181 for (size_t i = 0; i < slices.GetSlicesCount(); i++) | |
182 { | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
183 const OrthancStone::DicomInstanceParameters& slice = |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
184 dynamic_cast<const OrthancStone::DicomInstanceParameters&>(slices.GetSlicePayload(i)); |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
185 slices_.push_back(new OrthancStone::DicomInstanceParameters(slice)); |
814 | 186 } |
187 | |
188 CheckVolume(); | |
189 | |
1156
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
190 double spacingZ; |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
191 |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
192 if (slices.ComputeSpacingBetweenSlices(spacingZ)) |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
193 { |
1320
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
194 LOG(TRACE) << "Computed spacing between slices: " << spacingZ << "mm"; |
814 | 195 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
196 const OrthancStone::DicomInstanceParameters& parameters = *slices_[0]; |
814 | 197 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
198 geometry_.reset(new OrthancStone::VolumeImageGeometry); |
1156
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
199 geometry_->SetSizeInVoxels(parameters.GetImageInformation().GetWidth(), |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
200 parameters.GetImageInformation().GetHeight(), |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
201 static_cast<unsigned int>(slices.GetSlicesCount())); |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
202 geometry_->SetAxialGeometry(slices.GetSliceGeometry(0)); |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
203 geometry_->SetVoxelDimensions(parameters.GetPixelSpacingX(), |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
204 parameters.GetPixelSpacingY(), spacingZ); |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
205 } |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
206 else |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
207 { |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
208 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry, |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
209 "The origins of the slices of a volume image are not regularly spaced"); |
34ee7204fde3
removing IGeometryProvider
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1135
diff
changeset
|
210 } |
814 | 211 } |
212 } | |
213 | |
214 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
215 const OrthancStone::VolumeImageGeometry& OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetImageGeometry() const |
814 | 216 { |
217 if (!HasGeometry()) | |
218 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
219 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetImageGeometry(): (!HasGeometry())"; |
814 | 220 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
221 } | |
222 else | |
223 { | |
224 assert(slices_.size() == geometry_->GetDepth()); | |
225 return *geometry_; | |
226 } | |
227 } | |
228 | |
229 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
230 const OrthancStone::DicomInstanceParameters& OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetSliceParameters(size_t index) const |
814 | 231 { |
232 CheckSliceIndex(index); | |
233 return *slices_[index]; | |
234 } | |
235 | |
236 | |
237 uint64_t OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::GetSliceRevision(size_t index) const | |
238 { | |
239 CheckSliceIndex(index); | |
240 return slicesRevision_[index]; | |
241 } | |
242 | |
243 | |
244 void OrthancSeriesVolumeProgressiveLoader::SeriesGeometry::IncrementSliceRevision(size_t index) | |
245 { | |
246 CheckSliceIndex(index); | |
247 slicesRevision_[index] ++; | |
248 } | |
249 | |
250 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
251 static unsigned int GetSliceIndexPayload(const OrthancStone::OracleCommandBase& command) |
814 | 252 { |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
253 assert(command.HasPayload()); |
814 | 254 return dynamic_cast< const Orthanc::SingleValueObject<unsigned int>& >(command.GetPayload()).GetValue(); |
255 } | |
256 | |
257 | |
258 void OrthancSeriesVolumeProgressiveLoader::ScheduleNextSliceDownload() | |
259 { | |
260 assert(strategy_.get() != NULL); | |
261 | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
262 unsigned int sliceIndex = 0, quality = 0; |
814 | 263 |
264 if (strategy_->GetNext(sliceIndex, quality)) | |
265 { | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
266 if (!progressiveQuality_) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
267 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
268 ORTHANC_ASSERT(quality == QUALITY_00, "INTERNAL ERROR. quality != QUALITY_00 in " |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
269 << "OrthancSeriesVolumeProgressiveLoader::ScheduleNextSliceDownload"); |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
270 } |
814 | 271 |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
272 const OrthancStone::DicomInstanceParameters& slice = seriesGeometry_.GetSliceParameters(sliceIndex); |
814 | 273 |
274 const std::string& instance = slice.GetOrthancInstanceIdentifier(); | |
275 if (instance.empty()) | |
276 { | |
277 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
278 } | |
279 | |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
280 std::unique_ptr<OrthancStone::OracleCommandBase> command; |
814 | 281 |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
282 if (!progressiveQuality_ || quality == QUALITY_02) |
814 | 283 { |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
284 std::unique_ptr<OrthancStone::GetOrthancImageCommand> tmp(new OrthancStone::GetOrthancImageCommand); |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
285 // TODO: review the following comment. |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
286 // - Commented out by bgo on 2019-07-19 | reason: Alain has seen cases |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
287 // where gzipping the uint16 image took 11 sec to produce 5mb. |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
288 // The unzipped request was much much faster. |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
289 // - Re-enabled on 2019-07-30. Reason: in Web Assembly, the browser |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
290 // does not use the Accept-Encoding header and always requests |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
291 // compression. Furthermore, NOT |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
292 tmp->SetHttpHeader("Accept-Encoding", "gzip"); |
814 | 293 tmp->SetHttpHeader("Accept", std::string(Orthanc::EnumerationToString(Orthanc::MimeType_Pam))); |
819 | 294 tmp->SetInstanceUri(instance, slice.GetExpectedPixelFormat()); |
814 | 295 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); |
1320
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
296 //LOG(INFO) |
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
297 // << "OrthancSeriesVolumeProgressiveLoader.ScheduleNextSliceDownload()" |
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
298 // << " sliceIndex = " << sliceIndex << " slice quality = " << quality |
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
299 // << " URI = " << tmp->GetUri(); |
814 | 300 command.reset(tmp.release()); |
301 } | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
302 else // progressive mode is true AND quality is not final (different from QUALITY_02 |
814 | 303 { |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
304 std::unique_ptr<OrthancStone::GetOrthancWebViewerJpegCommand> tmp( |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
305 new OrthancStone::GetOrthancWebViewerJpegCommand); |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
306 |
913
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
819
diff
changeset
|
307 // TODO: review the following comment. Commented out by bgo on 2019-07-19 |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
819
diff
changeset
|
308 // (gzip for jpeg seems overkill) |
2b4b6b86520a
Re-enabled gl debug output in GuiAdapter +
Benjamin Golinvaux <bgo@osimis.io>
parents:
819
diff
changeset
|
309 //tmp->SetHttpHeader("Accept-Encoding", "gzip"); |
814 | 310 tmp->SetInstance(instance); |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
311 tmp->SetQuality((quality == 0 ? 50 : 90)); // QUALITY_00 is Jpeg50 while QUALITY_01 is Jpeg90 |
814 | 312 tmp->SetExpectedPixelFormat(slice.GetExpectedPixelFormat()); |
1320
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
313 LOG(TRACE) |
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
314 << "OrthancSeriesVolumeProgressiveLoader.ScheduleNextSliceDownload()" |
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
315 << " sliceIndex = " << sliceIndex << " slice quality = " << quality; |
814 | 316 command.reset(tmp.release()); |
317 } | |
318 | |
1128
8e3763d1736a
removing CustomOracleCommand
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1075
diff
changeset
|
319 command->AcquirePayload(new Orthanc::SingleValueObject<unsigned int>(sliceIndex)); |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
320 |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
321 { |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
322 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(loadersContext_.Lock()); |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
323 boost::shared_ptr<IObserver> observer(GetSharedObserver()); |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
324 lock->Schedule(observer, 0, command.release()); // TODO: priority! |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
325 } |
814 | 326 } |
937
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
327 else |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
328 { |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
329 // loading is finished! |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
330 volumeImageReadyInHighQuality_ = true; |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
331 BroadcastMessage(OrthancSeriesVolumeProgressiveLoader::VolumeImageReadyInHighQuality(*this)); |
86ac61a040c9
Added getters and notifications to allow clients of the loaders (DicomStructureSetLoader, OrthancSeriesVolumeProgressiveLoader and OrthancMultiframeVolumeLoader) to know when the loading is finished + added ability for SDL event loop to execute a callback repeatedly (used to check the view loading state)
Benjamin Golinvaux <bgo@osimis.io>
parents:
935
diff
changeset
|
332 } |
814 | 333 } |
334 | |
335 /** | |
336 This is called in response to GET "/series/XXXXXXXXXXXXX/instances-tags" | |
337 */ | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
338 void OrthancSeriesVolumeProgressiveLoader::LoadGeometry(const OrthancStone::OrthancRestApiCommand::SuccessMessage& message) |
814 | 339 { |
340 Json::Value body; | |
341 message.ParseJsonBody(body); | |
342 | |
343 if (body.type() != Json::objectValue) | |
344 { | |
345 throw Orthanc::OrthancException(Orthanc::ErrorCode_NetworkProtocol); | |
346 } | |
347 | |
348 { | |
349 Json::Value::Members instances = body.getMemberNames(); | |
350 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
351 OrthancStone::SlicesSorter slices; |
814 | 352 |
353 for (size_t i = 0; i < instances.size(); i++) | |
354 { | |
355 Orthanc::DicomMap dicom; | |
356 dicom.FromDicomAsJson(body[instances[i]]); | |
357 | |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
358 std::unique_ptr<OrthancStone::DicomInstanceParameters> instance(new OrthancStone::DicomInstanceParameters(dicom)); |
814 | 359 instance->SetOrthancInstanceIdentifier(instances[i]); |
360 | |
361 // the 3D plane corresponding to the slice | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
362 OrthancStone::CoordinateSystem3D geometry = instance->GetGeometry(); |
814 | 363 slices.AddSlice(geometry, instance.release()); |
364 } | |
365 | |
366 seriesGeometry_.ComputeGeometry(slices); | |
367 } | |
368 | |
369 size_t slicesCount = seriesGeometry_.GetImageGeometry().GetDepth(); | |
370 | |
371 if (slicesCount == 0) | |
372 { | |
373 volume_->Initialize(seriesGeometry_.GetImageGeometry(), Orthanc::PixelFormat_Grayscale8); | |
374 } | |
375 else | |
376 { | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
377 const OrthancStone::DicomInstanceParameters& parameters = seriesGeometry_.GetSliceParameters(0); |
814 | 378 |
379 volume_->Initialize(seriesGeometry_.GetImageGeometry(), parameters.GetExpectedPixelFormat()); | |
380 volume_->SetDicomParameters(parameters); | |
381 volume_->GetPixelData().Clear(); | |
382 | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
383 // If we are in progressive mode, the Fetching strategy will first request QUALITY_00, then QUALITY_01, then |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
384 // QUALITY_02... Otherwise, it's only QUALITY_00 |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
385 unsigned int maxQuality = QUALITY_00; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
386 if (progressiveQuality_) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
387 maxQuality = QUALITY_02; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
388 |
1320
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
389 strategy_.reset(new OrthancStone::BasicFetchingStrategy( |
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
390 sorter_->CreateSorter(static_cast<unsigned int>(slicesCount)), |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
391 maxQuality)); |
1320
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
392 |
814 | 393 assert(simultaneousDownloads_ != 0); |
394 for (unsigned int i = 0; i < simultaneousDownloads_; i++) | |
395 { | |
396 ScheduleNextSliceDownload(); | |
397 } | |
398 } | |
399 | |
400 slicesQuality_.resize(slicesCount, 0); | |
401 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
402 BroadcastMessage(OrthancStone::DicomVolumeImage::GeometryReadyMessage(*volume_)); |
814 | 403 } |
404 | |
405 | |
406 void OrthancSeriesVolumeProgressiveLoader::SetSliceContent(unsigned int sliceIndex, | |
407 const Orthanc::ImageAccessor& image, | |
408 unsigned int quality) | |
409 { | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
410 ORTHANC_ASSERT(sliceIndex < slicesQuality_.size() && |
814 | 411 slicesQuality_.size() == volume_->GetPixelData().GetDepth()); |
412 | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
413 if (!progressiveQuality_) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
414 { |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
415 ORTHANC_ASSERT(quality == QUALITY_00); |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
416 ORTHANC_ASSERT(slicesQuality_[sliceIndex] == QUALITY_00); |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
417 } |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
418 |
814 | 419 if (quality >= slicesQuality_[sliceIndex]) |
420 { | |
421 { | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
422 OrthancStone::ImageBuffer3D::SliceWriter writer(volume_->GetPixelData(), |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
423 OrthancStone::VolumeProjection_Axial, |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
424 sliceIndex); |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
425 |
814 | 426 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), image); |
427 } | |
428 | |
429 volume_->IncrementRevision(); | |
430 seriesGeometry_.IncrementSliceRevision(sliceIndex); | |
431 slicesQuality_[sliceIndex] = quality; | |
432 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
433 BroadcastMessage(OrthancStone::DicomVolumeImage::ContentUpdatedMessage(*volume_)); |
814 | 434 } |
1320
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
435 LOG(TRACE) << "SetSliceContent sliceIndex = " << sliceIndex << " -- will " |
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
436 << " now call ScheduleNextSliceDownload()"; |
814 | 437 ScheduleNextSliceDownload(); |
438 } | |
439 | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
440 void OrthancSeriesVolumeProgressiveLoader::LoadBestQualitySliceContent( |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
441 const OrthancStone::GetOrthancImageCommand::SuccessMessage& message) |
814 | 442 { |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
443 unsigned int quality = QUALITY_00; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
444 if (progressiveQuality_) |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
445 quality = QUALITY_02; |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
446 |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
447 SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
448 message.GetImage(), |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
449 quality); |
814 | 450 } |
451 | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
452 void OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent( |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
453 const OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage& message) |
814 | 454 { |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
455 ORTHANC_ASSERT(progressiveQuality_, "INTERNAL ERROR: OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent" |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
456 << " called while progressiveQuality_ is false!"); |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
457 |
1320
7702ad9b7011
OrthancSeriesVolumeProgressiveLoader : PNG quality only!
Benjamin Golinvaux <bgo@osimis.io>
parents:
1318
diff
changeset
|
458 LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent"; |
814 | 459 unsigned int quality; |
460 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
461 switch (dynamic_cast<const OrthancStone::GetOrthancWebViewerJpegCommand&>(message.GetOrigin()).GetQuality()) |
814 | 462 { |
463 case 50: | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
464 quality = QUALITY_00; |
814 | 465 break; |
466 | |
467 case 90: | |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
468 quality = QUALITY_01; |
814 | 469 break; |
470 | |
471 default: | |
472 throw Orthanc::OrthancException(Orthanc::ErrorCode_InternalError); | |
473 } | |
474 | |
1135
a0a33e5ea5bb
IOracleCommand::Clone()
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1134
diff
changeset
|
475 SetSliceContent(GetSliceIndexPayload(message.GetOrigin()), message.GetImage(), quality); |
814 | 476 } |
477 | |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
478 OrthancSeriesVolumeProgressiveLoader::OrthancSeriesVolumeProgressiveLoader( |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
479 OrthancStone::ILoadersContext& loadersContext, |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
480 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume, |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
481 bool progressiveQuality) |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
482 : loadersContext_(loadersContext) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
483 , active_(false) |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
484 , progressiveQuality_(progressiveQuality) |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
485 , simultaneousDownloads_(4) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
486 , volume_(volume) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
487 , sorter_(new OrthancStone::BasicFetchingItemsSorter::Factory) |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
488 , volumeImageReadyInHighQuality_(false) |
814 | 489 { |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
490 } |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
491 |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
492 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
493 OrthancSeriesVolumeProgressiveLoader::Create( |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
494 OrthancStone::ILoadersContext& loadersContext, |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
495 boost::shared_ptr<OrthancStone::DicomVolumeImage> volume, |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
496 bool progressiveQuality) |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
497 { |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
498 std::auto_ptr<OrthancStone::ILoadersContext::ILock> lock(loadersContext.Lock()); |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
499 |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
500 boost::shared_ptr<OrthancSeriesVolumeProgressiveLoader> obj( |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
501 new OrthancSeriesVolumeProgressiveLoader( |
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
502 loadersContext, volume, progressiveQuality)); |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
503 |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
504 obj->Register<OrthancStone::OrthancRestApiCommand::SuccessMessage>( |
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
505 lock->GetOracleObservable(), |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
506 &OrthancSeriesVolumeProgressiveLoader::LoadGeometry); |
1065
9d42f89b8c3c
improved readability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1064
diff
changeset
|
507 |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
508 obj->Register<OrthancStone::GetOrthancImageCommand::SuccessMessage>( |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
509 lock->GetOracleObservable(), |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
510 &OrthancSeriesVolumeProgressiveLoader::LoadBestQualitySliceContent); |
1065
9d42f89b8c3c
improved readability
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1064
diff
changeset
|
511 |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
512 obj->Register<OrthancStone::GetOrthancWebViewerJpegCommand::SuccessMessage>( |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
513 lock->GetOracleObservable(), |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
514 &OrthancSeriesVolumeProgressiveLoader::LoadJpegSliceContent); |
1327
4f8db2d202c8
OrthancSeriesProgressiveLoader now has two modes that
Benjamin Golinvaux <bgo@osimis.io>
parents:
1320
diff
changeset
|
515 |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
516 return obj; |
814 | 517 } |
518 | |
1314
9b126de2cde2
Since the observer system now uses shared_ptr and many registrations are
Benjamin Golinvaux <bgo@osimis.io>
parents:
1310
diff
changeset
|
519 |
935
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
933
diff
changeset
|
520 OrthancSeriesVolumeProgressiveLoader::~OrthancSeriesVolumeProgressiveLoader() |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
933
diff
changeset
|
521 { |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
933
diff
changeset
|
522 LOG(TRACE) << "OrthancSeriesVolumeProgressiveLoader::~OrthancSeriesVolumeProgressiveLoader()"; |
401808e7ff2e
Added traces in LoaderCache objects dtors + fuse to prevent dead weak ptrs to be calleds in VisitWdigets (in GuiAdapter.h)
Benjamin Golinvaux <bgo@osimis.io>
parents:
933
diff
changeset
|
523 } |
814 | 524 |
525 void OrthancSeriesVolumeProgressiveLoader::SetSimultaneousDownloads(unsigned int count) | |
526 { | |
527 if (active_) | |
528 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
529 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::SetSimultaneousDownloads(): (active_)"; |
814 | 530 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
531 } | |
532 else if (count == 0) | |
533 { | |
534 throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange); | |
535 } | |
536 else | |
537 { | |
538 simultaneousDownloads_ = count; | |
539 } | |
540 } | |
541 | |
542 | |
543 void OrthancSeriesVolumeProgressiveLoader::LoadSeries(const std::string& seriesId) | |
544 { | |
545 if (active_) | |
546 { | |
956
a7351ad54960
Made IsContextLost automatically set the flag by checking with the emscripten
Benjamin Golinvaux <bgo@osimis.io>
parents:
949
diff
changeset
|
547 LOG(ERROR) << "OrthancSeriesVolumeProgressiveLoader::LoadSeries(const std::string& seriesId): (active_)"; |
814 | 548 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
549 } | |
550 else | |
551 { | |
552 active_ = true; | |
553 | |
1299
c38c89684d83
replacing std::auto_ptr by std::unique_ptr
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1279
diff
changeset
|
554 std::unique_ptr<OrthancStone::OrthancRestApiCommand> command(new OrthancStone::OrthancRestApiCommand); |
814 | 555 command->SetUri("/series/" + seriesId + "/instances-tags"); |
1310
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
556 { |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
557 std::unique_ptr<OrthancStone::ILoadersContext::ILock> lock(loadersContext_.Lock()); |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
558 boost::shared_ptr<IObserver> observer(GetSharedObserver()); |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
559 lock->Schedule(observer, 0, command.release()); //TODO: priority! |
9bea7e15b519
- first pass at changes to cope with the refactoring of the loading system
Benjamin Golinvaux <bgo@osimis.io>
parents:
1300
diff
changeset
|
560 } |
814 | 561 } |
562 } | |
563 | |
564 | |
1225
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
565 OrthancStone::IVolumeSlicer::IExtractedSlice* |
16738485e457
deprecating DicomStructureSetLoader, OrthancMultiframeVolumeLoader and OrthancSeriesVolumeProgressiveLoader
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1156
diff
changeset
|
566 OrthancSeriesVolumeProgressiveLoader::ExtractSlice(const OrthancStone::CoordinateSystem3D& cuttingPlane) |
814 | 567 { |
568 if (volume_->HasGeometry()) | |
569 { | |
570 return new ExtractedSlice(*this, cuttingPlane); | |
571 } | |
572 else | |
573 { | |
574 return new IVolumeSlicer::InvalidSlice; | |
575 } | |
576 } | |
577 } |