Mercurial > hg > orthanc-stone
comparison Framework/dev.h @ 136:a06ad9d7406e wasm
ISlicedVolume::NotifyVolumeReady
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 16 Jan 2018 12:49:54 +0100 |
parents | e2fe9352f240 |
children | 77c4fef7f4a5 |
comparison
equal
deleted
inserted
replaced
135:e2fe9352f240 | 136:a06ad9d7406e |
---|---|
37 #include <boost/math/special_functions/round.hpp> | 37 #include <boost/math/special_functions/round.hpp> |
38 | 38 |
39 | 39 |
40 namespace OrthancStone | 40 namespace OrthancStone |
41 { | 41 { |
42 // TODO: Handle errors while loading | |
42 class OrthancVolumeImage : | 43 class OrthancVolumeImage : |
43 public SlicedVolumeBase, | 44 public SlicedVolumeBase, |
44 private OrthancSlicesLoader::ICallback | 45 private OrthancSlicesLoader::ICallback |
45 { | 46 { |
46 private: | 47 private: |
47 OrthancSlicesLoader loader_; | 48 OrthancSlicesLoader loader_; |
48 std::auto_ptr<ImageBuffer3D> image_; | 49 std::auto_ptr<ImageBuffer3D> image_; |
49 std::auto_ptr<DownloadStack> downloadStack_; | 50 std::auto_ptr<DownloadStack> downloadStack_; |
50 bool computeRange_; | 51 bool computeRange_; |
52 size_t pendingSlices_; | |
51 | 53 |
52 void ScheduleSliceDownload() | 54 void ScheduleSliceDownload() |
53 { | 55 { |
54 assert(downloadStack_.get() != NULL); | 56 assert(downloadStack_.get() != NULL); |
55 | 57 |
156 image_->SetVoxelDimensions(loader.GetSlice(0).GetPixelSpacingX(), | 158 image_->SetVoxelDimensions(loader.GetSlice(0).GetPixelSpacingX(), |
157 loader.GetSlice(0).GetPixelSpacingY(), spacingZ); | 159 loader.GetSlice(0).GetPixelSpacingY(), spacingZ); |
158 image_->Clear(); | 160 image_->Clear(); |
159 | 161 |
160 downloadStack_.reset(new DownloadStack(loader.GetSliceCount())); | 162 downloadStack_.reset(new DownloadStack(loader.GetSliceCount())); |
163 pendingSlices_ = loader.GetSliceCount(); | |
161 | 164 |
162 for (unsigned int i = 0; i < 4; i++) // Limit to 4 simultaneous downloads | 165 for (unsigned int i = 0; i < 4; i++) // Limit to 4 simultaneous downloads |
163 { | 166 { |
164 ScheduleSliceDownload(); | 167 ScheduleSliceDownload(); |
165 } | 168 } |
184 { | 187 { |
185 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, sliceIndex); | 188 ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, sliceIndex); |
186 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), *image); | 189 Orthanc::ImageProcessing::Copy(writer.GetAccessor(), *image); |
187 } | 190 } |
188 | 191 |
189 SlicedVolumeBase::NotifySliceChange(sliceIndex, slice); | 192 SlicedVolumeBase::NotifySliceChange(sliceIndex, slice); |
193 | |
194 if (pendingSlices_ == 1) | |
195 { | |
196 SlicedVolumeBase::NotifyVolumeReady(); | |
197 pendingSlices_ = 0; | |
198 } | |
199 else if (pendingSlices_ > 1) | |
200 { | |
201 pendingSlices_ -= 1; | |
202 } | |
190 | 203 |
191 ScheduleSliceDownload(); | 204 ScheduleSliceDownload(); |
192 } | 205 } |
193 | 206 |
194 virtual void NotifySliceImageError(const OrthancSlicesLoader& loader, | 207 virtual void NotifySliceImageError(const OrthancSlicesLoader& loader, |
202 | 215 |
203 public: | 216 public: |
204 OrthancVolumeImage(IWebService& orthanc, | 217 OrthancVolumeImage(IWebService& orthanc, |
205 bool computeRange) : | 218 bool computeRange) : |
206 loader_(*this, orthanc), | 219 loader_(*this, orthanc), |
207 computeRange_(computeRange) | 220 computeRange_(computeRange), |
221 pendingSlices_(0) | |
208 { | 222 { |
209 } | 223 } |
210 | 224 |
211 void ScheduleLoadSeries(const std::string& seriesId) | 225 void ScheduleLoadSeries(const std::string& seriesId) |
212 { | 226 { |