26 #include <itkAffineGeometryFrame.h>
27 #include <itkBoundingBox.h>
29 #include <itkQuaternionRigidTransform.h>
30 #include <itkScalableAffineTransform.h>
32 #include <vtkMatrix4x4.h>
33 #include <vtkMatrixToLinearTransform.h>
42 class vtkMatrixToLinearTransform;
43 class vtkLinearTransform;
45 typedef itk::BoundingBox<unsigned long, 3, mitk::ScalarType>
BoundingBox;
55 DummyTestClass(
const DummyTestClass &other) :
BaseGeometry(other){};
65 newGeometry->UnRegister();
66 return newGeometry.GetPointer();
70 virtual void PrintSelf(std::ostream & , itk::Indent )
const override{};
84 CPPUNIT_TEST_SUITE(mitkBaseGeometryTestSuite);
97 MITK_TEST(TestSetIndexToWorldTransformWithoutChangingSpacing);
98 MITK_TEST(TestSetIndexToWorldTransform_WithPointerToSameTransform);
100 MITK_TEST(TestTransferItkToVtkTransform);
101 MITK_TEST(TestSetIndexToWorldTransformByVtkMatrix);
105 MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue);
106 MITK_TEST(Equal_DifferentOrigin_ReturnsFalse);
107 MITK_TEST(Equal_DifferentIndexToWorldTransform_ReturnsFalse);
108 MITK_TEST(Equal_DifferentSpacing_ReturnsFalse);
109 MITK_TEST(Equal_InputIsNull_ReturnsFalse);
110 MITK_TEST(Equal_DifferentBoundingBox_ReturnsFalse);
111 MITK_TEST(Equal_Transforms_MinorDifferences_And_Eps);
118 MITK_TEST(TestCalculateBoundingBoxRelToTransform);
130 CPPUNIT_TEST_SUITE_END();
135 float aFloatSpacing[3];
139 mitk::AffineTransform3D::MatrixType aMatrix;
147 mitk::AffineTransform3D::MatrixType anotherMatrix;
148 mitk::AffineTransform3D::MatrixType aThirdMatrix;
155 void setUp()
override
163 aTransform->SetIdentity();
165 aMatrix.SetIdentity();
169 anotherMatrix.SetIdentity();
170 anotherMatrix(1, 1) = 2;
171 anotherTransform->SetMatrix(anotherMatrix);
175 aThirdMatrix.SetIdentity();
176 aThirdMatrix(1, 1) = 7;
177 aThirdTransform->SetMatrix(aThirdMatrix);
180 float bounds[6] = {0, 1, 0, 1, 0, 1};
182 const float *input = bounds;
184 for (mitk::BoundingBox::BoundsArrayType::Iterator it = b.Begin(); j < 6; ++j)
191 BoundingBoxType::PointIdentifier pointid;
192 for (pointid = 0; pointid < 2; ++pointid)
195 for (i = 0; i < 3; ++i)
197 p[i] = bounds[2 * i + pointid];
199 pointscontainer->InsertElement(pointid, p);
202 aBoundingBox->SetPoints(pointscontainer);
203 aBoundingBox->ComputeBoundingBox();
209 pointscontainer->InsertElement(1, p);
210 anotherBoundingBox->SetPoints(pointscontainer);
211 anotherBoundingBox->ComputeBoundingBox();
217 pointscontainer->InsertElement(1, p);
218 aThirdBoundingBox->SetPoints(pointscontainer);
219 aThirdBoundingBox->ComputeBoundingBox();
225 aDummyGeometry->Initialize();
226 anotherDummyGeometry = aDummyGeometry->Clone();
229 void tearDown()
override
231 aDummyGeometry =
nullptr;
232 anotherDummyGeometry =
nullptr;
240 dummy->SetOrigin(anotherPoint);
241 CPPUNIT_ASSERT(
mitk::Equal(anotherPoint, dummy->GetOrigin()));
244 dummy->SetOrigin(aPoint);
249 void TestSetImageGeometry()
252 dummy->SetImageGeometry(
true);
253 CPPUNIT_ASSERT(dummy->GetImageGeometry());
256 dummy->SetImageGeometry(
false);
257 CPPUNIT_ASSERT(dummy->GetImageGeometry() ==
false);
262 void TestSetFloatBounds()
264 float bounds[6] = {0, 11, 0, 12, 0, 13};
266 dummy->SetFloatBounds(bounds);
271 dummy->SetFloatBounds(bounds);
276 float originalBounds[6] = {0, 1, 0, 1, 0, 1};
277 dummy->SetFloatBounds(originalBounds);
285 dummy->SetBounds(anotherBoundingBox->GetBounds());
289 dummy->SetBounds(aThirdBoundingBox->GetBounds());
294 dummy->SetBounds(aBoundingBox->GetBounds());
299 void TestSetFloatBoundsDouble()
301 double bounds[6] = {0, 11, 0, 12, 0, 13};
303 dummy->SetFloatBounds(bounds);
308 dummy->SetFloatBounds(bounds);
313 double originalBounds[6] = {0, 1, 0, 1, 0, 1};
314 dummy->SetFloatBounds(originalBounds);
319 void TestSetFrameOfReferenceID()
322 dummy->SetFrameOfReferenceID(5);
323 CPPUNIT_ASSERT(dummy->GetFrameOfReferenceID() == 5);
326 dummy->SetFrameOfReferenceID(0);
331 void TestSetIndexToWorldTransform()
334 dummy->SetIndexToWorldTransform(anotherTransform);
337 "Compare IndexToWorldTransform 1");
340 dummy->SetIndexToWorldTransform(aThirdTransform);
343 "Compare IndexToWorldTransform 2");
346 dummy->SetIndexToWorldTransform(aTransform);
351 void TestSetIndexToWorldTransformWithoutChangingSpacing()
354 dummy->SetIndexToWorldTransformWithoutChangingSpacing(anotherTransform);
359 mitk::AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
360 vnlmatrix = anotherTransform->GetMatrix().GetVnlMatrix();
363 col = vnlmatrix.get_column(0);
366 vnlmatrix.set_column(0, col);
367 col = vnlmatrix.get_column(1);
370 vnlmatrix.set_column(1, col);
371 col = vnlmatrix.get_column(2);
374 vnlmatrix.set_column(2, col);
378 anotherTransform->SetMatrix(matrix);
380 CPPUNIT_ASSERT(
mitk::Equal(anotherTransform, dummy->GetIndexToWorldTransform(),
mitk::eps,
true));
383 void TestSetIndexToWorldTransform_WithPointerToSameTransform()
387 dummy->SetOrigin(anotherPoint);
388 dummy->SetIndexToWorldTransform(anotherTransform);
389 dummy->SetSpacing(anotherSpacing);
393 mitk::Vector3D modifiedPoint = anotherPoint.GetVectorFromOrigin() * 2.;
395 testTransfrom->SetOffset(modifiedPoint);
397 dummy->SetIndexToWorldTransform(testTransfrom);
399 CPPUNIT_ASSERT(
mitk::Equal(modifiedPoint, dummy->GetOrigin().GetVectorFromOrigin()));
402 void TestSetIndexToWorldTransformByVtkMatrix()
404 vtkMatrix4x4 *vtkmatrix;
406 vtkmatrix->Identity();
407 vtkmatrix->SetElement(1, 1, 2);
409 dummy->SetIndexToWorldTransformByVtkMatrix(vtkmatrix);
412 "Compare IndexToWorldTransformByVtkMatrix 1");
415 vtkmatrix->SetElement(1, 1, 7);
416 dummy->SetIndexToWorldTransformByVtkMatrix(vtkmatrix);
419 "Compare IndexToWorldTransformByVtkMatrix 2");
422 vtkmatrix->SetElement(1, 1, 1);
423 dummy->SetIndexToWorldTransformByVtkMatrix(vtkmatrix);
426 MITK_ASSERT_EQUAL(dummy, newDummy,
"Compare IndexToWorldTransformByVtkMatrix 3");
429 void TestSetIdentity()
433 dummy->SetIndexToWorldTransform(anotherTransform);
434 dummy->SetOrigin(anotherPoint);
437 dummy->SetIdentity();
441 CPPUNIT_ASSERT(
mitk::Equal(aPoint, dummy->GetOrigin()));
442 CPPUNIT_ASSERT(
mitk::Equal(aSpacing, dummy->GetSpacing()));
449 void TestSetSpacing()
452 dummy->SetSpacing(anotherSpacing);
453 CPPUNIT_ASSERT(
mitk::Equal(anotherSpacing, dummy->GetSpacing()));
456 dummy->SetSpacing(aSpacing);
461 void TestTransferItkToVtkTransform()
464 dummy->SetIndexToWorldTransform(anotherTransform);
469 void TestConstructors()
473 bool test = dummy1->IsValid();
474 CPPUNIT_ASSERT(test ==
true);
475 CPPUNIT_ASSERT(dummy1->GetFrameOfReferenceID() == 0);
476 CPPUNIT_ASSERT(dummy1->GetIndexToWorldTransformLastModified() == 0);
478 CPPUNIT_ASSERT(
mitk::Equal(dummy1->GetSpacing(), aSpacing));
479 CPPUNIT_ASSERT(
mitk::Equal(dummy1->GetOrigin(), aPoint));
481 CPPUNIT_ASSERT(dummy1->GetImageGeometry() ==
false);
490 dummy2->SetOrigin(anotherPoint);
491 float bounds[6] = {0, 11, 0, 12, 0, 13};
492 dummy2->SetFloatBounds(bounds);
493 dummy2->SetIndexToWorldTransform(anotherTransform);
494 dummy2->SetSpacing(anotherSpacing);
502 void Equal_CloneAndOriginal_ReturnsTrue() {
MITK_ASSERT_EQUAL(aDummyGeometry, anotherDummyGeometry,
"Clone test"); }
503 void Equal_DifferentOrigin_ReturnsFalse()
505 anotherDummyGeometry->SetOrigin(anotherPoint);
510 void Equal_DifferentIndexToWorldTransform_ReturnsFalse()
512 anotherDummyGeometry->SetIndexToWorldTransform(anotherTransform);
517 void Equal_DifferentSpacing_ReturnsFalse()
519 anotherDummyGeometry->SetSpacing(anotherSpacing);
524 void Equal_InputIsNull_ReturnsFalse()
530 void Equal_DifferentBoundingBox_ReturnsFalse()
534 anotherDummyGeometry->SetBounds(bounds);
539 void Equal_Transforms_MinorDifferences_And_Eps()
543 aMatrix.SetIdentity();
544 anotherMatrix.SetIdentity();
546 aMatrix(0, 1) = 0.0002;
547 aTransform->SetMatrix(aMatrix);
548 anotherMatrix(0, 1) = 0.0002;
549 anotherTransform->SetMatrix(anotherMatrix);
550 anotherTransform->SetMatrix(aMatrix);
551 CPPUNIT_ASSERT_MESSAGE(
"Exact same transforms are mitk::Equal() for eps=mitk::eps",
553 CPPUNIT_ASSERT_MESSAGE(
"Exact same transforms are mitk::Equal() for eps=vnl_math::eps",
556 anotherMatrix(0, 1) = 0.0002 +
mitk::eps;
557 anotherTransform->SetMatrix(anotherMatrix);
558 CPPUNIT_ASSERT_MESSAGE(
"Transforms of diff mitk::eps are !mitk::Equal() for eps=vnl_math::eps",
560 CPPUNIT_ASSERT_MESSAGE(
"Transforms of diff mitk::eps are !mitk::Equal() for eps=mitk::eps-1%",
562 CPPUNIT_ASSERT_MESSAGE(
"Transforms of diff mitk::eps _are_ mitk::Equal() for eps=mitk::eps+1%",
566 void TestComposeTransform()
571 mitk::AffineTransform3D::MatrixType matrix1;
572 matrix1.SetIdentity();
574 transform1->SetMatrix(matrix1);
578 mitk::AffineTransform3D::MatrixType matrix2;
579 matrix2.SetIdentity();
581 transform2->SetMatrix(matrix2);
585 mitk::AffineTransform3D::MatrixType matrix3;
586 matrix3.SetIdentity();
588 transform3->SetMatrix(matrix3);
592 mitk::AffineTransform3D::MatrixType matrix4;
593 matrix4.SetIdentity();
594 matrix4(1, 1) = 0.25;
595 transform4->SetMatrix(matrix4);
599 expectedSpacing.Fill(1.0);
600 expectedSpacing[1] = 4;
603 dummy->SetIndexToWorldTransform(transform1);
604 dummy->Compose(transform2);
605 CPPUNIT_ASSERT(
mitk::Equal(dummy->GetSpacing(), expectedSpacing));
610 dummy->Compose(transform4);
615 void TestComposeVtkMatrix()
620 mitk::AffineTransform3D::MatrixType matrix1;
621 matrix1.SetIdentity();
623 transform1->SetMatrix(matrix1);
625 vtkMatrix4x4 *vtkmatrix2;
627 vtkmatrix2->Identity();
628 vtkmatrix2->SetElement(1, 1, 2);
632 mitk::AffineTransform3D::MatrixType matrix3;
633 matrix3.SetIdentity();
635 transform3->SetMatrix(matrix3);
637 vtkMatrix4x4 *vtkmatrix4;
639 vtkmatrix4->Identity();
640 vtkmatrix4->SetElement(1, 1, 0.25);
644 expectedSpacing.Fill(1.0);
645 expectedSpacing[1] = 4;
648 dummy->SetIndexToWorldTransform(transform1);
649 dummy->Compose(vtkmatrix2);
650 vtkmatrix2->Delete();
654 CPPUNIT_ASSERT(
mitk::Equal(dummy->GetSpacing(), expectedSpacing));
657 dummy->Compose(vtkmatrix4);
658 vtkmatrix4->Delete();
666 dummy->SetOrigin(anotherPoint);
667 CPPUNIT_ASSERT(
mitk::Equal(anotherPoint, dummy->GetOrigin()));
671 translationVector.SetElement(0, 17.5f);
672 translationVector.SetElement(1, -32.3f);
673 translationVector.SetElement(2, 4.0f);
677 dummy->Translate(translationVector);
678 CPPUNIT_ASSERT(
mitk::Equal(dummy->GetOrigin(), tmpResult));
681 translationVector *= -1;
682 dummy->Translate(translationVector);
683 CPPUNIT_ASSERT(
mitk::Equal(dummy->GetOrigin(), anotherPoint));
686 translationVector.SetElement(0, -1 * anotherPoint[0]);
687 translationVector.SetElement(1, -1 * anotherPoint[1]);
688 translationVector.SetElement(2, -1 * anotherPoint[2]);
689 dummy->Translate(translationVector);
703 dummyGeometry->WorldToIndex(origin, dummyPoint);
704 dummyGeometry->IndexToWorld(dummyPoint, dummyPoint);
712 dummyGeometry->WorldToIndex(origin, originContinuousIndex);
717 dummyGeometry->WorldToIndex(origin, itkindex);
723 mitk::Vector3D halfSpacingStep = dummyGeometry->GetSpacing() * 0.5;
726 dummyGeometry->WorldToIndex(originOffCenter, itkindex);
730 originOffCenter = origin + halfSpacingStep;
731 originOffCenter -= 0.0001;
732 dummyGeometry->WorldToIndex(originOffCenter, itkindex);
736 originOffCenter = origin + halfSpacingStep;
739 dummyGeometry->WorldToIndex(originOffCenter, itkindex);
745 dummyGeometry->WorldToIndex(center, centerContIndex);
748 CPPUNIT_ASSERT(
mitk::Equal(centerContIndex, centerBounds));
751 center = dummyGeometry->GetCenter();
753 dummyGeometry->IndexToWorld(centerBounds, centerBoundsInWorldCoords);
754 CPPUNIT_ASSERT(
mitk::Equal(center, centerBoundsInWorldCoords));
762 dummyGeometry->WorldToIndex(point, dummyPoint);
763 dummyGeometry->IndexToWorld(dummyPoint, dummyPoint);
776 origin = dummyGeometry->GetOrigin();
777 p[0] = xAxisMM[0] + origin[0];
778 p[1] = xAxisMM[1] + origin[1];
779 p[2] = xAxisMM[2] + origin[2];
781 dummyGeometry->WorldToIndex(p, pIndex);
783 dummyGeometry->WorldToIndex(xAxisMM, xAxisContinuousIndex);
784 CPPUNIT_ASSERT(
mitk::Equal(xAxisContinuousIndex[0], pIndex[0]));
785 CPPUNIT_ASSERT(
mitk::Equal(xAxisContinuousIndex[1], pIndex[1]));
786 CPPUNIT_ASSERT(
mitk::Equal(xAxisContinuousIndex[2], pIndex[2]));
788 dummyGeometry->IndexToWorld(xAxisContinuousIndex, xAxisContinuousIndex);
790 dummyGeometry->IndexToWorld(pIndex, p);
792 CPPUNIT_ASSERT(xAxisContinuousIndex == xAxisMM);
793 CPPUNIT_ASSERT(
mitk::Equal(xAxisContinuousIndex[0], p[0] - origin[0]));
794 CPPUNIT_ASSERT(
mitk::Equal(xAxisContinuousIndex[1], p[1] - origin[1]));
795 CPPUNIT_ASSERT(
mitk::Equal(xAxisContinuousIndex[2], p[2] - origin[2]));
802 p[0] = vector[0] + origin[0];
803 p[1] = vector[1] + origin[1];
804 p[2] = vector[2] + origin[2];
806 dummyGeometry->WorldToIndex(p, pIndex);
808 dummyGeometry->WorldToIndex(vector, vectorContinuousIndex);
809 CPPUNIT_ASSERT(
mitk::Equal(vectorContinuousIndex[0], pIndex[0]));
810 CPPUNIT_ASSERT(
mitk::Equal(vectorContinuousIndex[1], pIndex[1]));
811 CPPUNIT_ASSERT(
mitk::Equal(vectorContinuousIndex[2], pIndex[2]));
813 dummyGeometry->IndexToWorld(vectorContinuousIndex, vectorContinuousIndex);
815 dummyGeometry->IndexToWorld(pIndex, p);
817 CPPUNIT_ASSERT(vectorContinuousIndex == vector);
818 CPPUNIT_ASSERT(
mitk::Equal(vectorContinuousIndex[0], p[0] - origin[0]));
819 CPPUNIT_ASSERT(
mitk::Equal(vectorContinuousIndex[1], p[1] - origin[1]));
820 CPPUNIT_ASSERT(
mitk::Equal(vectorContinuousIndex[2], p[2] - origin[2]));
835 itkIndex4[0] = itkIndex4[1] = itkIndex4[2] = itkIndex4[3] = 4;
836 itkIndex3[0] = itkIndex3[1] = itkIndex3[2] = 6;
837 itkIndex2[0] = itkIndex2[1] = 2;
838 mitkIndex[0] = mitkIndex[1] = mitkIndex[2] = 13;
842 dummyGeometry->IndexToWorld(itkIndex2, point);
843 dummyGeometry->WorldToIndex(point, itkIndex2b);
845 CPPUNIT_ASSERT(((itkIndex2b[0] == itkIndex2[0]) && (itkIndex2b[1] == itkIndex2[1])));
848 dummyGeometry->IndexToWorld(itkIndex3, point);
849 dummyGeometry->WorldToIndex(point, itkIndex3b);
852 ((itkIndex3b[0] == itkIndex3[0]) && (itkIndex3b[1] == itkIndex3[1]) && (itkIndex3b[2] == itkIndex3[2])));
855 dummyGeometry->IndexToWorld(itkIndex4, point);
856 dummyGeometry->WorldToIndex(point, itkIndex4b);
858 CPPUNIT_ASSERT(((itkIndex4b[0] == itkIndex4[0]) && (itkIndex4b[1] == itkIndex4[1]) &&
859 (itkIndex4b[2] == itkIndex4[2]) && (itkIndex4b[3] == 0)));
862 dummyGeometry->IndexToWorld(mitkIndex, point);
863 dummyGeometry->WorldToIndex(point, mitkIndexb);
866 ((mitkIndexb[0] == mitkIndex[0]) && (mitkIndexb[1] == mitkIndex[1]) && (mitkIndexb[2] == mitkIndex[2])));
872 void TestIndexToWorld()
885 dummy->SetOrigin(anotherPoint);
890 dummy->SetIndexToWorldTransform(anotherTransform);
895 dummy->SetOrigin(anotherPoint);
900 dummy->SetSpacing(anotherSpacing);
906 void TestExecuteOperation()
915 dummy->ExecuteOperation(opN);
920 dummy->ExecuteOperation(opP);
921 CPPUNIT_ASSERT(
mitk::Equal(anotherPoint, dummy->GetOrigin()));
922 newDummy->SetOrigin(anotherPoint);
927 spacing[0] = anotherSpacing[0] - 1.;
928 spacing[1] = anotherSpacing[1] - 1.;
929 spacing[2] = anotherSpacing[2] - 1.;
932 dummy->ExecuteOperation(opS);
933 CPPUNIT_ASSERT(
mitk::Equal(anotherSpacing, dummy->GetSpacing()));
934 newDummy->SetSpacing(anotherSpacing);
938 dummy->SetIndexToWorldTransform(anotherTransform);
939 dummy->SetSpacing(anotherSpacing);
947 dummy->ExecuteOperation(opR);
953 dummy->WorldToIndex(voxelStep, voxelStepIndex);
955 expectedVoxelStepIndex.Fill(1);
956 CPPUNIT_ASSERT(
mitk::Equal(voxelStepIndex, expectedVoxelStepIndex));
964 void TestCalculateBoundingBoxRelToTransform()
967 dummy->SetExtentInMM(0, 15);
968 dummy->SetExtentInMM(1, 20);
969 dummy->SetExtentInMM(2, 8);
974 mitk::BoundingBox::PointIdentifier pointid = 0;
977 anotherTransform->GetInverse(inverse);
978 for (i = 0; i < 8; ++i)
979 pointscontainer->InsertElement(pointid++, inverse->TransformPoint(dummy->GetCornerPoint(i)));
981 result->SetPoints(pointscontainer);
982 result->ComputeBoundingBox();
988 newDummy->SetExtentInMM(0, 15);
989 newDummy->SetExtentInMM(1, 20);
990 newDummy->SetExtentInMM(2, 8);
1014 void TestIs2DConvertable()
1019 CPPUNIT_ASSERT(dummy->Is2DConvertable());
1022 dummy->SetSpacing(anotherSpacing);
1023 CPPUNIT_ASSERT(dummy->Is2DConvertable() ==
false);
1025 dummy->SetSpacing(aSpacing);
1026 CPPUNIT_ASSERT(dummy->Is2DConvertable());
1029 dummy->SetOrigin(anotherPoint);
1030 CPPUNIT_ASSERT(dummy->Is2DConvertable() ==
false);
1032 dummy->SetOrigin(aPoint);
1033 CPPUNIT_ASSERT(dummy->Is2DConvertable());
1037 mitk::AffineTransform3D::MatrixType dummyMatrix;
1038 dummyMatrix.SetIdentity();
1039 dummyTransform->SetMatrix(dummyMatrix);
1040 dummy->SetIndexToWorldTransform(dummyTransform);
1043 CPPUNIT_ASSERT(dummy->Is2DConvertable());
1045 dummyMatrix(0, 2) = 3;
1046 dummyTransform->SetMatrix(dummyMatrix);
1047 CPPUNIT_ASSERT(dummy->Is2DConvertable() ==
false);
1049 dummyMatrix.SetIdentity();
1050 dummyMatrix(1, 2) = 0.4;
1051 dummyTransform->SetMatrix(dummyMatrix);
1052 CPPUNIT_ASSERT(dummy->Is2DConvertable() ==
false);
1054 dummyMatrix.SetIdentity();
1055 dummyMatrix(2, 2) = 3;
1056 dummyTransform->SetMatrix(dummyMatrix);
1057 CPPUNIT_ASSERT(dummy->Is2DConvertable() ==
false);
1059 dummyMatrix.SetIdentity();
1060 dummyMatrix(2, 1) = 3;
1061 dummyTransform->SetMatrix(dummyMatrix);
1062 CPPUNIT_ASSERT(dummy->Is2DConvertable() ==
false);
1064 dummyMatrix.SetIdentity();
1065 dummyMatrix(2, 0) = 3;
1066 dummyTransform->SetMatrix(dummyMatrix);
1067 CPPUNIT_ASSERT(dummy->Is2DConvertable() ==
false);
1070 dummyMatrix.SetIdentity();
1071 dummyTransform->SetMatrix(dummyMatrix);
1076 void TestGetCornerPoint()
1079 dummy->SetIndexToWorldTransform(anotherTransform);
1080 double bounds[6] = {0, 11, 0, 12, 0, 13};
1081 dummy->SetFloatBounds(bounds);
1087 refCorner = anotherTransform->TransformPoint(refCorner);
1088 corner = dummy->GetCornerPoint(0);
1090 corner = dummy->GetCornerPoint(
true,
true,
true);
1095 refCorner = anotherTransform->TransformPoint(refCorner);
1096 corner = dummy->GetCornerPoint(1);
1098 corner = dummy->GetCornerPoint(
true,
true,
false);
1103 refCorner = anotherTransform->TransformPoint(refCorner);
1104 corner = dummy->GetCornerPoint(2);
1106 corner = dummy->GetCornerPoint(
true,
false,
true);
1111 refCorner = anotherTransform->TransformPoint(refCorner);
1112 corner = dummy->GetCornerPoint(3);
1114 corner = dummy->GetCornerPoint(
true,
false,
false);
1119 refCorner = anotherTransform->TransformPoint(refCorner);
1120 corner = dummy->GetCornerPoint(4);
1122 corner = dummy->GetCornerPoint(
false,
true,
true);
1127 refCorner = anotherTransform->TransformPoint(refCorner);
1128 corner = dummy->GetCornerPoint(5);
1130 corner = dummy->GetCornerPoint(
false,
true,
false);
1135 refCorner = anotherTransform->TransformPoint(refCorner);
1136 corner = dummy->GetCornerPoint(6);
1138 corner = dummy->GetCornerPoint(
false,
false,
true);
1143 refCorner = anotherTransform->TransformPoint(refCorner);
1144 corner = dummy->GetCornerPoint(7);
1146 corner = dummy->GetCornerPoint(
false,
false,
false);
1150 CPPUNIT_ASSERT_THROW(dummy->GetCornerPoint(20), itk::ExceptionObject);
1154 newDummy->SetIndexToWorldTransform(anotherTransform);
1155 newDummy->SetFloatBounds(bounds);
1159 void TestExtentInMM()
1162 dummy->SetExtentInMM(0, 50);
1163 CPPUNIT_ASSERT(
mitk::Equal(50., dummy->GetExtentInMM(0)));
1166 mitk::Equal(50., dummy->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(0).magnitude()));
1169 dummy->SetExtentInMM(0, 5);
1170 CPPUNIT_ASSERT(
mitk::Equal(5., dummy->GetExtentInMM(0)));
1172 mitk::Equal(5., dummy->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(0).magnitude()));
1174 dummy->SetExtentInMM(1, 4);
1175 CPPUNIT_ASSERT(
mitk::Equal(4., dummy->GetExtentInMM(1)));
1177 mitk::Equal(4., dummy->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(1).magnitude()));
1179 dummy->SetExtentInMM(2, 2.5);
1180 CPPUNIT_ASSERT(
mitk::Equal(2.5, dummy->GetExtentInMM(2)));
1182 mitk::Equal(2.5, dummy->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2).magnitude()));
1185 void TestGetAxisVector()
1188 dummy->SetIndexToWorldTransform(anotherTransform);
1189 double bounds[6] = {0, 11, 0, 12, 0, 13};
1190 dummy->SetFloatBounds(bounds);
1194 dummy->IndexToWorld(vector, vector);
1195 CPPUNIT_ASSERT(
mitk::Equal(dummy->GetAxisVector(0), vector));
1198 dummy->IndexToWorld(vector, vector);
1199 CPPUNIT_ASSERT(
mitk::Equal(dummy->GetAxisVector(1), vector));
1202 dummy->IndexToWorld(vector, vector);
1203 CPPUNIT_ASSERT(
mitk::Equal(dummy->GetAxisVector(2), vector));
1206 void TestGetCenter()
1209 dummy->SetIndexToWorldTransform(anotherTransform);
1210 double bounds[6] = {0, 11, 2, 12, 1, 13};
1211 dummy->SetFloatBounds(bounds);
1214 for (
int i = 0; i < 3; i++)
1215 refCenter.SetElement(i, (bounds[2 * i] + bounds[2 * i + 1]) / 2.0);
1217 dummy->IndexToWorld(refCenter, refCenter);
1219 CPPUNIT_ASSERT(
mitk::Equal(dummy->GetCenter(), refCenter));
1222 void TestGetDiagonalLength()
1225 double bounds[6] = {1, 3, 5, 8, 7.5, 11.5};
1226 dummy->SetFloatBounds(bounds);
1228 double expectedLength = sqrt(29.);
1235 newDummy->SetFloatBounds(bounds);
1239 void TestGetExtent()
1242 double bounds[6] = {1, 3, 5, 8, 7.5, 11.5};
1243 dummy->SetFloatBounds(bounds);
1245 CPPUNIT_ASSERT(
mitk::Equal(2., dummy->GetExtent(0)));
1246 CPPUNIT_ASSERT(
mitk::Equal(3., dummy->GetExtent(1)));
1247 CPPUNIT_ASSERT(
mitk::Equal(4., dummy->GetExtent(2)));
1251 newDummy->SetFloatBounds(bounds);
1258 double bounds[6] = {1, 3, 5, 8, 7.5, 11.5};
1259 dummy->SetFloatBounds(bounds);
1267 CPPUNIT_ASSERT(dummy->IsIndexInside(insidePoint));
1268 CPPUNIT_ASSERT(
false == dummy->IsIndexInside(outsidePoint));
1270 dummy->IndexToWorld(insidePoint, insidePoint);
1271 dummy->IndexToWorld(outsidePoint, outsidePoint);
1273 CPPUNIT_ASSERT(dummy->IsInside(insidePoint));
1274 CPPUNIT_ASSERT(
false == dummy->IsInside(outsidePoint));
1278 newDummy->SetFloatBounds(bounds);
1282 void TestInitialize()
1288 dummy2->SetOrigin(anotherPoint);
1289 dummy2->SetBounds(anotherBoundingBox->GetBounds());
1294 dummy2->SetIndexToWorldTransform(anotherTransform);
1295 dummy2->SetSpacing(anotherSpacing);
1297 dummy1->InitializeGeometry(dummy2);
1301 dummy1->Initialize();
1307 void TestGetMatrixColumn()
1310 dummy->SetIndexToWorldTransform(anotherTransform);
1313 testVector.SetVnlVector(dummy->GetMatrixColumn(0));
1315 CPPUNIT_ASSERT(testVector == refVector);
1317 testVector.SetVnlVector(dummy->GetMatrixColumn(1));
1319 CPPUNIT_ASSERT(testVector == refVector);
1321 testVector.SetVnlVector(dummy->GetMatrixColumn(2));
1323 CPPUNIT_ASSERT(testVector == refVector);
1327 newDummy->SetIndexToWorldTransform(anotherTransform);
bool EqualArray(TArrayType1 &arrayType1, TArrayType2 &arrayType2, int size, ScalarType eps=mitk::eps, bool verbose=false)
itk::SmartPointer< Self > Pointer
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
void GetRotation(const mitk::BaseGeometry *geometry, TMatrixType &itkmatrix)
#define mitkNewMacro1Param(classname, type)
bool MatrixEqualElementWise(const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix1, const vnl_matrix_fixed< TCoordRep, NRows, NCols > &matrix2, mitk::ScalarType epsilon=mitk::eps)
Check for element-wise matrix equality with a user defined accuracy.
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const override
Base class of all Operation-classes.
vnl_vector< ScalarType > VnlVector
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
Constants for most interaction classes, due to the generic StateMachines.
int testIndexAndWorldConsistencyForVectors(mitk::Geometry3D *geometry3d)
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
itk::SmartPointer< Self > Pointer
itk::SmartPointer< const Self > ConstPointer
#define MITK_ASSERT_NOT_EQUAL(OBJ1, OBJ2, MSG)
Testing macro to test if two objects are not equal.
virtual void PreSetSpacing(const mitk::Vector3D &)
PreSetSpacing.
virtual itk::LightObject::Pointer InternalClone() const override=0
clones the geometry
An object of this class represents an exception of MITK. Please don't instantiate exceptions manually...
#define mitkClassMacro(className, SuperClassName)
itk::BoundingBox< unsigned long, 3, mitk::ScalarType > BoundingBoxType
Test fixture for parameterized tests.
Operation that handles all actions on one Point.
#define MITK_ASSERT_EQUAL(EXPECTED, ACTUAL, MSG)
Testing macro to test if two objects are equal.
void vtk2itk(const Tin &in, Tout &out)
int testIndexAndWorldConsistencyForIndex(mitk::Geometry3D *geometry3d)
MITKNEWMODULE_EXPORT bool Equal(mitk::ExampleDataStructure *leftHandSide, mitk::ExampleDataStructure *rightHandSide, mitk::ScalarType eps, bool verbose)
Returns true if the example data structures are considered equal.
The ScaleOperation is an operation to scale any mitk::BaseGeometry.
itk::BoundingBox< unsigned long, 3, mitk::ScalarType > BoundingBox
MITKCORE_EXPORT const ScalarType eps
int testIndexAndWorldConsistency(mitk::Geometry3D *geometry3d)
Operation, that holds everything necessary for an rotation operation on mitk::BaseData.
BoundingBoxType::Pointer BoundingBoxPointer
BaseGeometry Describes the geometry of a data object.
BoundingBoxType::BoundsArrayType BoundsArrayType
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.