changeset 1156:34ee7204fde3 broker

removing IGeometryProvider
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 16 Nov 2019 14:37:33 +0100
parents e265ed3f7843
children 9ad62b031c47
files Framework/Loaders/OrthancMultiframeVolumeLoader.h Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h Framework/Toolbox/SlicesSorter.cpp Framework/Toolbox/SlicesSorter.h Framework/Volumes/DicomVolumeImage.h
diffstat 6 files changed, 35 insertions(+), 36 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Loaders/OrthancMultiframeVolumeLoader.h	Sat Nov 16 11:26:13 2019 +0100
+++ b/Framework/Loaders/OrthancMultiframeVolumeLoader.h	Sat Nov 16 14:37:33 2019 +0100
@@ -30,8 +30,7 @@
 {
   class OrthancMultiframeVolumeLoader :
     public LoaderStateMachine,
-    public IObservable,
-    public IGeometryProvider
+    public IObservable
   {
   private:
     class LoadRTDoseGeometry;
@@ -57,8 +56,8 @@
 
     void SetUncompressedPixelData(const std::string& pixelData);
 
-    virtual bool HasGeometry() const ORTHANC_OVERRIDE;
-    virtual const VolumeImageGeometry& GetImageGeometry() const ORTHANC_OVERRIDE;
+    bool HasGeometry() const;
+    const VolumeImageGeometry& GetImageGeometry() const;
 
   public:
     OrthancMultiframeVolumeLoader(boost::shared_ptr<DicomVolumeImage> volume,
--- a/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp	Sat Nov 16 11:26:13 2019 +0100
+++ b/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.cpp	Sat Nov 16 14:37:33 2019 +0100
@@ -185,18 +185,27 @@
 
       CheckVolume();
 
-      const double spacingZ = slices.ComputeSpacingBetweenSlices();
-      LOG(INFO) << "Computed spacing between slices: " << spacingZ << "mm";
+      double spacingZ;
+
+      if (slices.ComputeSpacingBetweenSlices(spacingZ))
+      {
+        LOG(INFO) << "Computed spacing between slices: " << spacingZ << "mm";
       
-      const DicomInstanceParameters& parameters = *slices_[0];
+        const DicomInstanceParameters& parameters = *slices_[0];
 
-      geometry_.reset(new VolumeImageGeometry);
-      geometry_->SetSizeInVoxels(parameters.GetImageInformation().GetWidth(),
-                         parameters.GetImageInformation().GetHeight(),
-                         static_cast<unsigned int>(slices.GetSlicesCount()));
-      geometry_->SetAxialGeometry(slices.GetSliceGeometry(0));
-      geometry_->SetVoxelDimensions(parameters.GetPixelSpacingX(),
-                                    parameters.GetPixelSpacingY(), spacingZ);
+        geometry_.reset(new VolumeImageGeometry);
+        geometry_->SetSizeInVoxels(parameters.GetImageInformation().GetWidth(),
+                                   parameters.GetImageInformation().GetHeight(),
+                                   static_cast<unsigned int>(slices.GetSlicesCount()));
+        geometry_->SetAxialGeometry(slices.GetSliceGeometry(0));
+        geometry_->SetVoxelDimensions(parameters.GetPixelSpacingX(),
+                                      parameters.GetPixelSpacingY(), spacingZ);
+      }
+      else
+      {
+        throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry,
+                                        "The origins of the slices of a volume image are not regularly spaced");
+     }
     }
   }
 
--- a/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h	Sat Nov 16 11:26:13 2019 +0100
+++ b/Framework/Loaders/OrthancSeriesVolumeProgressiveLoader.h	Sat Nov 16 14:37:33 2019 +0100
@@ -44,8 +44,7 @@
   class OrthancSeriesVolumeProgressiveLoader : 
     public ObserverBase<OrthancSeriesVolumeProgressiveLoader>,
     public IObservable,
