Mercurial > hg > orthanc-stone
comparison UnitTestsSources/GeometryToolboxTests.cpp @ 1766:ae18b5cfbd3e
VolumeImageGeometry::DetectProjection() reports if normal is opposite
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 11 May 2021 11:31:34 +0200 |
parents | 177f93c8371c |
children | 3889ae96d2e9 |
comparison
equal
deleted
inserted
replaced
1765:177f93c8371c | 1766:ae18b5cfbd3e |
---|---|
664 ASSERT_DOUBLE_EQ(-1.0 / 2.0 + 10.0 * 1.0, p[0]); | 664 ASSERT_DOUBLE_EQ(-1.0 / 2.0 + 10.0 * 1.0, p[0]); |
665 ASSERT_DOUBLE_EQ(-2.0 / 2.0 + 20.0 * 2.0, p[1]); | 665 ASSERT_DOUBLE_EQ(-2.0 / 2.0 + 20.0 * 2.0, p[1]); |
666 ASSERT_DOUBLE_EQ(-3.0 / 2.0 + 30.0 * 3.0, p[2]); | 666 ASSERT_DOUBLE_EQ(-3.0 / 2.0 + 30.0 * 3.0, p[2]); |
667 | 667 |
668 VolumeProjection proj; | 668 VolumeProjection proj; |
669 ASSERT_TRUE(g.DetectProjection(proj, g.GetAxialGeometry().GetNormal())); | 669 bool isOpposite; |
670 ASSERT_TRUE(g.DetectProjection(proj, isOpposite, g.GetAxialGeometry().GetNormal())); | |
670 ASSERT_EQ(VolumeProjection_Axial, proj); | 671 ASSERT_EQ(VolumeProjection_Axial, proj); |
671 ASSERT_TRUE(g.DetectProjection(proj, g.GetCoronalGeometry().GetNormal())); | 672 ASSERT_FALSE(isOpposite); |
673 ASSERT_TRUE(g.DetectProjection(proj, isOpposite, g.GetCoronalGeometry().GetNormal())); | |
672 ASSERT_EQ(VolumeProjection_Coronal, proj); | 674 ASSERT_EQ(VolumeProjection_Coronal, proj); |
673 ASSERT_TRUE(g.DetectProjection(proj, g.GetSagittalGeometry().GetNormal())); | 675 ASSERT_FALSE(isOpposite); |
676 ASSERT_TRUE(g.DetectProjection(proj, isOpposite, g.GetSagittalGeometry().GetNormal())); | |
674 ASSERT_EQ(VolumeProjection_Sagittal, proj); | 677 ASSERT_EQ(VolumeProjection_Sagittal, proj); |
678 ASSERT_FALSE(isOpposite); | |
675 | 679 |
676 ASSERT_EQ(10u, g.GetProjectionWidth(VolumeProjection_Axial)); | 680 ASSERT_EQ(10u, g.GetProjectionWidth(VolumeProjection_Axial)); |
677 ASSERT_EQ(20u, g.GetProjectionHeight(VolumeProjection_Axial)); | 681 ASSERT_EQ(20u, g.GetProjectionHeight(VolumeProjection_Axial)); |
678 ASSERT_EQ(30u, g.GetProjectionDepth(VolumeProjection_Axial)); | 682 ASSERT_EQ(30u, g.GetProjectionDepth(VolumeProjection_Axial)); |
679 ASSERT_EQ(10u, g.GetProjectionWidth(VolumeProjection_Coronal)); | 683 ASSERT_EQ(10u, g.GetProjectionWidth(VolumeProjection_Coronal)); |
1032 slices.Sort(); | 1036 slices.Sort(); |
1033 | 1037 |
1034 double spacingZ; | 1038 double spacingZ; |
1035 ASSERT_TRUE(slices.ComputeSpacingBetweenSlices(spacingZ)); | 1039 ASSERT_TRUE(slices.ComputeSpacingBetweenSlices(spacingZ)); |
1036 ASSERT_FLOAT_EQ(1, spacingZ); | 1040 ASSERT_FLOAT_EQ(1, spacingZ); |
1041 ASSERT_TRUE(slices.AreAllSlicesDistinct()); | |
1037 | 1042 |
1038 ASSERT_FLOAT_EQ(300.0, slices.GetSliceGeometry(0).GetOrigin() [0]); | 1043 ASSERT_FLOAT_EQ(300.0, slices.GetSliceGeometry(0).GetOrigin() [0]); |
1039 ASSERT_FLOAT_EQ(302.5, slices.GetSliceGeometry(0).GetOrigin() [1]); | 1044 ASSERT_FLOAT_EQ(302.5, slices.GetSliceGeometry(0).GetOrigin() [1]); |
1040 ASSERT_FLOAT_EQ(323.11, slices.GetSliceGeometry(0).GetOrigin() [2]); | 1045 ASSERT_FLOAT_EQ(323.11, slices.GetSliceGeometry(0).GetOrigin() [2]); |
1041 | 1046 |
1054 OrthancStone::VolumeImageGeometry geometry; | 1059 OrthancStone::VolumeImageGeometry geometry; |
1055 geometry.SetSizeInVoxels(width, height, depth); | 1060 geometry.SetSizeInVoxels(width, height, depth); |
1056 geometry.SetVoxelDimensions(spacingXY, spacingXY, 1); | 1061 geometry.SetVoxelDimensions(spacingXY, spacingXY, 1); |
1057 geometry.SetAxialGeometry(slices.GetSliceGeometry(0)); | 1062 geometry.SetAxialGeometry(slices.GetSliceGeometry(0)); |
1058 | 1063 |
1059 OrthancStone::Vector p, q; | 1064 OrthancStone::Vector q = geometry.GetCoordinates(0, 0, 0); |
1060 | 1065 ASSERT_EQ(3u, q.size()); |
1061 p = OrthancStone::LinearAlgebra::CreateVector(0, 0, 0, 1); | |
1062 q = OrthancStone::LinearAlgebra::Product(geometry.GetTransform(), p); | |
1063 ASSERT_FLOAT_EQ(300 + spacingXY / 2.0, q[0]); | 1066 ASSERT_FLOAT_EQ(300 + spacingXY / 2.0, q[0]); |
1064 ASSERT_FLOAT_EQ(302.5 + spacingXY / 2.0, q[1]); | 1067 ASSERT_FLOAT_EQ(302.5 + spacingXY / 2.0, q[1]); |
1065 ASSERT_FLOAT_EQ(323.11 - 0.5, q[2]); | 1068 ASSERT_FLOAT_EQ(323.11 - 0.5, q[2]); |
1066 ASSERT_FLOAT_EQ(1, q[3]); | 1069 |
1067 | 1070 q = geometry.GetCoordinates(1, 1, 1); |
1068 p = OrthancStone::LinearAlgebra::CreateVector(1, 1, 1, 1); | 1071 ASSERT_EQ(3u, q.size()); |
1069 q = OrthancStone::LinearAlgebra::Product(geometry.GetTransform(), p); | |
1070 ASSERT_FLOAT_EQ(300 - double(width) * spacingXY + spacingXY / 2.0, q[0]); | 1072 ASSERT_FLOAT_EQ(300 - double(width) * spacingXY + spacingXY / 2.0, q[0]); |
1071 ASSERT_FLOAT_EQ(302.5 - double(height) * spacingXY + spacingXY / 2.0, q[1]); | 1073 ASSERT_FLOAT_EQ(302.5 - double(height) * spacingXY + spacingXY / 2.0, q[1]); |
1072 ASSERT_FLOAT_EQ(323.11 + 368.0 - 0.5, q[2]); | 1074 ASSERT_FLOAT_EQ(323.11 + 368.0 - 0.5, q[2]); |
1073 ASSERT_FLOAT_EQ(1, q[3]); | 1075 |
1074 } | 1076 OrthancStone::VolumeProjection projection; |
1075 } | 1077 unsigned int slice; |
1078 ASSERT_TRUE(geometry.DetectSlice(projection, slice, OrthancStone::CoordinateSystem3D("300\\302.5\\690.11", "-1\\0\\0\\0\\-1\\0"))); | |
1079 ASSERT_EQ(OrthancStone::VolumeProjection_Axial, projection); | |
1080 ASSERT_EQ(367u, slice); | |
1081 ASSERT_TRUE(geometry.DetectSlice(projection, slice, OrthancStone::CoordinateSystem3D("300\\302.5\\323.11", "-1\\0\\0\\0\\-1\\0"))); | |
1082 ASSERT_EQ(OrthancStone::VolumeProjection_Axial, projection); | |
1083 ASSERT_EQ(0u, slice); | |
1084 | |
1085 // DOSE instance: RD1.2.752.243.1.1.20210202150624529.3790.85357_DoseTPS.dcm | |
1086 ASSERT_TRUE(geometry.DetectSlice(projection, slice, | |
1087 OrthancStone::CoordinateSystem3D("-217.0492\\-161.4141\\376.61", "1\\0\\0\\0\\1\\0"))); | |
1088 ASSERT_EQ(OrthancStone::VolumeProjection_Axial, projection); | |
1089 ASSERT_EQ(376u - 323u, slice); | |
1090 } | |
1091 } |