Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/OrthancSlicesLoader.cpp @ 714:d2c0e347ddc2
deprecating DicomFrameConverter
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 20 May 2019 16:26:34 +0200 |
parents | 9a474e90e832 |
children | 4f2416d519b4 |
comparison
equal
deleted
inserted
replaced
713:e63c8b9b7b02 | 714:d2c0e347ddc2 |
---|---|
74 { | 74 { |
75 private: | 75 private: |
76 Mode mode_; | 76 Mode mode_; |
77 unsigned int frame_; | 77 unsigned int frame_; |
78 unsigned int sliceIndex_; | 78 unsigned int sliceIndex_; |
79 const Slice* slice_; | 79 const Deprecated::Slice* slice_; |
80 std::string instanceId_; | 80 std::string instanceId_; |
81 SliceImageQuality quality_; | 81 SliceImageQuality quality_; |
82 | 82 |
83 Operation(Mode mode) : | 83 Operation(Mode mode) : |
84 mode_(mode) | 84 mode_(mode) |
103 assert(mode_ == Mode_LoadImage || | 103 assert(mode_ == Mode_LoadImage || |
104 mode_ == Mode_LoadRawImage); | 104 mode_ == Mode_LoadRawImage); |
105 return sliceIndex_; | 105 return sliceIndex_; |
106 } | 106 } |
107 | 107 |
108 const Slice& GetSlice() const | 108 const Deprecated::Slice& GetSlice() const |
109 { | 109 { |
110 assert(mode_ == Mode_LoadImage || | 110 assert(mode_ == Mode_LoadImage || |
111 mode_ == Mode_LoadRawImage); | 111 mode_ == Mode_LoadRawImage); |
112 assert(slice_ != NULL); | 112 assert(slice_ != NULL); |
113 return *slice_; | 113 return *slice_; |
141 operation->frame_ = frame; | 141 operation->frame_ = frame; |
142 return operation.release(); | 142 return operation.release(); |
143 } | 143 } |
144 | 144 |
145 static Operation* DownloadSliceImage(unsigned int sliceIndex, | 145 static Operation* DownloadSliceImage(unsigned int sliceIndex, |
146 const Slice& slice, | 146 const Deprecated::Slice& slice, |
147 SliceImageQuality quality) | 147 SliceImageQuality quality) |
148 { | 148 { |
149 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadImage)); | 149 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadImage)); |
150 tmp->sliceIndex_ = sliceIndex; | 150 tmp->sliceIndex_ = sliceIndex; |
151 tmp->slice_ = &slice; | 151 tmp->slice_ = &slice; |
152 tmp->quality_ = quality; | 152 tmp->quality_ = quality; |
153 return tmp.release(); | 153 return tmp.release(); |
154 } | 154 } |
155 | 155 |
156 static Operation* DownloadSliceRawImage(unsigned int sliceIndex, | 156 static Operation* DownloadSliceRawImage(unsigned int sliceIndex, |
157 const Slice& slice) | 157 const Deprecated::Slice& slice) |
158 { | 158 { |
159 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadRawImage)); | 159 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadRawImage)); |
160 tmp->sliceIndex_ = sliceIndex; | 160 tmp->sliceIndex_ = sliceIndex; |
161 tmp->slice_ = &slice; | 161 tmp->slice_ = &slice; |
162 tmp->quality_ = SliceImageQuality_InternalRaw; | 162 tmp->quality_ = SliceImageQuality_InternalRaw; |
163 return tmp.release(); | 163 return tmp.release(); |
164 } | 164 } |
165 | 165 |
166 static Operation* DownloadDicomFile(const Slice& slice) | 166 static Operation* DownloadDicomFile(const Deprecated::Slice& slice) |
167 { | 167 { |
168 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadDicomFile)); | 168 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadDicomFile)); |
169 tmp->slice_ = &slice; | 169 tmp->slice_ = &slice; |
170 return tmp.release(); | 170 return tmp.release(); |
171 } | 171 } |
239 frames = 1; | 239 frames = 1; |
240 } | 240 } |
241 | 241 |
242 for (unsigned int frame = 0; frame < frames; frame++) | 242 for (unsigned int frame = 0; frame < frames; frame++) |
243 { | 243 { |
244 std::auto_ptr<Slice> slice(new Slice); | 244 std::auto_ptr<Deprecated::Slice> slice(new Deprecated::Slice); |
245 if (slice->ParseOrthancFrame(dicom, instances[i], frame)) | 245 if (slice->ParseOrthancFrame(dicom, instances[i], frame)) |
246 { | 246 { |
247 CoordinateSystem3D geometry = slice->GetGeometry(); | 247 CoordinateSystem3D geometry = slice->GetGeometry(); |
248 slices_.AddSlice(geometry, slice.release()); | 248 slices_.AddSlice(geometry, slice.release()); |
249 } | 249 } |
275 | 275 |
276 LOG(INFO) << "Instance " << instanceId << " contains " << frames << " frame(s)"; | 276 LOG(INFO) << "Instance " << instanceId << " contains " << frames << " frame(s)"; |
277 | 277 |
278 for (unsigned int frame = 0; frame < frames; frame++) | 278 for (unsigned int frame = 0; frame < frames; frame++) |
279 { | 279 { |
280 std::auto_ptr<Slice> slice(new Slice); | 280 std::auto_ptr<Deprecated::Slice> slice(new Deprecated::Slice); |
281 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) | 281 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) |
282 { | 282 { |
283 CoordinateSystem3D geometry = slice->GetGeometry(); | 283 CoordinateSystem3D geometry = slice->GetGeometry(); |
284 slices_.AddSlice(geometry, slice.release()); | 284 slices_.AddSlice(geometry, slice.release()); |
285 } | 285 } |
306 state_ = State_GeometryReady; | 306 state_ = State_GeometryReady; |
307 | 307 |
308 Orthanc::DicomMap dicom; | 308 Orthanc::DicomMap dicom; |
309 MessagingToolbox::ConvertDataset(dicom, dataset); | 309 MessagingToolbox::ConvertDataset(dicom, dataset); |
310 | 310 |
311 std::auto_ptr<Slice> slice(new Slice); | 311 std::auto_ptr<Deprecated::Slice> slice(new Deprecated::Slice); |
312 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) | 312 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) |
313 { | 313 { |
314 LOG(INFO) << "Loaded instance geometry " << instanceId; | 314 LOG(INFO) << "Loaded instance geometry " << instanceId; |
315 | 315 |
316 CoordinateSystem3D geometry = slice->GetGeometry(); | 316 CoordinateSystem3D geometry = slice->GetGeometry(); |
719 | 719 |
720 return slices_.GetSlicesCount(); | 720 return slices_.GetSlicesCount(); |
721 } | 721 } |
722 | 722 |
723 | 723 |
724 const Slice& OrthancSlicesLoader::GetSlice(size_t index) const | 724 const Deprecated::Slice& OrthancSlicesLoader::GetSlice(size_t index) const |
725 { | 725 { |
726 if (state_ != State_GeometryReady) | 726 if (state_ != State_GeometryReady) |
727 { | 727 { |
728 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 728 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
729 } | 729 } |
730 | 730 |
731 return dynamic_cast<const Slice&>(slices_.GetSlicePayload(index)); | 731 return dynamic_cast<const Deprecated::Slice&>(slices_.GetSlicePayload(index)); |
732 } | 732 } |
733 | 733 |
734 | 734 |
735 bool OrthancSlicesLoader::LookupSlice(size_t& index, | 735 bool OrthancSlicesLoader::LookupSlice(size_t& index, |
736 const CoordinateSystem3D& plane) const | 736 const CoordinateSystem3D& plane) const |
744 return (slices_.LookupClosestSlice(index, distance, plane) && | 744 return (slices_.LookupClosestSlice(index, distance, plane) && |
745 distance <= GetSlice(index).GetThickness() / 2.0); | 745 distance <= GetSlice(index).GetThickness() / 2.0); |
746 } | 746 } |
747 | 747 |
748 | 748 |
749 void OrthancSlicesLoader::ScheduleSliceImagePng(const Slice& slice, | 749 void OrthancSlicesLoader::ScheduleSliceImagePng(const Deprecated::Slice& slice, |
750 size_t index) | 750 size_t index) |
751 { | 751 { |
752 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + | 752 std::string uri = ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
753 boost::lexical_cast<std::string>(slice.GetFrame())); | 753 boost::lexical_cast<std::string>(slice.GetFrame())); |
754 | 754 |
779 (*this, &OrthancSlicesLoader::OnSliceImageError), | 779 (*this, &OrthancSlicesLoader::OnSliceImageError), |
780 Operation::DownloadSliceImage( | 780 Operation::DownloadSliceImage( |
781 static_cast<unsigned int>(index), slice, SliceImageQuality_FullPng)); | 781 static_cast<unsigned int>(index), slice, SliceImageQuality_FullPng)); |
782 } | 782 } |
783 | 783 |
784 void OrthancSlicesLoader::ScheduleSliceImagePam(const Slice& slice, | 784 void OrthancSlicesLoader::ScheduleSliceImagePam(const Deprecated::Slice& slice, |
785 size_t index) | 785 size_t index) |
786 { | 786 { |
787 std::string uri = | 787 std::string uri = |
788 ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + | 788 ("/instances/" + slice.GetOrthancInstanceId() + "/frames/" + |
789 boost::lexical_cast<std::string>(slice.GetFrame())); | 789 boost::lexical_cast<std::string>(slice.GetFrame())); |
817 slice, SliceImageQuality_FullPam)); | 817 slice, SliceImageQuality_FullPam)); |
818 } | 818 } |
819 | 819 |
820 | 820 |
821 | 821 |
822 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Slice& slice, | 822 void OrthancSlicesLoader::ScheduleSliceImageJpeg(const Deprecated::Slice& slice, |
823 size_t index, | 823 size_t index, |
824 SliceImageQuality quality) | 824 SliceImageQuality quality) |
825 { | 825 { |
826 unsigned int value; | 826 unsigned int value; |
827 | 827 |
868 if (state_ != State_GeometryReady) | 868 if (state_ != State_GeometryReady) |
869 { | 869 { |
870 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); | 870 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls); |
871 } | 871 } |
872 | 872 |
873 const Slice& slice = GetSlice(index); | 873 const Deprecated::Slice& slice = GetSlice(index); |
874 | 874 |
875 if (slice.HasOrthancDecoding()) | 875 if (slice.HasOrthancDecoding()) |
876 { | 876 { |
877 switch (quality) | 877 switch (quality) |
878 { | 878 { |