diff UnitTestsSources/UnitTestsMain.cpp @ 88:90bf4116a23c wasm

ISlicedVolume
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 26 May 2017 16:11:52 +0200
parents 4a541cd4fa83
children f244018a4e4b
line wrap: on
line diff
--- a/UnitTestsSources/UnitTestsMain.cpp	Fri May 26 15:31:58 2017 +0200
+++ b/UnitTestsSources/UnitTestsMain.cpp	Fri May 26 16:11:52 2017 +0200
@@ -30,6 +30,7 @@
 
 #include "../Framework/Toolbox/IVolumeSlicesObserver.h"
 #include "../Framework/Volumes/ImageBuffer3D.h"
+#include "../Framework/Volumes/SlicedVolumeBase.h"
 #include "../Framework/Toolbox/DownloadStack.h"
 #include "../Resources/Orthanc/Core/Images/ImageProcessing.h"
 
@@ -75,7 +76,9 @@
   };
 
 
-  class OrthancVolumeImageLoader : private OrthancSlicesLoader::ICallback
+  class OrthancVolumeImageLoader : 
+    public SlicedVolumeBase,
+    private OrthancSlicesLoader::ICallback
   { 
   private:
     OrthancSlicesLoader           loader_;
@@ -143,6 +146,7 @@
       if (loader.GetSliceCount() == 0)
       {
         LOG(ERROR) << "Empty volume image";
+        SlicedVolumeBase::NotifyGeometryError();
         return;
       }
 
@@ -150,6 +154,7 @@
       {
         if (!IsCompatible(loader.GetSlice(0), loader.GetSlice(i)))
         {
+          SlicedVolumeBase::NotifyGeometryError();
           return;
         }
       }
@@ -172,6 +177,7 @@
         if (!GeometryToolbox::IsNear(spacingZ, GetDistance(loader.GetSlice(i - 1), loader.GetSlice(i))))
         {
           LOG(ERROR) << "The distance between successive slices is not constant in a volume image";
+          SlicedVolumeBase::NotifyGeometryError();
           return;
         }
       }
@@ -190,6 +196,8 @@
 
       downloadStack_.reset(new DownloadStack(loader.GetSliceCount()));
 
+      SlicedVolumeBase::NotifyGeometryReady();
+
       for (unsigned int i = 0; i < 4; i++)  // Limit to 4 simultaneous downloads
       {
         ScheduleSliceDownload();
@@ -209,10 +217,12 @@
       std::auto_ptr<Orthanc::ImageAccessor> protection(image);
 
       {
-        ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, 0);
+        ImageBuffer3D::SliceWriter writer(*image_, VolumeProjection_Axial, sliceIndex);
         Orthanc::ImageProcessing::Copy(writer.GetAccessor(), *protection);
       }
 
+      SlicedVolumeBase::NotifySliceChange(sliceIndex, slice);
+
       ScheduleSliceDownload();
     }
 
@@ -242,6 +252,16 @@
       loader_.ScheduleLoadInstance(instanceId, frame);
     }
 
+    virtual size_t GetSliceCount() const
+    {
+      return loader_.GetSliceCount();
+    }
+
+    virtual const Slice& GetSlice(size_t index) const
+    {
+      return loader_.GetSlice(index);
+    }
+
     void SetObserver(IVolumeSlicesObserver& observer)
     {
       if (observer_ == NULL)