diff Framework/Volumes/VolumeImageGeometry.cpp @ 1170:1644de437a7b broker

fixes related to swapped normal in sagittal geometry
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 20 Nov 2019 13:09:15 +0100
parents 19b1c8caade4
children 0ca50d275b9a
line wrap: on
line diff
--- a/Framework/Volumes/VolumeImageGeometry.cpp	Wed Nov 20 10:55:44 2019 +0100
+++ b/Framework/Volumes/VolumeImageGeometry.cpp	Wed Nov 20 13:09:15 2019 +0100
@@ -296,16 +296,18 @@
     {
       return false;
     }
-        
-    unsigned int d = static_cast<unsigned int>(std::floor(z));
-    if (d >= projectionDepth)
-    {
-      return false;
-    }
     else
     {
-      slice = d;
-      return true;
+      unsigned int d = static_cast<unsigned int>(std::floor(z));
+      if (d >= projectionDepth)
+      {
+        return false;
+      }
+      else
+      {
+        slice = d;
+        return true;
+      }
     }
   }
 
@@ -321,7 +323,18 @@
     Vector dim = GetVoxelDimensions(projection);
     CoordinateSystem3D plane = GetProjectionGeometry(projection);
 
-    plane.SetOrigin(plane.GetOrigin() + static_cast<double>(z) * plane.GetNormal() * dim[2]);
+    Vector normal = plane.GetNormal();
+    if (projection == VolumeProjection_Sagittal)
+    {
+      /**
+       * WARNING: In sagittal geometry, the normal points to REDUCING
+       * X-axis in the 3D world. This is necessary to keep the
+       * right-hand coordinate system. Hence the negation.
+       **/
+      normal = -normal;
+    }
+    
+    plane.SetOrigin(plane.GetOrigin() + static_cast<double>(z) * dim[2] * normal);
 
     return plane;
   }