# HG changeset patch # User Sebastien Jodogne # Date 1559059766 -7200 # Node ID e8fdf29cd0ca8bf1858e12317638100a99578849 # Parent c237e0625065c22cc8f5c764faf7fda7054f5ce6 VolumeImageGeometry::GetProjectionSlice() diff -r c237e0625065 -r e8fdf29cd0ca Framework/Volumes/VolumeImageGeometry.cpp --- 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(depth) * plane.GetNormal() * dim[2]); + + return plane; + } } diff -r c237e0625065 -r e8fdf29cd0ca Framework/Volumes/VolumeImageGeometry.h --- 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; }; } diff -r c237e0625065 -r e8fdf29cd0ca UnitTestsSources/UnitTestsMain.cpp --- 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(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(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); } } }