changeset 784:9f3b2027a4a9

DicomStructureSetLoader
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 27 May 2019 17:20:59 +0200
parents cd13a062c9bd
children 5aa728500586
files Resources/CMake/OrthancStoneConfiguration.cmake Samples/Sdl/Loader.cpp
diffstat 2 files changed, 93 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Resources/CMake/OrthancStoneConfiguration.cmake	Mon May 27 15:54:53 2019 +0200
+++ b/Resources/CMake/OrthancStoneConfiguration.cmake	Mon May 27 17:20:59 2019 +0200
@@ -313,10 +313,6 @@
 
 if (ENABLE_STONE_DEPRECATED)
   list(APPEND ORTHANC_STONE_SOURCES
-    ${ORTHANC_ROOT}/Plugins/Samples/Common/DicomDatasetReader.cpp
-    ${ORTHANC_ROOT}/Plugins/Samples/Common/DicomPath.cpp
-    ${ORTHANC_ROOT}/Plugins/Samples/Common/FullOrthancDataset.cpp
-    ${ORTHANC_ROOT}/Plugins/Samples/Common/IOrthancConnection.cpp
     ${ORTHANC_STONE_ROOT}/Framework/Deprecated/Layers/CircleMeasureTracker.cpp
     ${ORTHANC_STONE_ROOT}/Framework/Deprecated/Layers/ColorFrameRenderer.cpp
     ${ORTHANC_STONE_ROOT}/Framework/Deprecated/Layers/DicomSeriesVolumeSlicer.cpp
@@ -373,6 +369,11 @@
   #${ORTHANC_STONE_ROOT}/Framework/Layers/SeriesFrameRendererFactory.cpp
   #${ORTHANC_STONE_ROOT}/Framework/Layers/SingleFrameRendererFactory.cpp
 
+  ${ORTHANC_ROOT}/Plugins/Samples/Common/DicomDatasetReader.cpp
+  ${ORTHANC_ROOT}/Plugins/Samples/Common/DicomPath.cpp
+  ${ORTHANC_ROOT}/Plugins/Samples/Common/FullOrthancDataset.cpp
+  ${ORTHANC_ROOT}/Plugins/Samples/Common/IOrthancConnection.cpp
+
   ${ORTHANC_STONE_ROOT}/Framework/Scene2D/CairoCompositor.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Scene2D/ColorTextureSceneLayer.cpp
   ${ORTHANC_STONE_ROOT}/Framework/Scene2D/FloatTextureSceneLayer.cpp
--- a/Samples/Sdl/Loader.cpp	Mon May 27 15:54:53 2019 +0200
+++ b/Samples/Sdl/Loader.cpp	Mon May 27 17:20:59 2019 +0200
@@ -37,6 +37,7 @@
 #include "../../Framework/StoneInitialization.h"
 #include "../../Framework/Toolbox/GeometryToolbox.h"
 #include "../../Framework/Toolbox/SlicesSorter.h"
+#include "../../Framework/Toolbox/DicomStructureSet.h"
 #include "../../Framework/Volumes/ImageBuffer3D.h"
 #include "../../Framework/Volumes/VolumeImageGeometry.h"
 #include "../../Framework/Volumes/VolumeReslicer.h"
@@ -1462,6 +1463,86 @@
 
 
 
+  class DicomStructureSetLoader :
+    public IObserver,
+    public IVolumeSlicer
+  {
+  private:
+    enum State
+    {
+      State_Setup,
+      State_Loading,
+      State_Ready
+    };    
+    
+    
+    std::auto_ptr<DicomStructureSet>  content_;
+    IOracle&                          oracle_;
+    State                             state_;
+    std::string                       instanceId_;
+
+    void Handle(const OrthancRestApiCommand::SuccessMessage& message)
+    {
+      if (state_ != State_Loading)
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+      }
+
+      const boost::posix_time::ptime start = boost::posix_time::microsec_clock::local_time();
+
+      {
+        OrthancPlugins::FullOrthancDataset dicom(message.GetAnswer());
+        content_.reset(new DicomStructureSet(dicom));
+      }
+
+      const boost::posix_time::ptime end = boost::posix_time::microsec_clock::local_time();
+
+      printf("LOADED: %d\n", (end - start).total_milliseconds());
+      state_ = State_Ready;
+    }
+      
+    
+  public:
+    DicomStructureSetLoader(IOracle& oracle,
+                            IObservable& oracleObservable) :
+      IObserver(oracleObservable.GetBroker()),
+      oracle_(oracle),
+      state_(State_Setup)
+    {
+      oracleObservable.RegisterObserverCallback(
+        new Callable<DicomStructureSetLoader, OrthancRestApiCommand::SuccessMessage>
+        (*this, &DicomStructureSetLoader::Handle));
+    }
+    
+    
+    void LoadInstance(const std::string& instanceId)
+    {
+      if (state_ != State_Setup)
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls);
+      }
+      else
+      {
+        state_ = State_Loading;
+        instanceId_ = instanceId;
+
+        {
+          std::auto_ptr<OrthancRestApiCommand> command(new OrthancRestApiCommand);
+          command->SetHttpHeader("Accept-Encoding", "gzip");
+          command->SetUri("/instances/" + instanceId + "/tags?ignore-length=3006-0050");
+          oracle_.Schedule(*this, command.release());
+        }
+      }
+    }
+
+    virtual IExtractedSlice* ExtractSlice(const CoordinateSystem3D& cuttingPlane)
+    {
+      return NULL;
+    }
+  };
+
+
+
   class VolumeSceneLayerSource : public boost::noncopyable
   {
   private:
@@ -1854,12 +1935,14 @@
   boost::shared_ptr<Toto> toto;
   boost::shared_ptr<OrthancStone::OrthancSeriesVolumeProgressiveLoader> ctLoader;
   boost::shared_ptr<OrthancStone::OrthancMultiframeVolumeLoader> doseLoader;
+  boost::shared_ptr<OrthancStone::DicomStructureSetLoader>  rtstructLoader;
 
   {
     OrthancStone::NativeApplicationContext::WriterLock lock(context);
     toto.reset(new Toto(oracle, lock.GetOracleObservable()));
     ctLoader.reset(new OrthancStone::OrthancSeriesVolumeProgressiveLoader(ct, oracle, lock.GetOracleObservable()));
     doseLoader.reset(new OrthancStone::OrthancMultiframeVolumeLoader(dose, oracle, lock.GetOracleObservable()));
+    rtstructLoader.reset(new OrthancStone::DicomStructureSetLoader(oracle, lock.GetOracleObservable()));
   }
 
 
@@ -1882,7 +1965,7 @@
     toto->SetVolume2(1, doseLoader, config.release());
   }
 
-  oracle.Schedule(*toto, new OrthancStone::SleepOracleCommand(100));
+  //oracle.Schedule(*toto, new OrthancStone::SleepOracleCommand(100));
 
   if (0)
   {
@@ -1959,9 +2042,11 @@
     }
   }
 
+  
   // 2017-11-17-Anonymized
-  ctLoader->LoadSeries("cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618");  // CT
-  doseLoader->LoadInstance("41029085-71718346-811efac4-420e2c15-d39f99b6");  // RT-DOSE
+  //ctLoader->LoadSeries("cb3ea4d1-d08f3856-ad7b6314-74d88d77-60b05618");  // CT
+  //doseLoader->LoadInstance("41029085-71718346-811efac4-420e2c15-d39f99b6");  // RT-DOSE
+  rtstructLoader->LoadInstance("83d9c0c3-913a7fee-610097d7-cbf0522d-fd75bee6");  // RT-STRUCT
 
   // 2015-01-28-Multiframe
   //doseLoader->LoadInstance("88f71e2a-5fad1c61-96ed14d6-5b3d3cf7-a5825279");  // Multiframe CT