changeset 692:10910827f235

simplification in DicomVolumeSlicer
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 16 May 2019 20:39:30 +0200
parents 032a94cca5c4
children 9a474e90e832
files Samples/Sdl/Loader.cpp
diffstat 1 files changed, 26 insertions(+), 23 deletions(-) [+]
line wrap: on
line diff
--- a/Samples/Sdl/Loader.cpp	Thu May 16 20:32:16 2019 +0200
+++ b/Samples/Sdl/Loader.cpp	Thu May 16 20:39:30 2019 +0200
@@ -1603,7 +1603,7 @@
 
 
 
-  class VolumeSlicerBase : public IVolumeSlicer
+  /*  class VolumeSlicerBase : public IVolumeSlicer
   {
   private:
     OrthancStone::Scene2D&            scene_;
@@ -1653,24 +1653,29 @@
       first_(true)
     {
     }
-  };
+    };*/
   
 
 
-  class DicomVolumeSlicer : public VolumeSlicerBase
+  class DicomVolumeSlicer : public IVolumeSlicer
   {
   private:
-    const DicomVolumeImage&  volume_;
-    bool                     hasLastSlice_;
-    uint64_t                 lastSliceRevision_;
+    OrthancStone::Scene2D&          scene_;
+    int                             layerDepth_;
+    const DicomVolumeImage&         volume_;
+    bool                            first_;
+    OrthancStone::VolumeProjection  lastProjection_;
+    unsigned int                    lastSliceIndex_;
+    uint64_t                        lastSliceRevision_;
 
   public:
     DicomVolumeSlicer(OrthancStone::Scene2D& scene,
                       int layerDepth,
                       const DicomVolumeImage& volume) :
-      VolumeSlicerBase(scene, layerDepth),
+      scene_(scene),
+      layerDepth_(layerDepth),
       volume_(volume),
-      hasLastSlice_(false)
+      first_(true)
     {
     }
     
@@ -1678,7 +1683,7 @@
     {
       if (!volume_.HasGeometry())
       {
-        DeleteLayer();
+        scene_.DeleteLayer(layerDepth_);
         return;
       }
 
@@ -1688,7 +1693,7 @@
       {
         // The cutting plane is neither axial, nor coronal, nor
         // sagittal. Could use "VolumeReslicer" here.
-        DeleteLayer();
+        scene_.DeleteLayer(layerDepth_);
         return;
       }
 
@@ -1703,22 +1708,20 @@
         // revision of the volume
         sliceRevision = volume_.GetRevision();
       }
-      
-      if (!HasViewportPlaneChanged(plane) &&
-          hasLastSlice_ &&
+
+      if (first_ ||
+          lastProjection_ == projection ||
+          lastSliceIndex_ == sliceIndex ||
           lastSliceRevision_ == sliceRevision)
       {
-        // The viewport plane and the content of the slice have not
-        // changed since the last time the layer was set: No update needed
-        return;
-      }
-      else
-      {
-        // The layer must be updated
-        SetLastViewportPlane(plane);
-        hasLastSlice_ = true;
+        // Eiter the viewport plane, or the content of the slice have not
+        // changed since the last time the layer was set: Update is needed
+
+        first_ = false;
+        lastProjection_ = projection;
+        lastSliceIndex_ = sliceIndex;
         lastSliceRevision_ = sliceRevision;
-
+        
         {
           OrthancStone::ImageBuffer3D::SliceReader reader(volume_.GetImage(), projection, sliceIndex);