comparison Framework/Toolbox/OrthancSeriesLoader.cpp @ 32:517c46f527cd

sync
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 19 Dec 2016 11:00:23 +0100
parents 9aace933cb64
children 6465fbd23bce
comparison
equal deleted inserted replaced
31:9aace933cb64 32:517c46f527cd
35 #include "../Messaging/MessagingToolbox.h" 35 #include "../Messaging/MessagingToolbox.h"
36 #include "../../Resources/Orthanc/Core/Images/Image.h" 36 #include "../../Resources/Orthanc/Core/Images/Image.h"
37 #include "../../Resources/Orthanc/Core/Images/ImageProcessing.h" 37 #include "../../Resources/Orthanc/Core/Images/ImageProcessing.h"
38 #include "../../Resources/Orthanc/Core/Logging.h" 38 #include "../../Resources/Orthanc/Core/Logging.h"
39 #include "../../Resources/Orthanc/Core/OrthancException.h" 39 #include "../../Resources/Orthanc/Core/OrthancException.h"
40 #include "../../Resources/Orthanc/Plugins/Samples/Common/FullOrthancDataset.h"
40 #include "DicomFrameConverter.h" 41 #include "DicomFrameConverter.h"
41 42
42 namespace OrthancStone 43 namespace OrthancStone
43 { 44 {
44 class OrthancSeriesLoader::Slice : public boost::noncopyable 45 class OrthancSeriesLoader::Slice : public boost::noncopyable
359 { 360 {
360 assert(GeometryToolbox::IsParallel(normal, slices_->GetSlice(i).GetGeometry().GetNormal())); 361 assert(GeometryToolbox::IsParallel(normal, slices_->GetSlice(i).GetGeometry().GetNormal()));
361 geometry_.AddSlice(slices_->GetSlice(i).GetGeometry()); 362 geometry_.AddSlice(slices_->GetSlice(i).GetGeometry());
362 } 363 }
363 364
364 std::auto_ptr<DicomDataset> dataset(new DicomDataset(orthanc_, slices_->GetSlice(0).GetInstanceId())); 365 std::string uri = "/instances/" + slices_->GetSlice(0).GetInstanceId() + "/tags";
365 if (!dataset->HasTag(DICOM_TAG_ROWS) || 366
366 !dataset->HasTag(DICOM_TAG_COLUMNS)) 367 OrthancPlugins::FullOrthancDataset dataset(orthanc_, uri);
368 OrthancPlugins::DicomDatasetReader reader(dataset);
369
370 if (!reader.GetUnsignedIntegerValue(width_, OrthancPlugins::DICOM_TAG_COLUMNS) ||
371 !reader.GetUnsignedIntegerValue(height_, OrthancPlugins::DICOM_TAG_ROWS))
367 { 372 {
368 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentTag); 373 throw Orthanc::OrthancException(Orthanc::ErrorCode_InexistentTag);
369 } 374 }
370 375
371 DicomFrameConverter converter; 376 DicomFrameConverter converter;
372 converter.ReadParameters(*dataset); 377 converter.ReadParameters(dataset);
373
374 format_ = converter.GetExpectedPixelFormat(); 378 format_ = converter.GetExpectedPixelFormat();
375 width_ = dataset->GetUnsignedIntegerValue(DICOM_TAG_COLUMNS);
376 height_ = dataset->GetUnsignedIntegerValue(DICOM_TAG_ROWS);
377 } 379 }
378 380
379 381
380 DicomDataset* OrthancSeriesLoader::DownloadDicom(size_t index) 382 OrthancPlugins::IDicomDataset* OrthancSeriesLoader::DownloadDicom(size_t index)
381 { 383 {
382 std::auto_ptr<DicomDataset> dataset(new DicomDataset(orthanc_, slices_->GetSlice(index).GetInstanceId())); 384 std::string uri = "/instances/" + slices_->GetSlice(index).GetInstanceId() + "/tags";
383 385
384 if (dataset->HasTag(DICOM_TAG_NUMBER_OF_FRAMES) && 386 std::auto_ptr<OrthancPlugins::IDicomDataset> dataset(new OrthancPlugins::FullOrthancDataset(orthanc_, uri));
385 dataset->GetUnsignedIntegerValue(DICOM_TAG_NUMBER_OF_FRAMES) != 1) 387 OrthancPlugins::DicomDatasetReader reader(*dataset);
388
389 unsigned int frames;
390 if (reader.GetUnsignedIntegerValue(frames, OrthancPlugins::DICOM_TAG_NUMBER_OF_FRAMES) &&
391 frames != 1)
386 { 392 {
387 LOG(ERROR) << "One instance in this series has more than 1 frame"; 393 LOG(ERROR) << "One instance in this series has more than 1 frame";
388 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat); 394 throw Orthanc::OrthancException(Orthanc::ErrorCode_BadFileFormat);
389 } 395 }
390 396