-    public IVolumeSlicer,
-    public IGeometryProvider
+    public IVolumeSlicer
   {
   private:
     static const unsigned int LOW_QUALITY = 0;
@@ -140,7 +139,7 @@
     subscribing, for instance if they are created or listening only AFTER the
     "geometry loaded" message is broadcast 
     */
-    bool HasGeometry() const ORTHANC_OVERRIDE
+    bool HasGeometry() const
     {
       return seriesGeometry_.HasGeometry();
     }
@@ -148,7 +147,7 @@
     /**
     Same remark as HasGeometry
     */
-    const VolumeImageGeometry& GetImageGeometry() const ORTHANC_OVERRIDE
+    const VolumeImageGeometry& GetImageGeometry() const
     {
       return seriesGeometry_.GetImageGeometry();
     }
--- a/Framework/Toolbox/SlicesSorter.cpp	Sat Nov 16 11:26:13 2019 +0100
+++ b/Framework/Toolbox/SlicesSorter.cpp	Sat Nov 16 14:37:33 2019 +0100
@@ -289,13 +289,14 @@
   }
 
 
-  double SlicesSorter::ComputeSpacingBetweenSlices() const
+  bool SlicesSorter::ComputeSpacingBetweenSlices(double& spacing /* out */) const
   {
     if (GetSlicesCount() <= 1)
     {
       // This is a volume that is empty or that contains one single
       // slice: Choose a dummy z-dimension for voxels
-      return 1.0;
+      spacing = 1.0;
+      return true;
     }
     
     const OrthancStone::CoordinateSystem3D& reference = GetSliceGeometry(0);
@@ -303,28 +304,27 @@
     double referencePosition = reference.ProjectAlongNormal(reference.GetOrigin());
         
     double p = reference.ProjectAlongNormal(GetSliceGeometry(1).GetOrigin());
-    double spacingZ = p - referencePosition;
+    spacing = p - referencePosition;
 
-    if (spacingZ <= 0)
+    if (spacing <= 0)
     {
-      LOG(ERROR) << "SlicesSorter::ComputeSpacingBetweenSlices(): (spacingZ <= 0)";
+      LOG(ERROR) << "SlicesSorter::ComputeSpacingBetweenSlices(): (spacing <= 0)";
       throw Orthanc::OrthancException(Orthanc::ErrorCode_BadSequenceOfCalls,
                                       "Please call the Sort() method before");
     }
 
     for (size_t i = 1; i < GetSlicesCount(); i++)
     {
-      OrthancStone::Vector p = reference.GetOrigin() + spacingZ * static_cast<double>(i) * reference.GetNormal();        
+      OrthancStone::Vector p = reference.GetOrigin() + spacing * static_cast<double>(i) * reference.GetNormal();
       double d = boost::numeric::ublas::norm_2(p - GetSliceGeometry(i).GetOrigin());
 
       if (!OrthancStone::LinearAlgebra::IsNear(d, 0, 0.001 /* tolerance expressed in mm */))
       {
-        throw Orthanc::OrthancException(Orthanc::ErrorCode_BadGeometry,
-                                        "The origins of the slices of a volume image are not regularly spaced");
+        return false;
       }
     }
 
-    return spacingZ;
+    return true;
   }
 
 
--- a/Framework/Toolbox/SlicesSorter.h	Sat Nov 16 11:26:13 2019 +0100
+++ b/Framework/Toolbox/SlicesSorter.h	Sat Nov 16 14:37:33 2019 +0100
@@ -91,7 +91,7 @@
                             const CoordinateSystem3D& slice) const;
 
     // WARNING - The slices must have been sorted before calling this method
-    double ComputeSpacingBetweenSlices() const;
+    bool ComputeSpacingBetweenSlices(double& spacing /* out */) const;
 
     // WARNING - The slices must have been sorted before calling this method
     bool AreAllSlicesDistinct() const;
--- a/Framework/Volumes/DicomVolumeImage.h	Sat Nov 16 11:26:13 2019 +0100
+++ b/Framework/Volumes/DicomVolumeImage.h	Sat Nov 16 14:37:33 2019 +0100
@@ -28,14 +28,6 @@
 
 namespace OrthancStone
 {
-  class IGeometryProvider
-  {
-  public:
-    virtual ~IGeometryProvider() {}
-    virtual bool HasGeometry() const = 0;
-    virtual const VolumeImageGeometry& GetImageGeometry() const = 0;
-  };
-
   /**
   This class combines a 3D image buffer, a 3D volume geometry and
   information about the DICOM parameters of the series.