Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/OrthancSlicesLoader.cpp @ 377:8eb4fe74000f
refactoring
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 05 Nov 2018 16:18:27 +0100 |
parents | 557c8ff1db5c |
children | 814fa32e2fcc |
comparison
equal
deleted
inserted
replaced
376:70256a53ff21 | 377:8eb4fe74000f |
---|---|
230 state_ = State_Error; | 230 state_ = State_Error; |
231 } | 231 } |
232 | 232 |
233 void OrthancSlicesLoader::OnSliceImageError(const OrthancApiClient::HttpErrorMessage& message) | 233 void OrthancSlicesLoader::OnSliceImageError(const OrthancApiClient::HttpErrorMessage& message) |
234 { | 234 { |
235 NotifySliceImageError(dynamic_cast<const Operation&>(*(message.Payload))); | 235 NotifySliceImageError(dynamic_cast<const Operation&>(message.GetPayload())); |
236 state_ = State_Error; | 236 state_ = State_Error; |
237 } | 237 } |
238 | 238 |
239 void OrthancSlicesLoader::ParseSeriesGeometry(const OrthancApiClient::JsonResponseReadyMessage& message) | 239 void OrthancSlicesLoader::ParseSeriesGeometry(const OrthancApiClient::JsonResponseReadyMessage& message) |
240 { | 240 { |
241 Json::Value series = message.Response; | 241 const Json::Value& series = message.GetJson(); |
242 Json::Value::Members instances = series.getMemberNames(); | 242 Json::Value::Members instances = series.getMemberNames(); |
243 | 243 |
244 slices_.Reserve(instances.size()); | 244 slices_.Reserve(instances.size()); |
245 | 245 |
246 for (size_t i = 0; i < instances.size(); i++) | 246 for (size_t i = 0; i < instances.size(); i++) |
273 SortAndFinalizeSlices(); | 273 SortAndFinalizeSlices(); |
274 } | 274 } |
275 | 275 |
276 void OrthancSlicesLoader::ParseInstanceGeometry(const OrthancApiClient::JsonResponseReadyMessage& message) | 276 void OrthancSlicesLoader::ParseInstanceGeometry(const OrthancApiClient::JsonResponseReadyMessage& message) |
277 { | 277 { |
278 Json::Value tags = message.Response; | 278 const Json::Value& tags = message.GetJson(); |
279 const std::string& instanceId = dynamic_cast<OrthancSlicesLoader::Operation*>(message.Payload.get())->GetInstanceId(); | 279 const std::string& instanceId = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()).GetInstanceId(); |
280 | 280 |
281 OrthancPlugins::FullOrthancDataset dataset(tags); | 281 OrthancPlugins::FullOrthancDataset dataset(tags); |
282 | 282 |
283 Orthanc::DicomMap dicom; | 283 Orthanc::DicomMap dicom; |
284 MessagingToolbox::ConvertDataset(dicom, dataset); | 284 MessagingToolbox::ConvertDataset(dicom, dataset); |
310 } | 310 } |
311 | 311 |
312 | 312 |
313 void OrthancSlicesLoader::ParseFrameGeometry(const OrthancApiClient::JsonResponseReadyMessage& message) | 313 void OrthancSlicesLoader::ParseFrameGeometry(const OrthancApiClient::JsonResponseReadyMessage& message) |
314 { | 314 { |
315 Json::Value tags = message.Response; | 315 const Json::Value& tags = message.GetJson(); |
316 const std::string& instanceId = dynamic_cast<OrthancSlicesLoader::Operation*>(message.Payload.get())->GetInstanceId(); | 316 const std::string& instanceId = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()).GetInstanceId(); |
317 unsigned int frame = dynamic_cast<OrthancSlicesLoader::Operation*>(message.Payload.get())->GetFrame(); | 317 unsigned int frame = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()).GetFrame(); |
318 | 318 |
319 OrthancPlugins::FullOrthancDataset dataset(tags); | 319 OrthancPlugins::FullOrthancDataset dataset(tags); |
320 | 320 |
321 state_ = State_GeometryReady; | 321 state_ = State_GeometryReady; |
322 | 322 |
338 } | 338 } |
339 | 339 |
340 | 340 |
341 void OrthancSlicesLoader::ParseSliceImagePng(const OrthancApiClient::BinaryResponseReadyMessage& message) | 341 void OrthancSlicesLoader::ParseSliceImagePng(const OrthancApiClient::BinaryResponseReadyMessage& message) |
342 { | 342 { |
343 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(*message.Payload.get()); | 343 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); |
344 boost::shared_ptr<Orthanc::ImageAccessor> image; | 344 boost::shared_ptr<Orthanc::ImageAccessor> image; |
345 | 345 |
346 try | 346 try |
347 { | 347 { |
348 image.reset(new Orthanc::PngReader); | 348 image.reset(new Orthanc::PngReader); |
349 dynamic_cast<Orthanc::PngReader&>(*image).ReadFromMemory(message.Answer, message.AnswerSize); | 349 dynamic_cast<Orthanc::PngReader&>(*image).ReadFromMemory(message.GetAnswer(), message.GetAnswerSize()); |
350 } | 350 } |
351 catch (Orthanc::OrthancException&) | 351 catch (Orthanc::OrthancException&) |
352 { | 352 { |
353 NotifySliceImageError(operation); | 353 NotifySliceImageError(operation); |
354 return; | 354 return; |
378 NotifySliceImageSuccess(operation, image); | 378 NotifySliceImageSuccess(operation, image); |
379 } | 379 } |
380 | 380 |
381 void OrthancSlicesLoader::ParseSliceImagePam(const OrthancApiClient::BinaryResponseReadyMessage& message) | 381 void OrthancSlicesLoader::ParseSliceImagePam(const OrthancApiClient::BinaryResponseReadyMessage& message) |
382 { | 382 { |
383 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(*message.Payload.get()); | 383 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); |
384 boost::shared_ptr<Orthanc::ImageAccessor> image; | 384 boost::shared_ptr<Orthanc::ImageAccessor> image; |
385 | 385 |
386 try | 386 try |
387 { | 387 { |
388 image.reset(new Orthanc::PamReader); | 388 image.reset(new Orthanc::PamReader); |
389 dynamic_cast<Orthanc::PamReader&>(*image).ReadFromMemory(std::string(reinterpret_cast<const char*>(message.Answer), message.AnswerSize)); | 389 dynamic_cast<Orthanc::PamReader&>(*image).ReadFromMemory(std::string(reinterpret_cast<const char*>(message.GetAnswer()), message.GetAnswerSize())); |
390 } | 390 } |
391 catch (Orthanc::OrthancException&) | 391 catch (Orthanc::OrthancException&) |
392 { | 392 { |
393 NotifySliceImageError(operation); | 393 NotifySliceImageError(operation); |
394 return; | 394 return; |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 void OrthancSlicesLoader::ParseSliceImageJpeg(const OrthancApiClient::JsonResponseReadyMessage& message) | 422 void OrthancSlicesLoader::ParseSliceImageJpeg(const OrthancApiClient::JsonResponseReadyMessage& message) |
423 { | 423 { |
424 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(*message.Payload.get()); | 424 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); |
425 | 425 |
426 Json::Value encoded = message.Response; | 426 const Json::Value& encoded = message.GetJson(); |
427 if (encoded.type() != Json::objectValue || | 427 if (encoded.type() != Json::objectValue || |
428 !encoded.isMember("Orthanc") || | 428 !encoded.isMember("Orthanc") || |
429 encoded["Orthanc"].type() != Json::objectValue) | 429 encoded["Orthanc"].type() != Json::objectValue) |
430 { | 430 { |
431 NotifySliceImageError(operation); | 431 NotifySliceImageError(operation); |
432 return; | 432 return; |
433 } | 433 } |
434 | 434 |
435 Json::Value& info = encoded["Orthanc"]; | 435 const Json::Value& info = encoded["Orthanc"]; |
436 if (!info.isMember("PixelData") || | 436 if (!info.isMember("PixelData") || |
437 !info.isMember("Stretched") || | 437 !info.isMember("Stretched") || |
438 !info.isMember("Compression") || | 438 !info.isMember("Compression") || |
439 info["Compression"].type() != Json::stringValue || | 439 info["Compression"].type() != Json::stringValue || |
440 info["PixelData"].type() != Json::stringValue || | 440 info["PixelData"].type() != Json::stringValue || |
591 } | 591 } |
592 }; | 592 }; |
593 | 593 |
594 void OrthancSlicesLoader::ParseSliceRawImage(const OrthancApiClient::BinaryResponseReadyMessage& message) | 594 void OrthancSlicesLoader::ParseSliceRawImage(const OrthancApiClient::BinaryResponseReadyMessage& message) |
595 { | 595 { |
596 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(*message.Payload.get()); | 596 const Operation& operation = dynamic_cast<const OrthancSlicesLoader::Operation&>(message.GetPayload()); |
597 Orthanc::GzipCompressor compressor; | 597 Orthanc::GzipCompressor compressor; |
598 | 598 |
599 std::string raw; | 599 std::string raw; |
600 compressor.Uncompress(raw, message.Answer, message.AnswerSize); | 600 compressor.Uncompress(raw, message.GetAnswer(), message.GetAnswerSize()); |
601 | 601 |
602 const Orthanc::DicomImageInformation& info = operation.GetSlice().GetImageInformation(); | 602 const Orthanc::DicomImageInformation& info = operation.GetSlice().GetImageInformation(); |
603 | 603 |
604 if (info.GetBitsAllocated() == 32 && | 604 if (info.GetBitsAllocated() == 32 && |
605 info.GetBitsStored() == 32 && | 605 info.GetBitsStored() == 32 && |