MCPcopy Create free account
hub / github.com/MITK/MITK / IsSubGeometry

Method IsSubGeometry

Modules/Core/src/DataManagement/mitkBaseGeometry.cpp:1065–1181  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1063}
1064
1065bool mitk::IsSubGeometry(const mitk::BaseGeometry& testGeo,
1066 const mitk::BaseGeometry& referenceGeo,
1067 ScalarType coordinateEps,
1068 ScalarType directionEps,
1069 bool verbose)
1070{
1071 bool result = true;
1072
1073 // Compare spacings (must be equal)
1074 const auto testedSpacing = testGeo.GetSpacing();
1075 if (!mitk::Equal(testedSpacing, referenceGeo.GetSpacing(), coordinateEps))
1076 {
1077 if (verbose)
1078 {
1079 MITK_INFO << "[( Geometry3D )] Spacing differs.";
1080 MITK_INFO << "testedGeometry is " << setprecision(12) << testedSpacing << " : referenceGeometry is "
1081 << referenceGeo.GetSpacing() << " and tolerance is " << coordinateEps;
1082 }
1083 result = false;
1084 }
1085
1086 // Compare ImageGeometry Flag (must be equal)
1087 if (referenceGeo.GetImageGeometry() != testGeo.GetImageGeometry())
1088 {
1089 if (verbose)
1090 {
1091 MITK_INFO << "[( Geometry3D )] GetImageGeometry is different.";
1092 MITK_INFO << "referenceGeo is " << referenceGeo.GetImageGeometry() << " : testGeo is "
1093 << testGeo.GetImageGeometry();
1094 }
1095 result = false;
1096 }
1097
1098 // Compare IndexToWorldTransform Matrix (must be equal -> same axis directions)
1099 if (!Equal(*(testGeo.GetIndexToWorldTransform()), *(referenceGeo.GetIndexToWorldTransform()), directionEps, verbose))
1100 {
1101 result = false;
1102 }
1103
1104 //check if the geometry is within or equal to the bounds of reference geomentry.
1105 for (int i = 0; i<8; ++i)
1106 {
1107 auto testCorner = testGeo.GetCornerPoint(i);
1108 bool isInside = false;
1109 mitk::Point3D testCornerIndex;
1110 referenceGeo.WorldToIndex(testCorner, testCornerIndex);
1111
1112 std::bitset<sizeof(int)> bs(i);
1113 //To regard the coordinateEps, we subtract or add it to the index elements
1114 //depending on whether it was constructed by a lower or an upper bound value
1115 //(see implementation of BaseGeometry::GetCorner()).
1116 if (bs.test(0))
1117 {
1118 testCornerIndex[2] -= coordinateEps;
1119 }
1120 else
1121 {
1122 testCornerIndex[2] += coordinateEps;

Callers

nothing calls this directly

Calls 6

GetCornerPointMethod · 0.80
IsIndexInsideMethod · 0.80
EqualFunction · 0.50
GetSpacingMethod · 0.45
WorldToIndexMethod · 0.45

Tested by

no test coverage detected