diff OrthancServer/SliceOrdering.cpp @ 1842:697ae8d0e287

better handling of ordered-slices
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 30 Nov 2015 13:16:52 +0100
parents ec66a16aa398
children 1ba224001fd0
line wrap: on
line diff
--- a/OrthancServer/SliceOrdering.cpp	Mon Nov 30 12:05:55 2015 +0100
+++ b/OrthancServer/SliceOrdering.cpp	Mon Nov 30 13:16:52 2015 +0100
@@ -276,21 +276,24 @@
     PositionComparator comparator(normal_);
     std::sort(instances_.begin(), instances_.end(), comparator);
 
-    float a = instances_.front()->ComputeRelativePosition(normal_);
-    float b = instances_.back()->ComputeRelativePosition(normal_);
-
-    if (std::fabs(b - a) <= 10.0f * std::numeric_limits<float>::epsilon())
+    float a = instances_[0]->ComputeRelativePosition(normal_);
+    for (size_t i = 1; i < instances_.size(); i++)
     {
-      // Not enough difference between the minimum and maximum
-      // positions along the normal of the volume
-      return false;
+      float b = instances_[i]->ComputeRelativePosition(normal_);
+
+      if (std::fabs(b - a) <= 10.0f * std::numeric_limits<float>::epsilon())
+      {
+        // Not enough space between two slices along the normal of the volume
+        printf("Not enough space\n");
+        return false;
+      }
+
+      a = b;
     }
-    else
-    {
-      // This is a 3D volume
-      isVolume_ = true;
-      return true;
-    }
+
+    // This is a 3D volume
+    isVolume_ = true;
+    return true;
   }