Mercurial > hg > orthanc-stone
comparison Framework/Deprecated/Toolbox/OrthancSlicesLoader.cpp @ 1298:8a0a62189f46
replacing std::auto_ptr by std::unique_ptr
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 02 Mar 2020 16:31:30 +0100 |
parents | 2d8ab34c8c91 |
children | 257f2c9a02ac |
comparison
equal
deleted
inserted
replaced
1296:86400fa16091 | 1298:8a0a62189f46 |
---|---|
126 return instanceId_; | 126 return instanceId_; |
127 } | 127 } |
128 | 128 |
129 static Operation* DownloadInstanceGeometry(const std::string& instanceId) | 129 static Operation* DownloadInstanceGeometry(const std::string& instanceId) |
130 { | 130 { |
131 std::auto_ptr<Operation> operation(new Operation(Mode_InstanceGeometry)); | 131 std::unique_ptr<Operation> operation(new Operation(Mode_InstanceGeometry)); |
132 operation->instanceId_ = instanceId; | 132 operation->instanceId_ = instanceId; |
133 return operation.release(); | 133 return operation.release(); |
134 } | 134 } |
135 | 135 |
136 static Operation* DownloadFrameGeometry(const std::string& instanceId, | 136 static Operation* DownloadFrameGeometry(const std::string& instanceId, |
137 unsigned int frame) | 137 unsigned int frame) |
138 { | 138 { |
139 std::auto_ptr<Operation> operation(new Operation(Mode_FrameGeometry)); | 139 std::unique_ptr<Operation> operation(new Operation(Mode_FrameGeometry)); |
140 operation->instanceId_ = instanceId; | 140 operation->instanceId_ = instanceId; |
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 Slice& slice, |
147 SliceImageQuality quality) | 147 SliceImageQuality quality) |
148 { | 148 { |
149 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadImage)); | 149 std::unique_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 Slice& slice) |
158 { | 158 { |
159 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadRawImage)); | 159 std::unique_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 Slice& slice) |
167 { | 167 { |
168 std::auto_ptr<Operation> tmp(new Operation(Mode_LoadDicomFile)); | 168 std::unique_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 } |
172 | 172 |
173 }; | 173 }; |
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::unique_ptr<Slice> slice(new Slice); |
245 if (slice->ParseOrthancFrame(dicom, instances[i], frame)) | 245 if (slice->ParseOrthancFrame(dicom, instances[i], frame)) |
246 { | 246 { |
247 OrthancStone::CoordinateSystem3D geometry = slice->GetGeometry(); | 247 OrthancStone::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::unique_ptr<Slice> slice(new Slice); |
281 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) | 281 if (slice->ParseOrthancFrame(dicom, instanceId, frame)) |
282 { | 282 { |
283 OrthancStone::CoordinateSystem3D geometry = slice->GetGeometry(); | 283 OrthancStone::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::unique_ptr<Slice> slice(new 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 OrthancStone::CoordinateSystem3D geometry = slice->GetGeometry(); | 316 OrthancStone::CoordinateSystem3D geometry = slice->GetGeometry(); |
327 | 327 |
328 | 328 |
329 void OrthancSlicesLoader::ParseSliceImagePng(const OrthancApiClient::BinaryResponseReadyMessage& message) | 329 void OrthancSlicesLoader::ParseSliceImagePng(const OrthancApiClient::BinaryResponseReadyMessage& message) |
330 { | 330 { |
331 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); | 331 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); |
332 std::auto_ptr<Orthanc::ImageAccessor> image; | 332 std::unique_ptr<Orthanc::ImageAccessor> image; |
333 | 333 |
334 try | 334 try |
335 { | 335 { |
336 image.reset(new Orthanc::PngReader); | 336 image.reset(new Orthanc::PngReader); |
337 dynamic_cast<Orthanc::PngReader&>(*image).ReadFromMemory(message.GetAnswer(), message.GetAnswerSize()); | 337 dynamic_cast<Orthanc::PngReader&>(*image).ReadFromMemory(message.GetAnswer(), message.GetAnswerSize()); |
367 } | 367 } |
368 | 368 |
369 void OrthancSlicesLoader::ParseSliceImagePam(const OrthancApiClient::BinaryResponseReadyMessage& message) | 369 void OrthancSlicesLoader::ParseSliceImagePam(const OrthancApiClient::BinaryResponseReadyMessage& message) |
370 { | 370 { |
371 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); | 371 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); |
372 std::auto_ptr<Orthanc::ImageAccessor> image; | 372 std::unique_ptr<Orthanc::ImageAccessor> image; |
373 | 373 |
374 try | 374 try |
375 { | 375 { |
376 image.reset(new Orthanc::PamReader); | 376 image.reset(new Orthanc::PamReader); |
377 dynamic_cast<Orthanc::PamReader&>(*image).ReadFromMemory(message.GetAnswer(), message.GetAnswerSize()); | 377 dynamic_cast<Orthanc::PamReader&>(*image).ReadFromMemory(message.GetAnswer(), message.GetAnswerSize()); |
447 { | 447 { |
448 isSigned = info["IsSigned"].asBool(); | 448 isSigned = info["IsSigned"].asBool(); |
449 } | 449 } |
450 } | 450 } |
451 | 451 |
452 std::auto_ptr<Orthanc::ImageAccessor> reader; | 452 std::unique_ptr<Orthanc::ImageAccessor> reader; |
453 | 453 |
454 { | 454 { |
455 std::string jpeg; | 455 std::string jpeg; |
456 //Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString()); | 456 //Orthanc::Toolbox::DecodeBase64(jpeg, info["PixelData"].asString()); |
457 jpeg = base64_decode(info["PixelData"].asString()); | 457 jpeg = base64_decode(info["PixelData"].asString()); |
534 NotifySliceImageError(operation); | 534 NotifySliceImageError(operation); |
535 return; | 535 return; |
536 } | 536 } |
537 | 537 |
538 // Decode a grayscale JPEG 8bpp image coming from the Web viewer | 538 // Decode a grayscale JPEG 8bpp image coming from the Web viewer |
539 std::auto_ptr<Orthanc::ImageAccessor> image | 539 std::unique_ptr<Orthanc::ImageAccessor> image |
540 (new Orthanc::Image(expectedFormat, reader->GetWidth(), reader->GetHeight(), false)); | 540 (new Orthanc::Image(expectedFormat, reader->GetWidth(), reader->GetHeight(), false)); |
541 | 541 |
542 Orthanc::ImageProcessing::Convert(*image, *reader); | 542 Orthanc::ImageProcessing::Convert(*image, *reader); |
543 reader.reset(); | 543 reader.reset(); |
544 | 544 |
597 info.GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome2 && | 597 info.GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome2 && |
598 raw.size() == info.GetWidth() * info.GetHeight() * 4) | 598 raw.size() == info.GetWidth() * info.GetHeight() * 4) |
599 { | 599 { |
600 // This is the case of RT-DOSE (uint32_t values) | 600 // This is the case of RT-DOSE (uint32_t values) |
601 | 601 |
602 std::auto_ptr<Orthanc::ImageAccessor> image | 602 std::unique_ptr<Orthanc::ImageAccessor> image |
603 (new StringImage(Orthanc::PixelFormat_Grayscale32, info.GetWidth(), | 603 (new StringImage(Orthanc::PixelFormat_Grayscale32, info.GetWidth(), |
604 info.GetHeight(), raw)); | 604 info.GetHeight(), raw)); |
605 | 605 |
606 // TODO - Only for big endian | 606 // TODO - Only for big endian |
607 for (unsigned int y = 0; y < image->GetHeight(); y++) | 607 for (unsigned int y = 0; y < image->GetHeight(); y++) |
621 info.GetChannelCount() == 1 && | 621 info.GetChannelCount() == 1 && |
622 !info.IsSigned() && | 622 !info.IsSigned() && |
623 info.GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome2 && | 623 info.GetPhotometricInterpretation() == Orthanc::PhotometricInterpretation_Monochrome2 && |
624 raw.size() == info.GetWidth() * info.GetHeight() * 2) | 624 raw.size() == info.GetWidth() * info.GetHeight() * 2) |
625 { | 625 { |
626 std::auto_ptr<Orthanc::ImageAccessor> image | 626 std::unique_ptr<Orthanc::ImageAccessor> image |
627 (new StringImage(Orthanc::PixelFormat_Grayscale16, info.GetWidth(), | 627 (new StringImage(Orthanc::PixelFormat_Grayscale16, info.GetWidth(), |
628 info.GetHeight(), raw)); | 628 info.GetHeight(), raw)); |
629 | 629 |
630 // TODO - Big endian ? | 630 // TODO - Big endian ? |
631 | 631 |