# HG changeset patch # User Sebastien Jodogne # Date 1559059788 -7200 # Node ID 7608e8107aa1dba2bcc468f9d2184380f6afabda # Parent e8fdf29cd0ca8bf1858e12317638100a99578849# Parent 269522196741a7a948be658f11819a452dbe4308 merge diff -r 269522196741 -r 7608e8107aa1 Framework/Volumes/VolumeImageGeometry.cpp --- a/Framework/Volumes/VolumeImageGeometry.cpp Tue May 28 17:50:09 2019 +0200 +++ b/Framework/Volumes/VolumeImageGeometry.cpp Tue May 28 18:09:48 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 269522196741 -r 7608e8107aa1 Framework/Volumes/VolumeImageGeometry.h --- a/Framework/Volumes/VolumeImageGeometry.h Tue May 28 17:50:09 2019 +0200 +++ b/Framework/Volumes/VolumeImageGeometry.h Tue May 28 18:09:48 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 269522196741 -r 7608e8107aa1 UnitTestsSources/UnitTestsMain.cpp --- a/UnitTestsSources/UnitTestsMain.cpp Tue May 28 17:50:09 2019 +0200 +++ b/UnitTestsSources/UnitTestsMain.cpp Tue May 28 18:09:48 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); } } }