changeset 2093:c336e07b675c dicom-sr

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 08 Nov 2023 12:37:42 +0100
parents b7d4d288459a
children 79e984a89a38
files Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp
diffstat 1 files changed, 13 insertions(+), 24 deletions(-) [+]
line wrap: on
line diff
--- a/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Wed Nov 08 10:32:16 2023 +0100
+++ b/Applications/StoneWebViewer/WebAssembly/StoneWebViewer.cpp	Wed Nov 08 12:37:42 2023 +0100
@@ -218,9 +218,6 @@
 
   virtual unsigned int GetFrameNumberInInstance(size_t frameIndex) const = 0;
 
-  // TODO - Could be removed
-  virtual OrthancStone::CoordinateSystem3D GetFrameGeometry(size_t frameIndex) const = 0;
-
   virtual bool LookupFrame(size_t& frameIndex,
                            const std::string& sopInstanceUid,
                            unsigned int frameNumber) const = 0;
@@ -228,6 +225,12 @@
   virtual bool FindClosestFrame(size_t& frameIndex,
                                 const OrthancStone::Vector& point,
                                 double maximumDistance) const = 0;
+
+  static OrthancStone::CoordinateSystem3D GetFrameGeometry(const IFramesCollection& frames,
+                                                           size_t frameIndex)
+  {
+    return frames.GetInstanceOfFrame(frameIndex).GetFrameGeometry(frames.GetFrameNumberInInstance(frameIndex));
+  }
 };
 
 
@@ -264,11 +267,6 @@
     return frames_->GetFrameNumberInInstance(frameIndex);
   }
 
-  virtual OrthancStone::CoordinateSystem3D GetFrameGeometry(size_t frameIndex) const ORTHANC_OVERRIDE
-  {
-    return frames_->GetFrameGeometry(frameIndex);
-  }
-
   virtual bool LookupFrame(size_t& frameIndex,
                            const std::string& sopInstanceUid,
                            unsigned int frameNumber) const ORTHANC_OVERRIDE
@@ -400,11 +398,6 @@
     return GetFrame(frameIndex).GetInformation().GetFrameNumber();
   }
 
-  virtual OrthancStone::CoordinateSystem3D GetFrameGeometry(size_t frameIndex) const ORTHANC_OVERRIDE
-  {
-    return GetFrame(frameIndex).GetParameters().GetFrameGeometry(GetFrameNumberInInstance(frameIndex));
-  }
-
   virtual bool LookupFrame(size_t& frameIndex,
                            const std::string& sopInstanceUid,
                            unsigned int frameNumber) const ORTHANC_OVERRIDE
@@ -431,7 +424,7 @@
 
     for (size_t i = 0; i < GetFramesCount(); i++)
     {
-      double distance = GetFrameGeometry(i).ComputeDistance(point);
+      double distance = GetFrameGeometry(*this, i).ComputeDistance(point);
       if (distance <= maximumDistance)
       {
         found = true;
@@ -2723,7 +2716,7 @@
       if (instance.GetSopInstanceUid() == loadedSopInstanceUid &&
           frameNumber == loadedFrameNumber)
       {
-        const OrthancStone::CoordinateSystem3D plane = frames_->GetFrameGeometry(cursorIndex);
+        const OrthancStone::CoordinateSystem3D plane = IFramesCollection::GetFrameGeometry(*frames_, cursorIndex);
         
         if (quality == DisplayedFrameQuality_Low)
         {
@@ -2882,7 +2875,6 @@
     }
   }
   
-
   ViewerViewport(OrthancStone::WebAssemblyLoadersContext& context,
                  const OrthancStone::DicomSource& source,
                  const std::string& canvas,
@@ -2977,14 +2969,12 @@
       {
         const size_t currentCursorIndex = that.cursor_->GetCurrentIndex();
 
-        const OrthancStone::CoordinateSystem3D current =
-          that.frames_->GetFrameGeometry(currentCursorIndex);
+        const OrthancStone::CoordinateSystem3D current = IFramesCollection::GetFrameGeometry(*that.frames_, currentCursorIndex);
       
         if (isShift &&
             previousCursorIndex != currentCursorIndex)
         {
-          const OrthancStone::CoordinateSystem3D previous =
-            that.frames_->GetFrameGeometry(previousCursorIndex);
+          const OrthancStone::CoordinateSystem3D previous = IFramesCollection::GetFrameGeometry(*that.frames_, previousCursorIndex);
           that.synchronizationOffset_ += previous.GetOrigin() - current.GetOrigin();
         }
 
@@ -3258,7 +3248,7 @@
       FramesCache::Accessor accessor(*framesCache_, instance.GetSopInstanceUid(), frameNumber);
       if (accessor.IsValid())
       {
-        RenderCurrentScene(accessor.GetImage(), instance, frameNumber, frames_->GetFrameGeometry(cursorIndex));
+        RenderCurrentScene(accessor.GetImage(), instance, frameNumber, IFramesCollection::GetFrameGeometry(*frames_, cursorIndex));
 
         DisplayedFrameQuality quality;
         
@@ -3369,7 +3359,7 @@
     if (cursor_.get() != NULL &&
         frames_.get() != NULL)
     {
-      plane = frames_->GetFrameGeometry(cursor_->GetCurrentIndex());      
+      plane = IFramesCollection::GetFrameGeometry(*frames_, cursor_->GetCurrentIndex());
       return true;
     }
     else
@@ -3869,8 +3859,7 @@
     {
       const size_t currentCursorIndex = cursor_->GetCurrentIndex();
 
-      const OrthancStone::CoordinateSystem3D current =
-        frames_->GetFrameGeometry(currentCursorIndex);
+      const OrthancStone::CoordinateSystem3D current = IFramesCollection::GetFrameGeometry(*frames_, currentCursorIndex);
       
       observer_->SignalSynchronizedBrowsing(
         *this, current.GetOrigin() + synchronizationOffset_, current.GetNormal());