changeset 809:e8fdf29cd0ca

VolumeImageGeometry::GetProjectionSlice()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 28 May 2019 18:09:26 +0200
parents c237e0625065
children 7608e8107aa1
files Framework/Volumes/VolumeImageGeometry.cpp Framework/Volumes/VolumeImageGeometry.h UnitTestsSources/UnitTestsMain.cpp
diffstat 3 files changed, 29 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/Framework/Volumes/VolumeImageGeometry.cpp	Tue May 28 17:44:53 2019 +0200
+++ b/Framework/Volumes/VolumeImageGeometry.cpp	Tue May 28 18:09:26 2019 +0200
@@ -306,4 +306,21 @@
       return true;
     }
   }
+
+
+  CoordinateSystem3D VolumeImageGeometry::GetProjectionSlice(VolumeProjection projection,
+                                                             unsigned int depth) const
+  {
+    if (depth >= GetProjectionDepth(projection))
+    {
+      throw Orthanc::OrthancException(Orthanc::ErrorCode_ParameterOutOfRange);
+    }
+
+    Vector dim = GetVoxelDimensions(projection);
+    CoordinateSystem3D plane = GetProjectionGeometry(projection);
+
+    plane.SetOrigin(plane.GetOrigin() + static_cast<double>(depth) * plane.GetNormal() * dim[2]);
+
+    return plane;
+  }
 }
--- a/Framework/Volumes/VolumeImageGeometry.h	Tue May 28 17:44:53 2019 +0200
+++ b/Framework/Volumes/VolumeImageGeometry.h	Tue May 28 18:09:26 2019 +0200
@@ -127,5 +127,8 @@
     bool DetectSlice(VolumeProjection& projection,
                      unsigned int& slice,
                      const CoordinateSystem3D& plane) const;
+
+    CoordinateSystem3D GetProjectionSlice(VolumeProjection projection,
+                                          unsigned int depth) const;
   };
 }
--- a/UnitTestsSources/UnitTestsMain.cpp	Tue May 28 17:44:53 2019 +0200
+++ b/UnitTestsSources/UnitTestsMain.cpp	Tue May 28 18:09:26 2019 +0200
@@ -699,18 +699,22 @@
     OrthancStone::VolumeProjection projection = (OrthancStone::VolumeProjection) p;
     const OrthancStone::CoordinateSystem3D& s = g.GetProjectionGeometry(projection);
     
+    ASSERT_THROW(g.GetProjectionSlice(projection, g.GetProjectionDepth(projection)), Orthanc::OrthancException);
+
     for (unsigned int i = 0; i < g.GetProjectionDepth(projection); i++)
     {
-      OrthancStone::CoordinateSystem3D plane(
-        s.GetOrigin() + static_cast<double>(i) * s.GetNormal() * g.GetVoxelDimensions(projection)[2],
-        s.GetAxisX(),
-        s.GetAxisY());
+      OrthancStone::CoordinateSystem3D plane = g.GetProjectionSlice(projection, i);
+
+      ASSERT_TRUE(IsEqualVector(plane.GetOrigin(), s.GetOrigin() + static_cast<double>(i) * 
+                                s.GetNormal() * g.GetVoxelDimensions(projection)[2]));
+      ASSERT_TRUE(IsEqualVector(plane.GetAxisX(), s.GetAxisX()));
+      ASSERT_TRUE(IsEqualVector(plane.GetAxisY(), s.GetAxisY()));
 
       unsigned int slice;
       OrthancStone::VolumeProjection q;
       ASSERT_TRUE(g.DetectSlice(q, slice, plane));
       ASSERT_EQ(projection, q);
-      ASSERT_EQ(i, slice);
+      ASSERT_EQ(i, slice);     
     }
   }
 }