Medical Imaging Interaction Toolkit  2018.4.99-f51274ea
Medical Imaging Interaction Toolkit
mitkBaseGeometryTest.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 #include "mitkTestingMacros.h"
14 #include <mitkTestFixture.h>
15 #include <mitkTestingConfig.h>
16 
17 #include <MitkCoreExports.h>
18 #include <mitkBaseGeometry.h>
19 #include <mitkCommon.h>
20 #include <mitkOperationActor.h>
21 
22 #include <itkAffineGeometryFrame.h>
23 #include <itkBoundingBox.h>
24 #include <itkIndex.h>
25 #include <itkQuaternionRigidTransform.h>
26 #include <itkScalableAffineTransform.h>
27 #include <mitkVector.h>
28 #include <vtkMatrix4x4.h>
29 #include <vtkMatrixToLinearTransform.h>
30 
31 #include <mitkImageCast.h>
32 #include <mitkInteractionConst.h>
33 #include <mitkMatrixConvert.h>
34 #include <mitkRotationOperation.h>
35 #include <mitkScaleOperation.h>
36 
37 class vtkMatrix4x4;
38 class vtkMatrixToLinearTransform;
39 class vtkLinearTransform;
40 
41 typedef itk::BoundingBox<unsigned long, 3, mitk::ScalarType> BoundingBox;
42 typedef itk::BoundingBox<unsigned long, 3, mitk::ScalarType> BoundingBoxType;
44 typedef BoundingBoxType::Pointer BoundingBoxPointer;
45 
46 // Dummy instance of abstract base class
47 class DummyTestClass : public mitk::BaseGeometry
48 {
49 public:
50  DummyTestClass(){};
51  DummyTestClass(const DummyTestClass &other) : BaseGeometry(other){};
52  ~DummyTestClass() override{};
53 
54  mitkClassMacro(DummyTestClass, mitk::BaseGeometry);
55  itkNewMacro(Self);
56  mitkNewMacro1Param(Self, const Self &);
57 
58  itk::LightObject::Pointer InternalClone() const override
59  {
60  Self::Pointer newGeometry = new Self(*this);
61  newGeometry->UnRegister();
62  return newGeometry.GetPointer();
63  }
64 
65 protected:
66  void PrintSelf(std::ostream & /*os*/, itk::Indent /*indent*/) const override{};
67  //##Documentation
68  //## @brief Pre- and Post-functions are empty in BaseGeometry
69  //##
70  //## These virtual functions allow for a different beahiour in subclasses.
71  //## Do implement them in every subclass of BaseGeometry. If not needed, use {}.
72  //## If this class is inherited from a subclass of BaseGeometry, call {Superclass::Pre...();};, example:
73  // SlicedGeometry3D class
74  void PreSetSpacing(const mitk::Vector3D &/*aSpacing*/) override{};
75 };
76 
77 class mitkBaseGeometryTestSuite : public mitk::TestFixture
78 {
79  // List of Tests
80  CPPUNIT_TEST_SUITE(mitkBaseGeometryTestSuite);
81 
82  // Constructor
83  MITK_TEST(TestConstructors);
84  MITK_TEST(TestInitialize);
85 
86  // Set
87  MITK_TEST(TestSetOrigin);
88  MITK_TEST(TestSetBounds);
89  MITK_TEST(TestSetFloatBounds);
90  MITK_TEST(TestSetFloatBoundsDouble);
91  MITK_TEST(TestSetFrameOfReferenceID);
92  MITK_TEST(TestSetIndexToWorldTransform);
93  MITK_TEST(TestSetIndexToWorldTransformWithoutChangingSpacing);
94  MITK_TEST(TestSetIndexToWorldTransform_WithPointerToSameTransform);
95  MITK_TEST(TestSetSpacing);
96  MITK_TEST(TestTransferItkToVtkTransform);
97  MITK_TEST(TestSetIndexToWorldTransformByVtkMatrix);
98  MITK_TEST(TestSetIdentity);
99  MITK_TEST(TestSetImageGeometry);
100  // Equal
101  MITK_TEST(Equal_CloneAndOriginal_ReturnsTrue);
102  MITK_TEST(Equal_DifferentOrigin_ReturnsFalse);
103  MITK_TEST(Equal_DifferentIndexToWorldTransform_ReturnsFalse);
104  MITK_TEST(Equal_DifferentSpacing_ReturnsFalse);
105  MITK_TEST(Equal_InputIsNull_ReturnsFalse);
106  MITK_TEST(Equal_DifferentBoundingBox_ReturnsFalse);
107  MITK_TEST(Equal_Transforms_MinorDifferences_And_Eps);
108  // other Functions
109  MITK_TEST(TestComposeTransform);
110  MITK_TEST(TestComposeVtkMatrix);
111  MITK_TEST(TestTranslate);
112  MITK_TEST(TestIndexToWorld);
113  MITK_TEST(TestExecuteOperation);
114  MITK_TEST(TestCalculateBoundingBoxRelToTransform);
115  // MITK_TEST(TestSetTimeBounds);
116  MITK_TEST(TestIs2DConvertable);
117  MITK_TEST(TestGetCornerPoint);
118  MITK_TEST(TestExtentInMM);
119  MITK_TEST(TestGetAxisVector);
120  MITK_TEST(TestGetCenter);
121  MITK_TEST(TestGetDiagonalLength);
122  MITK_TEST(TestGetExtent);
123  MITK_TEST(TestIsInside);
124  MITK_TEST(TestGetMatrixColumn);
125  // test IsSubGeometry
126  MITK_TEST(IsSubGeometry_Spacing);
127  MITK_TEST(IsSubGeometry_TransformMatrix);
128  MITK_TEST(IsSubGeometry_Bounds);
129  MITK_TEST(IsSubGeometry_Grid);
130 
131  CPPUNIT_TEST_SUITE_END();
132 
133  // Used Variables
134 private:
135  mitk::Point3D aPoint;
136  float aFloatSpacing[3];
137  mitk::Vector3D aSpacing;
138  mitk::AffineTransform3D::Pointer aTransform;
139  BoundingBoxPointer aBoundingBox;
140  mitk::AffineTransform3D::MatrixType aMatrix;
141 
142  mitk::Point3D anotherPoint;
143  mitk::Vector3D anotherSpacing;
144  BoundingBoxPointer anotherBoundingBox;
145  BoundingBoxPointer aThirdBoundingBox;
146  mitk::AffineTransform3D::Pointer anotherTransform;
147  mitk::AffineTransform3D::Pointer aThirdTransform;
148  mitk::AffineTransform3D::MatrixType anotherMatrix;
149  mitk::AffineTransform3D::MatrixType aThirdMatrix;
150 
151  DummyTestClass::Pointer aDummyGeometry;
152  DummyTestClass::Pointer anotherDummyGeometry;
153 
154 public:
155  // Set up for variables
156  void setUp() override
157  {
158  mitk::FillVector3D(aFloatSpacing, 1, 1, 1);
159  mitk::FillVector3D(aSpacing, 1, 1, 1);
160  mitk::FillVector3D(aPoint, 0, 0, 0);
161 
162  // Transform
163  aTransform = mitk::AffineTransform3D::New();
164  aTransform->SetIdentity();
165 
166  aMatrix.SetIdentity();
167 
168  anotherTransform = mitk::AffineTransform3D::New();
169 
170  anotherMatrix.SetIdentity();
171  anotherMatrix(1, 1) = 2;
172  anotherTransform->SetMatrix(anotherMatrix);
173 
174  aThirdTransform = mitk::AffineTransform3D::New();
175 
176  aThirdMatrix.SetIdentity();
177  aThirdMatrix(1, 1) = 7;
178  aThirdTransform->SetMatrix(aThirdMatrix);
179 
180  // Bounding Box
181  float bounds[6] = {0, 1, 0, 1, 0, 1};
183  const float *input = bounds;
184  int j = 0;
185  for (mitk::BoundingBox::BoundsArrayType::Iterator it = b.Begin(); j < 6; ++j)
186  *it++ = (mitk::ScalarType)*input++;
187 
188  aBoundingBox = BoundingBoxType::New();
189 
190  BoundingBoxType::PointsContainer::Pointer pointscontainer = BoundingBoxType::PointsContainer::New();
191  BoundingBoxType::PointType p;
192  BoundingBoxType::PointIdentifier pointid;
193  for (pointid = 0; pointid < 2; ++pointid)
194  {
195  unsigned int i;
196  for (i = 0; i < 3; ++i)
197  {
198  p[i] = bounds[2 * i + pointid];
199  }
200  pointscontainer->InsertElement(pointid, p);
201  }
202 
203  aBoundingBox->SetPoints(pointscontainer);
204  aBoundingBox->ComputeBoundingBox();
205 
206  anotherBoundingBox = BoundingBoxType::New();
207  p[0] = 11;
208  p[1] = 12;
209  p[2] = 13;
210  pointscontainer->InsertElement(1, p);
211  anotherBoundingBox->SetPoints(pointscontainer);
212  anotherBoundingBox->ComputeBoundingBox();
213 
214  aThirdBoundingBox = BoundingBoxType::New();
215  p[0] = 22;
216  p[1] = 23;
217  p[2] = 24;
218  pointscontainer->InsertElement(1, p);
219  aThirdBoundingBox->SetPoints(pointscontainer);
220  aThirdBoundingBox->ComputeBoundingBox();
221 
222  mitk::FillVector3D(anotherPoint, 2, 3, 4);
223  mitk::FillVector3D(anotherSpacing, 5, 6.5, 7);
224 
225  aDummyGeometry = DummyTestClass::New();
226  aDummyGeometry->Initialize();
227  anotherDummyGeometry = aDummyGeometry->Clone();
228  }
229 
230  void tearDown() override
231  {
232  aDummyGeometry = nullptr;
233  anotherDummyGeometry = nullptr;
234  }
235 
236  // Test functions
237 
238  void TestSetOrigin()
239  {
240  DummyTestClass::Pointer dummy = DummyTestClass::New();
241  dummy->SetOrigin(anotherPoint);
242  CPPUNIT_ASSERT(mitk::Equal(anotherPoint, dummy->GetOrigin()));
243 
244  // undo changes, new and changed object need to be the same!
245  dummy->SetOrigin(aPoint);
246  DummyTestClass::Pointer newDummy = DummyTestClass::New();
247  MITK_ASSERT_EQUAL(dummy, newDummy, "TestSetOrigin");
248  }
249 
250  void TestSetImageGeometry()
251  {
252  DummyTestClass::Pointer dummy = DummyTestClass::New();
253  dummy->SetImageGeometry(true);
254  CPPUNIT_ASSERT(dummy->GetImageGeometry());
255 
256  // undo changes, new and changed object need to be the same!
257  dummy->SetImageGeometry(false);
258  CPPUNIT_ASSERT(dummy->GetImageGeometry() == false);
259  DummyTestClass::Pointer newDummy = DummyTestClass::New();
260  MITK_ASSERT_EQUAL(dummy, newDummy, "TestSetImageGeometry");
261  }
262 
263  void TestSetFloatBounds()
264  {
265  float bounds[6] = {0, 11, 0, 12, 0, 13};
266  DummyTestClass::Pointer dummy = DummyTestClass::New();
267  dummy->SetFloatBounds(bounds);
268  MITK_ASSERT_EQUAL(BoundingBox::ConstPointer(dummy->GetBoundingBox()), anotherBoundingBox, "BoundingBox equality");
269 
270  // Wrong bounds, test needs to fail
271  bounds[1] = 7;
272  dummy->SetFloatBounds(bounds);
274  BoundingBox::ConstPointer(dummy->GetBoundingBox()), anotherBoundingBox, "BoundingBox not equal");
275 
276  // undo changes, new and changed object need to be the same!
277  float originalBounds[6] = {0, 1, 0, 1, 0, 1};
278  dummy->SetFloatBounds(originalBounds);
279  DummyTestClass::Pointer newDummy = DummyTestClass::New();
280  MITK_ASSERT_EQUAL(dummy, newDummy, "Undo and equal");
281  }
282 
283  void TestSetBounds()
284  {
285  DummyTestClass::Pointer dummy = DummyTestClass::New();
286  dummy->SetBounds(anotherBoundingBox->GetBounds());
287  MITK_ASSERT_EQUAL(BoundingBox::ConstPointer(dummy->GetBoundingBox()), anotherBoundingBox, "Setting bounds");
288 
289  // Test needs to fail now
290  dummy->SetBounds(aThirdBoundingBox->GetBounds());
292  BoundingBox::ConstPointer(dummy->GetBoundingBox()), anotherBoundingBox, "Setting unequal bounds");
293 
294  // undo changes, new and changed object need to be the same!
295  dummy->SetBounds(aBoundingBox->GetBounds());
296  DummyTestClass::Pointer newDummy = DummyTestClass::New();
297  MITK_ASSERT_EQUAL(dummy, newDummy, "Undo set bounds");
298  }
299 
300  void TestSetFloatBoundsDouble()
301  {
302  double bounds[6] = {0, 11, 0, 12, 0, 13};
303  DummyTestClass::Pointer dummy = DummyTestClass::New();
304  dummy->SetFloatBounds(bounds);
305  MITK_ASSERT_EQUAL(BoundingBox::ConstPointer(dummy->GetBoundingBox()), anotherBoundingBox, "Float bounds");
306 
307  // Test needs to fail now
308  bounds[3] = 7;
309  dummy->SetFloatBounds(bounds);
311  BoundingBox::ConstPointer(dummy->GetBoundingBox()), anotherBoundingBox, "Float bounds unequal");
312 
313  // undo changes, new and changed object need to be the same!
314  double originalBounds[6] = {0, 1, 0, 1, 0, 1};
315  dummy->SetFloatBounds(originalBounds);
316  DummyTestClass::Pointer newDummy = DummyTestClass::New();
317  MITK_ASSERT_EQUAL(dummy, newDummy, "Undo set float bounds");
318  }
319 
320  void TestSetFrameOfReferenceID()
321  {
322  DummyTestClass::Pointer dummy = DummyTestClass::New();
323  dummy->SetFrameOfReferenceID(5);
324  CPPUNIT_ASSERT(dummy->GetFrameOfReferenceID() == 5);
325 
326  // undo changes, new and changed object need to be the same!
327  dummy->SetFrameOfReferenceID(0);
328  DummyTestClass::Pointer newDummy = DummyTestClass::New();
329  MITK_ASSERT_EQUAL(dummy, newDummy, "Undo set frame of reference");
330  }
331 
332  void TestSetIndexToWorldTransform()
333  {
334  DummyTestClass::Pointer dummy = DummyTestClass::New();
335  dummy->SetIndexToWorldTransform(anotherTransform);
336  MITK_ASSERT_EQUAL(anotherTransform,
337  mitk::AffineTransform3D::Pointer(dummy->GetIndexToWorldTransform()),
338  "Compare IndexToWorldTransform 1");
339 
340  // Test needs to fail now
341  dummy->SetIndexToWorldTransform(aThirdTransform);
342  MITK_ASSERT_NOT_EQUAL(anotherTransform,
343  mitk::AffineTransform3D::Pointer(dummy->GetIndexToWorldTransform()),
344  "Compare IndexToWorldTransform 2");
345 
346  // undo changes, new and changed object need to be the same!
347  dummy->SetIndexToWorldTransform(aTransform);
348  DummyTestClass::Pointer newDummy = DummyTestClass::New();
349  MITK_ASSERT_EQUAL(dummy, newDummy, "Compare IndexToWorldTransform 3");
350  }
351 
352  void TestSetIndexToWorldTransformWithoutChangingSpacing()
353  {
354  DummyTestClass::Pointer dummy = DummyTestClass::New();
355  dummy->SetIndexToWorldTransformWithoutChangingSpacing(anotherTransform);
356  CPPUNIT_ASSERT(mitk::Equal(aSpacing, dummy->GetSpacing(), mitk::eps, true));
357 
358  // calculate a new version of anotherTransform, so that the spacing should be the same as the original spacing of
359  // aTransform.
360  mitk::AffineTransform3D::MatrixType::InternalMatrixType vnlmatrix;
361  vnlmatrix = anotherTransform->GetMatrix().GetVnlMatrix();
362 
363  mitk::VnlVector col;
364  col = vnlmatrix.get_column(0);
365  col.normalize();
366  col *= aSpacing[0];
367  vnlmatrix.set_column(0, col);
368  col = vnlmatrix.get_column(1);
369  col.normalize();
370  col *= aSpacing[1];
371  vnlmatrix.set_column(1, col);
372  col = vnlmatrix.get_column(2);
373  col.normalize();
374  col *= aSpacing[2];
375  vnlmatrix.set_column(2, col);
376 
377  mitk::Matrix3D matrix;
378  matrix = vnlmatrix;
379  anotherTransform->SetMatrix(matrix);
380 
381  CPPUNIT_ASSERT(mitk::Equal(anotherTransform, dummy->GetIndexToWorldTransform(), mitk::eps, true));
382  }
383 
384  void TestSetIndexToWorldTransform_WithPointerToSameTransform()
385  {
386  DummyTestClass::Pointer dummy = DummyTestClass::New();
387 
388  dummy->SetOrigin(anotherPoint);
389  dummy->SetIndexToWorldTransform(anotherTransform);
390  dummy->SetSpacing(anotherSpacing);
391 
392  mitk::AffineTransform3D::Pointer testTransfrom = dummy->GetIndexToWorldTransform();
393 
394  mitk::Vector3D modifiedPoint = anotherPoint.GetVectorFromOrigin() * 2.;
395 
396  testTransfrom->SetOffset(modifiedPoint);
397 
398  dummy->SetIndexToWorldTransform(testTransfrom);
399 
400  CPPUNIT_ASSERT(mitk::Equal(modifiedPoint, dummy->GetOrigin().GetVectorFromOrigin()));
401  }
402 
403  void TestSetIndexToWorldTransformByVtkMatrix()
404  {
405  vtkMatrix4x4 *vtkmatrix;
406  vtkmatrix = vtkMatrix4x4::New();
407  vtkmatrix->Identity();
408  vtkmatrix->SetElement(1, 1, 2);
409  DummyTestClass::Pointer dummy = DummyTestClass::New();
410  dummy->SetIndexToWorldTransformByVtkMatrix(vtkmatrix);
411  MITK_ASSERT_EQUAL(anotherTransform,
412  mitk::AffineTransform3D::Pointer(dummy->GetIndexToWorldTransform()),
413  "Compare IndexToWorldTransformByVtkMatrix 1");
414 
415  // test needs to fail now
416  vtkmatrix->SetElement(1, 1, 7);
417  dummy->SetIndexToWorldTransformByVtkMatrix(vtkmatrix);
418  MITK_ASSERT_NOT_EQUAL(anotherTransform,
419  mitk::AffineTransform3D::Pointer(dummy->GetIndexToWorldTransform()),
420  "Compare IndexToWorldTransformByVtkMatrix 2");
421 
422  // undo changes, new and changed object need to be the same!
423  vtkmatrix->SetElement(1, 1, 1);
424  dummy->SetIndexToWorldTransformByVtkMatrix(vtkmatrix);
425  vtkmatrix->Delete();
426  DummyTestClass::Pointer newDummy = DummyTestClass::New();
427  MITK_ASSERT_EQUAL(dummy, newDummy, "Compare IndexToWorldTransformByVtkMatrix 3");
428  }
429 
430  void TestSetIdentity()
431  {
432  DummyTestClass::Pointer dummy = DummyTestClass::New();
433  // Change IndextoWorldTransform and Origin
434  dummy->SetIndexToWorldTransform(anotherTransform);
435  dummy->SetOrigin(anotherPoint);
436 
437  // Set Identity should reset ITWT and Origin
438  dummy->SetIdentity();
439 
441  aTransform, mitk::AffineTransform3D::Pointer(dummy->GetIndexToWorldTransform()), "Test set identity 1");
442  CPPUNIT_ASSERT(mitk::Equal(aPoint, dummy->GetOrigin()));
443  CPPUNIT_ASSERT(mitk::Equal(aSpacing, dummy->GetSpacing()));
444 
445  // new and changed object need to be the same!
446  DummyTestClass::Pointer newDummy = DummyTestClass::New();
447  MITK_ASSERT_EQUAL(dummy, newDummy, "Test set identity 2");
448  }
449 
450  void TestSetSpacing()
451  {
452  DummyTestClass::Pointer dummy = DummyTestClass::New();
453  dummy->SetSpacing(anotherSpacing);
454  CPPUNIT_ASSERT(mitk::Equal(anotherSpacing, dummy->GetSpacing()));
455 
456  // undo changes, new and changed object need to be the same!
457  dummy->SetSpacing(aSpacing);
458  DummyTestClass::Pointer newDummy = DummyTestClass::New();
459  MITK_ASSERT_EQUAL(dummy, newDummy, "Dummy spacing");
460  }
461 
462  void TestTransferItkToVtkTransform()
463  {
464  DummyTestClass::Pointer dummy = DummyTestClass::New();
465  dummy->SetIndexToWorldTransform(anotherTransform); // calls TransferItkToVtkTransform
466  mitk::AffineTransform3D::Pointer dummyTransform = dummy->GetIndexToWorldTransform();
467  CPPUNIT_ASSERT(mitk::MatrixEqualElementWise(anotherMatrix, dummyTransform->GetMatrix()));
468  }
469 
470  void TestConstructors()
471  {
472  // test standard constructor
473  DummyTestClass::Pointer dummy1 = DummyTestClass::New();
474  bool test = dummy1->IsValid();
475  CPPUNIT_ASSERT(test == true);
476  CPPUNIT_ASSERT(dummy1->GetFrameOfReferenceID() == 0);
477  CPPUNIT_ASSERT(dummy1->GetIndexToWorldTransformLastModified() == 0);
478 
479  CPPUNIT_ASSERT(mitk::Equal(dummy1->GetSpacing(), aSpacing));
480  CPPUNIT_ASSERT(mitk::Equal(dummy1->GetOrigin(), aPoint));
481 
482  CPPUNIT_ASSERT(dummy1->GetImageGeometry() == false);
483 
485  mitk::AffineTransform3D::Pointer(dummy1->GetIndexToWorldTransform()), aTransform, "Contructor test 1");
486 
488  mitk::BaseGeometry::BoundingBoxType::ConstPointer(dummy1->GetBoundingBox()), aBoundingBox, "Constructor test 2");
489 
490  DummyTestClass::Pointer dummy2 = DummyTestClass::New();
491  dummy2->SetOrigin(anotherPoint);
492  float bounds[6] = {0, 11, 0, 12, 0, 13};
493  dummy2->SetFloatBounds(bounds);
494  dummy2->SetIndexToWorldTransform(anotherTransform);
495  dummy2->SetSpacing(anotherSpacing);
496 
497  DummyTestClass::Pointer dummy3 = DummyTestClass::New(*dummy2);
498  MITK_ASSERT_EQUAL(dummy3, dummy2, "Dummy contructor");
499  }
500 
501  // Equal Tests
502 
503  void Equal_CloneAndOriginal_ReturnsTrue() { MITK_ASSERT_EQUAL(aDummyGeometry, anotherDummyGeometry, "Clone test"); }
504  void Equal_DifferentOrigin_ReturnsFalse()
505  {
506  anotherDummyGeometry->SetOrigin(anotherPoint);
507 
508  MITK_ASSERT_NOT_EQUAL(aDummyGeometry, anotherDummyGeometry, "Different origin test");
509  }
510 
511  void Equal_DifferentIndexToWorldTransform_ReturnsFalse()
512  {
513  anotherDummyGeometry->SetIndexToWorldTransform(anotherTransform);
514 
515  MITK_ASSERT_NOT_EQUAL(aDummyGeometry, anotherDummyGeometry, "Different index to world");
516  }
517 
518  void Equal_DifferentSpacing_ReturnsFalse()
519  {
520  anotherDummyGeometry->SetSpacing(anotherSpacing);
521 
522  MITK_ASSERT_NOT_EQUAL(aDummyGeometry, anotherDummyGeometry, "Different spacing");
523  }
524 
525  void Equal_InputIsNull_ReturnsFalse()
526  {
527  DummyTestClass::Pointer geometryNull = nullptr;
528  CPPUNIT_ASSERT_THROW(MITK_ASSERT_EQUAL(geometryNull, anotherDummyGeometry, "Input is null"), mitk::Exception);
529  }
530 
531  void Equal_DifferentBoundingBox_ReturnsFalse()
532  {
533  // create different bounds to make the comparison false
534  mitk::ScalarType bounds[] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0};
535  anotherDummyGeometry->SetBounds(bounds);
536 
537  MITK_ASSERT_NOT_EQUAL(aDummyGeometry, anotherDummyGeometry, "Different bounding box");
538  }
539 
540  void Equal_Transforms_MinorDifferences_And_Eps()
541  {
542  // Verifies that the eps parameter is evaluated properly
543  // when comparing two mitk::BaseGeometry::TransformTypes
544  aMatrix.SetIdentity();
545  anotherMatrix.SetIdentity();
546 
547  aMatrix(0, 1) = 0.0002;
548  aTransform->SetMatrix(aMatrix);
549  anotherMatrix(0, 1) = 0.0002;
550  anotherTransform->SetMatrix(anotherMatrix);
551  anotherTransform->SetMatrix(aMatrix);
552  CPPUNIT_ASSERT_MESSAGE("Exact same transforms are mitk::Equal() for eps=mitk::eps",
553  mitk::Equal(aTransform, anotherTransform, mitk::eps, true));
554  CPPUNIT_ASSERT_MESSAGE("Exact same transforms are mitk::Equal() for eps=vnl_math::eps",
555  mitk::Equal(aTransform, anotherTransform, vnl_math::eps, true));
556 
557  anotherMatrix(0, 1) = 0.0002 + mitk::eps;
558  anotherTransform->SetMatrix(anotherMatrix);
559  CPPUNIT_ASSERT_MESSAGE("Transforms of diff mitk::eps are !mitk::Equal() for eps=vnl_math::eps",
560  !mitk::Equal(aTransform, anotherTransform, vnl_math::eps, true));
561  CPPUNIT_ASSERT_MESSAGE("Transforms of diff mitk::eps are !mitk::Equal() for eps=mitk::eps-1%",
562  !mitk::Equal(aTransform, anotherTransform, mitk::eps * 0.99, true));
563  CPPUNIT_ASSERT_MESSAGE("Transforms of diff mitk::eps _are_ mitk::Equal() for eps=mitk::eps+1%",
564  mitk::Equal(aTransform, anotherTransform, mitk::eps * 1.01, true));
565  }
566 
567  void TestComposeTransform()
568  {
569  // Create Transformations to set and compare
570  mitk::AffineTransform3D::Pointer transform1;
571  transform1 = mitk::AffineTransform3D::New();
572  mitk::AffineTransform3D::MatrixType matrix1;
573  matrix1.SetIdentity();
574  matrix1(1, 1) = 2;
575  transform1->SetMatrix(matrix1); // Spacing = 2
576 
577  mitk::AffineTransform3D::Pointer transform2;
578  transform2 = mitk::AffineTransform3D::New();
579  mitk::AffineTransform3D::MatrixType matrix2;
580  matrix2.SetIdentity();
581  matrix2(1, 1) = 2;
582  transform2->SetMatrix(matrix2); // Spacing = 2
583 
584  mitk::AffineTransform3D::Pointer transform3;
585  transform3 = mitk::AffineTransform3D::New();
586  mitk::AffineTransform3D::MatrixType matrix3;
587  matrix3.SetIdentity();
588  matrix3(1, 1) = 4;
589  transform3->SetMatrix(matrix3); // Spacing = 4
590 
591  mitk::AffineTransform3D::Pointer transform4;
592  transform4 = mitk::AffineTransform3D::New();
593  mitk::AffineTransform3D::MatrixType matrix4;
594  matrix4.SetIdentity();
595  matrix4(1, 1) = 0.25;
596  transform4->SetMatrix(matrix4); // Spacing = 0.25
597 
598  // Vector to compare spacing
599  mitk::Vector3D expectedSpacing;
600  expectedSpacing.Fill(1.0);
601  expectedSpacing[1] = 4;
602 
603  DummyTestClass::Pointer dummy = DummyTestClass::New();
604  dummy->SetIndexToWorldTransform(transform1); // Spacing = 2
605  dummy->Compose(transform2); // Spacing = 4
606  CPPUNIT_ASSERT(mitk::Equal(dummy->GetSpacing(), expectedSpacing));
608  transform3, mitk::AffineTransform3D::Pointer(dummy->GetIndexToWorldTransform()), "Compose transform 2"); // 4=4
609 
610  // undo changes, new and changed object need to be the same!
611  dummy->Compose(transform4); // Spacing = 1
612  DummyTestClass::Pointer newDummy = DummyTestClass::New();
613  MITK_ASSERT_EQUAL(dummy, newDummy, "Compose transform 3"); // 1=1
614  }
615 
616  void TestComposeVtkMatrix()
617  {
618  // Create Transformations to set and compare
619  mitk::AffineTransform3D::Pointer transform1;
620  transform1 = mitk::AffineTransform3D::New();
621  mitk::AffineTransform3D::MatrixType matrix1;
622  matrix1.SetIdentity();
623  matrix1(1, 1) = 2;
624  transform1->SetMatrix(matrix1); // Spacing = 2
625 
626  vtkMatrix4x4 *vtkmatrix2;
627  vtkmatrix2 = vtkMatrix4x4::New();
628  vtkmatrix2->Identity();
629  vtkmatrix2->SetElement(1, 1, 2); // Spacing = 2
630 
631  mitk::AffineTransform3D::Pointer transform3;
632  transform3 = mitk::AffineTransform3D::New();
633  mitk::AffineTransform3D::MatrixType matrix3;
634  matrix3.SetIdentity();
635  matrix3(1, 1) = 4;
636  transform3->SetMatrix(matrix3); // Spacing = 4
637 
638  vtkMatrix4x4 *vtkmatrix4;
639  vtkmatrix4 = vtkMatrix4x4::New();
640  vtkmatrix4->Identity();
641  vtkmatrix4->SetElement(1, 1, 0.25); // Spacing = 0.25
642 
643  // Vector to compare spacing
644  mitk::Vector3D expectedSpacing;
645  expectedSpacing.Fill(1.0);
646  expectedSpacing[1] = 4;
647 
648  DummyTestClass::Pointer dummy = DummyTestClass::New();
649  dummy->SetIndexToWorldTransform(transform1); // Spacing = 2
650  dummy->Compose(vtkmatrix2); // Spacing = 4
651  vtkmatrix2->Delete();
652 
654  transform3, mitk::AffineTransform3D::Pointer(dummy->GetIndexToWorldTransform()), "Compose vtk matrix"); // 4=4
655  CPPUNIT_ASSERT(mitk::Equal(dummy->GetSpacing(), expectedSpacing));
656 
657  // undo changes, new and changed object need to be the same!
658  dummy->Compose(vtkmatrix4); // Spacing = 1
659  vtkmatrix4->Delete();
660  DummyTestClass::Pointer newDummy = DummyTestClass::New();
661  MITK_ASSERT_EQUAL(dummy, newDummy, "Compose vtk"); // 1=1
662  }
663 
664  void TestTranslate()
665  {
666  DummyTestClass::Pointer dummy = DummyTestClass::New();
667  dummy->SetOrigin(anotherPoint);
668  CPPUNIT_ASSERT(mitk::Equal(anotherPoint, dummy->GetOrigin()));
669 
670  // use some random values for translation
671  mitk::Vector3D translationVector;
672  translationVector.SetElement(0, 17.5f);
673  translationVector.SetElement(1, -32.3f);
674  translationVector.SetElement(2, 4.0f);
675 
676  // compute ground truth
677  mitk::Point3D tmpResult = anotherPoint + translationVector;
678  dummy->Translate(translationVector);
679  CPPUNIT_ASSERT(mitk::Equal(dummy->GetOrigin(), tmpResult));
680 
681  // undo changes
682  translationVector *= -1;
683  dummy->Translate(translationVector);
684  CPPUNIT_ASSERT(mitk::Equal(dummy->GetOrigin(), anotherPoint));
685 
686  // undo changes, new and changed object need to be the same!
687  translationVector.SetElement(0, -1 * anotherPoint[0]);
688  translationVector.SetElement(1, -1 * anotherPoint[1]);
689  translationVector.SetElement(2, -1 * anotherPoint[2]);
690  dummy->Translate(translationVector);
691 
692  DummyTestClass::Pointer newDummy = DummyTestClass::New();
693  MITK_ASSERT_EQUAL(dummy, newDummy, "Translate test");
694  }
695 
696  // a part of the test requires axis-parallel coordinates
698  {
699  // Testing consistency of index and world coordinate systems
700  mitk::Point3D origin = dummyGeometry->GetOrigin();
701  mitk::Point3D dummyPoint;
702 
703  // Testing index->world->index conversion consistency
704  dummyGeometry->WorldToIndex(origin, dummyPoint);
705  dummyGeometry->IndexToWorld(dummyPoint, dummyPoint);
706  CPPUNIT_ASSERT(mitk::EqualArray(dummyPoint, origin, 3, mitk::eps, true));
707 
708  // Testing WorldToIndex(origin, mitk::Point3D)==(0,0,0)
709  mitk::Point3D globalOrigin;
710  mitk::FillVector3D(globalOrigin, 0, 0, 0);
711 
712  mitk::Point3D originContinuousIndex;
713  dummyGeometry->WorldToIndex(origin, originContinuousIndex);
714  CPPUNIT_ASSERT(mitk::EqualArray(originContinuousIndex, globalOrigin, 3, mitk::eps, true));
715 
716  // Testing WorldToIndex(origin, itk::Index)==(0,0,0)
717  itk::Index<3> itkindex;
718  dummyGeometry->WorldToIndex(origin, itkindex);
719  itk::Index<3> globalOriginIndex;
720  mitk::vtk2itk(globalOrigin, globalOriginIndex);
721  CPPUNIT_ASSERT(mitk::EqualArray(itkindex, globalOriginIndex, 3, mitk::eps, true));
722 
723  // Testing WorldToIndex(origin-0.5*spacing, itk::Index)==(0,0,0)
724  mitk::Vector3D halfSpacingStep = dummyGeometry->GetSpacing() * 0.5;
726  mitk::Point3D originOffCenter = origin - halfSpacingStep;
727  dummyGeometry->WorldToIndex(originOffCenter, itkindex);
728  CPPUNIT_ASSERT(mitk::EqualArray(itkindex, globalOriginIndex, 3, mitk::eps, true));
729 
730  // Testing WorldToIndex(origin+0.5*spacing-eps, itk::Index)==(0,0,0)
731  originOffCenter = origin + halfSpacingStep;
732  originOffCenter -= 0.0001;
733  dummyGeometry->WorldToIndex(originOffCenter, itkindex);
734  CPPUNIT_ASSERT(mitk::EqualArray(itkindex, globalOriginIndex, 3, mitk::eps, true));
735 
736  // Testing WorldToIndex(origin+0.5*spacing, itk::Index)==(1,1,1)");
737  originOffCenter = origin + halfSpacingStep;
738  itk::Index<3> global111;
739  mitk::FillVector3D(global111, 1, 1, 1);
740  dummyGeometry->WorldToIndex(originOffCenter, itkindex);
741  CPPUNIT_ASSERT(mitk::EqualArray(itkindex, global111, 3, mitk::eps, true));
742 
743  // Testing WorldToIndex(GetCenter())==BoundingBox.GetCenter
744  mitk::Point3D center = dummyGeometry->GetCenter();
745  mitk::Point3D centerContIndex;
746  dummyGeometry->WorldToIndex(center, centerContIndex);
747  mitk::BoundingBox::ConstPointer boundingBox = dummyGeometry->GetBoundingBox();
748  mitk::BoundingBox::PointType centerBounds = boundingBox->GetCenter();
749  CPPUNIT_ASSERT(mitk::Equal(centerContIndex, centerBounds));
750 
751  // Testing GetCenter()==IndexToWorld(BoundingBox.GetCenter)
752  center = dummyGeometry->GetCenter();
753  mitk::Point3D centerBoundsInWorldCoords;
754  dummyGeometry->IndexToWorld(centerBounds, centerBoundsInWorldCoords);
755  CPPUNIT_ASSERT(mitk::Equal(center, centerBoundsInWorldCoords));
756 
757  // Test using random point,
758  // Testing consistency of index and world coordinate systems
759  mitk::Point3D point;
760  mitk::FillVector3D(point, 3.5, -2, 4.6);
761 
762  // Testing index->world->index conversion consistency
763  dummyGeometry->WorldToIndex(point, dummyPoint);
764  dummyGeometry->IndexToWorld(dummyPoint, dummyPoint);
765  CPPUNIT_ASSERT(mitk::EqualArray(dummyPoint, point, 3, mitk::eps, true));
766 
767  return EXIT_SUCCESS;
768  }
769 
771  {
772  // Testing consistency of index and world coordinate systems for vectors
773  mitk::Vector3D xAxisMM = dummyGeometry->GetAxisVector(0);
774  mitk::Vector3D xAxisContinuousIndex;
775 
776  mitk::Point3D p, pIndex, origin;
777  origin = dummyGeometry->GetOrigin();
778  p[0] = xAxisMM[0] + origin[0];
779  p[1] = xAxisMM[1] + origin[1];
780  p[2] = xAxisMM[2] + origin[2];
781 
782  dummyGeometry->WorldToIndex(p, pIndex);
783 
784  dummyGeometry->WorldToIndex(xAxisMM, xAxisContinuousIndex);
785  CPPUNIT_ASSERT(mitk::Equal(xAxisContinuousIndex[0], pIndex[0]));
786  CPPUNIT_ASSERT(mitk::Equal(xAxisContinuousIndex[1], pIndex[1]));
787  CPPUNIT_ASSERT(mitk::Equal(xAxisContinuousIndex[2], pIndex[2]));
788 
789  dummyGeometry->IndexToWorld(xAxisContinuousIndex, xAxisContinuousIndex);
790 
791  dummyGeometry->IndexToWorld(pIndex, p);
792 
793  CPPUNIT_ASSERT(xAxisContinuousIndex == xAxisMM);
794  CPPUNIT_ASSERT(mitk::Equal(xAxisContinuousIndex[0], p[0] - origin[0]));
795  CPPUNIT_ASSERT(mitk::Equal(xAxisContinuousIndex[1], p[1] - origin[1]));
796  CPPUNIT_ASSERT(mitk::Equal(xAxisContinuousIndex[2], p[2] - origin[2]));
797 
798  // Test consictency for random vector
799  mitk::Vector3D vector;
800  mitk::FillVector3D(vector, 2.5, -3.2, 8.1);
801  mitk::Vector3D vectorContinuousIndex;
802 
803  p[0] = vector[0] + origin[0];
804  p[1] = vector[1] + origin[1];
805  p[2] = vector[2] + origin[2];
806 
807  dummyGeometry->WorldToIndex(p, pIndex);
808 
809  dummyGeometry->WorldToIndex(vector, vectorContinuousIndex);
810  CPPUNIT_ASSERT(mitk::Equal(vectorContinuousIndex[0], pIndex[0]));
811  CPPUNIT_ASSERT(mitk::Equal(vectorContinuousIndex[1], pIndex[1]));
812  CPPUNIT_ASSERT(mitk::Equal(vectorContinuousIndex[2], pIndex[2]));
813 
814  dummyGeometry->IndexToWorld(vectorContinuousIndex, vectorContinuousIndex);
815 
816  dummyGeometry->IndexToWorld(pIndex, p);
817 
818  CPPUNIT_ASSERT(vectorContinuousIndex == vector);
819  CPPUNIT_ASSERT(mitk::Equal(vectorContinuousIndex[0], p[0] - origin[0]));
820  CPPUNIT_ASSERT(mitk::Equal(vectorContinuousIndex[1], p[1] - origin[1]));
821  CPPUNIT_ASSERT(mitk::Equal(vectorContinuousIndex[2], p[2] - origin[2]));
822 
823  return EXIT_SUCCESS;
824  }
825 
827  {
828  // Testing consistency of index and world coordinate systems
829 
830  // creating testing data
831  itk::Index<4> itkIndex4, itkIndex4b;
832  itk::Index<3> itkIndex3, itkIndex3b;
833  itk::Index<2> itkIndex2, itkIndex2b;
834  itk::Index<3> mitkIndex, mitkIndexb;
835 
836  itkIndex4[0] = itkIndex4[1] = itkIndex4[2] = itkIndex4[3] = 4;
837  itkIndex3[0] = itkIndex3[1] = itkIndex3[2] = 6;
838  itkIndex2[0] = itkIndex2[1] = 2;
839  mitkIndex[0] = mitkIndex[1] = mitkIndex[2] = 13;
840 
841  // check for constistency
842  mitk::Point3D point;
843  dummyGeometry->IndexToWorld(itkIndex2, point);
844  dummyGeometry->WorldToIndex(point, itkIndex2b);
845 
846  CPPUNIT_ASSERT(((itkIndex2b[0] == itkIndex2[0]) && (itkIndex2b[1] == itkIndex2[1])));
847  // Testing itk::index<2> for IndexToWorld/WorldToIndex consistency
848 
849  dummyGeometry->IndexToWorld(itkIndex3, point);
850  dummyGeometry->WorldToIndex(point, itkIndex3b);
851 
852  CPPUNIT_ASSERT(
853  ((itkIndex3b[0] == itkIndex3[0]) && (itkIndex3b[1] == itkIndex3[1]) && (itkIndex3b[2] == itkIndex3[2])));
854  // Testing itk::index<3> for IndexToWorld/WorldToIndex consistency
855 
856  dummyGeometry->IndexToWorld(itkIndex4, point);
857  dummyGeometry->WorldToIndex(point, itkIndex4b);
858 
859  CPPUNIT_ASSERT(((itkIndex4b[0] == itkIndex4[0]) && (itkIndex4b[1] == itkIndex4[1]) &&
860  (itkIndex4b[2] == itkIndex4[2]) && (itkIndex4b[3] == 0)));
861  // Testing itk::index<3> for IndexToWorld/WorldToIndex consistency
862 
863  dummyGeometry->IndexToWorld(mitkIndex, point);
864  dummyGeometry->WorldToIndex(point, mitkIndexb);
865 
866  CPPUNIT_ASSERT(
867  ((mitkIndexb[0] == mitkIndex[0]) && (mitkIndexb[1] == mitkIndex[1]) && (mitkIndexb[2] == mitkIndex[2])));
868  // Testing mitk::Index for IndexToWorld/WorldToIndex consistency
869 
870  return EXIT_SUCCESS;
871  }
872 
873  void TestIndexToWorld()
874  {
875  DummyTestClass::Pointer dummy = DummyTestClass::New();
876 
880 
881  // Geometry must not have changed
882  DummyTestClass::Pointer newDummy = DummyTestClass::New();
883  MITK_ASSERT_EQUAL(dummy, newDummy, "Dummy index to world");
884 
885  // Test with other geometries
886  dummy->SetOrigin(anotherPoint);
890 
891  dummy->SetIndexToWorldTransform(anotherTransform);
895 
896  dummy->SetOrigin(anotherPoint);
900 
901  dummy->SetSpacing(anotherSpacing);
905  }
906 
907  void TestExecuteOperation()
908  {
909  DummyTestClass::Pointer dummy = DummyTestClass::New();
910 
911  // Do same Operations with new Dummy and compare
912  DummyTestClass::Pointer newDummy = DummyTestClass::New();
913 
914  // Test operation Nothing
915  auto opN = new mitk::Operation(mitk::OpNOTHING);
916  dummy->ExecuteOperation(opN);
917  MITK_ASSERT_EQUAL(dummy, newDummy, "Dummy execute operation 1");
918 
919  // Test operation Move
920  auto opP = new mitk::PointOperation(mitk::OpMOVE, anotherPoint);
921  dummy->ExecuteOperation(opP);
922  CPPUNIT_ASSERT(mitk::Equal(anotherPoint, dummy->GetOrigin()));
923  newDummy->SetOrigin(anotherPoint);
924  MITK_ASSERT_EQUAL(dummy, newDummy, "Dummy execute operation 2");
925 
926  // Test operation Scale, Scale sets spacing to scale+1
927  mitk::Point3D spacing;
928  spacing[0] = anotherSpacing[0] - 1.;
929  spacing[1] = anotherSpacing[1] - 1.;
930  spacing[2] = anotherSpacing[2] - 1.;
931 
932  auto opS = new mitk::ScaleOperation(mitk::OpSCALE, spacing, anotherPoint);
933  dummy->ExecuteOperation(opS);
934  CPPUNIT_ASSERT(mitk::Equal(anotherSpacing, dummy->GetSpacing()));
935  newDummy->SetSpacing(anotherSpacing);
936  MITK_ASSERT_EQUAL(dummy, newDummy, "Dummy execute operation 3");
937 
938  // change Geometry to test more cases
939  dummy->SetIndexToWorldTransform(anotherTransform);
940  dummy->SetSpacing(anotherSpacing);
941 
942  // Testing a rotation of the geometry
943  double angle = 35.0;
944  mitk::Vector3D rotationVector;
945  mitk::FillVector3D(rotationVector, 1, 0, 0);
946  mitk::Point3D center = dummy->GetCenter();
947  auto opR = new mitk::RotationOperation(mitk::OpROTATE, center, rotationVector, angle);
948  dummy->ExecuteOperation(opR);
949 
951  mitk::GetRotation(dummy, rotation);
952  mitk::Vector3D voxelStep = rotation * anotherSpacing;
953  mitk::Vector3D voxelStepIndex;
954  dummy->WorldToIndex(voxelStep, voxelStepIndex);
955  mitk::Vector3D expectedVoxelStepIndex;
956  expectedVoxelStepIndex.Fill(1);
957  CPPUNIT_ASSERT(mitk::Equal(voxelStepIndex, expectedVoxelStepIndex));
958 
959  delete opR;
960  delete opN;
961  delete opS;
962  delete opP;
963  }
964 
965  void TestCalculateBoundingBoxRelToTransform()
966  {
967  DummyTestClass::Pointer dummy = DummyTestClass::New();
968  dummy->SetExtentInMM(0, 15);
969  dummy->SetExtentInMM(1, 20);
970  dummy->SetExtentInMM(2, 8);
971 
972  mitk::BoundingBox::Pointer dummyBoundingBox = dummy->CalculateBoundingBoxRelativeToTransform(anotherTransform);
973 
974  mitk::BoundingBox::PointsContainer::Pointer pointscontainer = mitk::BoundingBox::PointsContainer::New();
975  mitk::BoundingBox::PointIdentifier pointid = 0;
976  unsigned char i;
977  mitk::AffineTransform3D::Pointer inverse = mitk::AffineTransform3D::New();
978  anotherTransform->GetInverse(inverse);
979  for (i = 0; i < 8; ++i)
980  pointscontainer->InsertElement(pointid++, inverse->TransformPoint(dummy->GetCornerPoint(i)));
981  mitk::BoundingBox::Pointer result = mitk::BoundingBox::New();
982  result->SetPoints(pointscontainer);
983  result->ComputeBoundingBox();
984 
985  MITK_ASSERT_EQUAL(result, dummyBoundingBox, "BBox rel to transform");
986 
987  // dummy still needs to be unchanged, except for extend
988  DummyTestClass::Pointer newDummy = DummyTestClass::New();
989  newDummy->SetExtentInMM(0, 15);
990  newDummy->SetExtentInMM(1, 20);
991  newDummy->SetExtentInMM(2, 8);
992  MITK_ASSERT_EQUAL(dummy, newDummy, "Dummy BBox");
993  }
994 
995  // void TestSetTimeBounds(){
996  // mitk::TimeBounds timeBounds;
997  // timeBounds[0] = 1;
998  // timeBounds[1] = 9;
999 
1000  // DummyTestClass::Pointer dummy = DummyTestClass::New();
1001  // dummy->SetTimeBounds(timeBounds);
1002  // mitk::TimeBounds timeBounds2 = dummy->GetTimeBounds();
1003 
1004  // CPPUNIT_ASSERT(timeBounds[0]==timeBounds2[0]);
1005  // CPPUNIT_ASSERT(timeBounds[1]==timeBounds2[1]);
1006 
1007  // //undo changes, new and changed object need to be the same!
1008  // timeBounds[0]=mitk::ScalarTypeNumericTraits::NonpositiveMin();
1009  // timeBounds[1]=mitk::ScalarTypeNumericTraits::max();
1010 
1011  // DummyTestClass::Pointer newDummy = DummyTestClass::New();
1012  // CPPUNIT_ASSERT(mitk::Equal(dummy,newDummy,mitk::eps,true));
1013  //}
1014 
1015  void TestIs2DConvertable()
1016  {
1017  DummyTestClass::Pointer dummy = DummyTestClass::New();
1018 
1019  // new initialized geometry is 2D convertable
1020  CPPUNIT_ASSERT(dummy->Is2DConvertable());
1021 
1022  // Wrong Spacing needs to fail
1023  dummy->SetSpacing(anotherSpacing);
1024  CPPUNIT_ASSERT(dummy->Is2DConvertable() == false);
1025  // undo
1026  dummy->SetSpacing(aSpacing);
1027  CPPUNIT_ASSERT(dummy->Is2DConvertable());
1028 
1029  // Wrong Origin needs to fail
1030  dummy->SetOrigin(anotherPoint);
1031  CPPUNIT_ASSERT(dummy->Is2DConvertable() == false);
1032  // undo
1033  dummy->SetOrigin(aPoint);
1034  CPPUNIT_ASSERT(dummy->Is2DConvertable());
1035 
1036  // third dimension must not be transformed
1037  mitk::AffineTransform3D::Pointer dummyTransform = mitk::AffineTransform3D::New();
1038  mitk::AffineTransform3D::MatrixType dummyMatrix;
1039  dummyMatrix.SetIdentity();
1040  dummyTransform->SetMatrix(dummyMatrix);
1041  dummy->SetIndexToWorldTransform(dummyTransform);
1042 
1043  // identity matrix is 2DConvertable
1044  CPPUNIT_ASSERT(dummy->Is2DConvertable());
1045 
1046  dummyMatrix(0, 2) = 3;
1047  dummyTransform->SetMatrix(dummyMatrix);
1048  CPPUNIT_ASSERT(dummy->Is2DConvertable() == false);
1049 
1050  dummyMatrix.SetIdentity();
1051  dummyMatrix(1, 2) = 0.4;
1052  dummyTransform->SetMatrix(dummyMatrix);
1053  CPPUNIT_ASSERT(dummy->Is2DConvertable() == false);
1054 
1055  dummyMatrix.SetIdentity();
1056  dummyMatrix(2, 2) = 3;
1057  dummyTransform->SetMatrix(dummyMatrix);
1058  CPPUNIT_ASSERT(dummy->Is2DConvertable() == false);
1059 
1060  dummyMatrix.SetIdentity();
1061  dummyMatrix(2, 1) = 3;
1062  dummyTransform->SetMatrix(dummyMatrix);
1063  CPPUNIT_ASSERT(dummy->Is2DConvertable() == false);
1064 
1065  dummyMatrix.SetIdentity();
1066  dummyMatrix(2, 0) = 3;
1067  dummyTransform->SetMatrix(dummyMatrix);
1068  CPPUNIT_ASSERT(dummy->Is2DConvertable() == false);
1069 
1070  // undo changes, new and changed object need to be the same!
1071  dummyMatrix.SetIdentity();
1072  dummyTransform->SetMatrix(dummyMatrix);
1073  DummyTestClass::Pointer newDummy = DummyTestClass::New();
1074  MITK_ASSERT_EQUAL(dummy, newDummy, "Is 2D convertable");
1075  }
1076 
1077  void TestGetCornerPoint()
1078  {
1079  DummyTestClass::Pointer dummy = DummyTestClass::New();
1080  dummy->SetIndexToWorldTransform(anotherTransform);
1081  double bounds[6] = {0, 11, 0, 12, 0, 13};
1082  dummy->SetFloatBounds(bounds);
1083 
1084  mitk::Point3D corner, refCorner;
1085 
1086  // Corner 0
1087  mitk::FillVector3D(refCorner, bounds[0], bounds[2], bounds[4]);
1088  refCorner = anotherTransform->TransformPoint(refCorner);
1089  corner = dummy->GetCornerPoint(0);
1090  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1091  corner = dummy->GetCornerPoint(true, true, true);
1092  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1093 
1094  // Corner 1
1095  mitk::FillVector3D(refCorner, bounds[0], bounds[2], bounds[5]);
1096  refCorner = anotherTransform->TransformPoint(refCorner);
1097  corner = dummy->GetCornerPoint(1);
1098  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1099  corner = dummy->GetCornerPoint(true, true, false);
1100  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1101 
1102  // Corner 2
1103  mitk::FillVector3D(refCorner, bounds[0], bounds[3], bounds[4]);
1104  refCorner = anotherTransform->TransformPoint(refCorner);
1105  corner = dummy->GetCornerPoint(2);
1106  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1107  corner = dummy->GetCornerPoint(true, false, true);
1108  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1109 
1110  // Corner 3
1111  mitk::FillVector3D(refCorner, bounds[0], bounds[3], bounds[5]);
1112  refCorner = anotherTransform->TransformPoint(refCorner);
1113  corner = dummy->GetCornerPoint(3);
1114  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1115  corner = dummy->GetCornerPoint(true, false, false);
1116  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1117 
1118  // Corner 4
1119  mitk::FillVector3D(refCorner, bounds[1], bounds[2], bounds[4]);
1120  refCorner = anotherTransform->TransformPoint(refCorner);
1121  corner = dummy->GetCornerPoint(4);
1122  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1123  corner = dummy->GetCornerPoint(false, true, true);
1124  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1125 
1126  // Corner 5
1127  mitk::FillVector3D(refCorner, bounds[1], bounds[2], bounds[5]);
1128  refCorner = anotherTransform->TransformPoint(refCorner);
1129  corner = dummy->GetCornerPoint(5);
1130  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1131  corner = dummy->GetCornerPoint(false, true, false);
1132  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1133 
1134  // Corner 6
1135  mitk::FillVector3D(refCorner, bounds[1], bounds[3], bounds[4]);
1136  refCorner = anotherTransform->TransformPoint(refCorner);
1137  corner = dummy->GetCornerPoint(6);
1138  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1139  corner = dummy->GetCornerPoint(false, false, true);
1140  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1141 
1142  // Corner 7
1143  mitk::FillVector3D(refCorner, bounds[1], bounds[3], bounds[5]);
1144  refCorner = anotherTransform->TransformPoint(refCorner);
1145  corner = dummy->GetCornerPoint(7);
1146  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1147  corner = dummy->GetCornerPoint(false, false, false);
1148  CPPUNIT_ASSERT(mitk::Equal(refCorner, corner));
1149 
1150  // Wrong Corner needs to fail
1151  CPPUNIT_ASSERT_THROW(dummy->GetCornerPoint(20), itk::ExceptionObject);
1152 
1153  // dummy geometry must not have changed!
1154  DummyTestClass::Pointer newDummy = DummyTestClass::New();
1155  newDummy->SetIndexToWorldTransform(anotherTransform);
1156  newDummy->SetFloatBounds(bounds);
1157  MITK_ASSERT_EQUAL(dummy, newDummy, "Corner point");
1158  }
1159 
1160  void TestExtentInMM()
1161  {
1162  DummyTestClass::Pointer dummy = DummyTestClass::New();
1163  dummy->SetExtentInMM(0, 50);
1164  CPPUNIT_ASSERT(mitk::Equal(50., dummy->GetExtentInMM(0)));
1165  // Vnl Matrix has changed. The next line only works because the spacing is 1!
1166  CPPUNIT_ASSERT(
1167  mitk::Equal(50., dummy->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(0).magnitude()));
1168 
1169  // Smaller extent than original
1170  dummy->SetExtentInMM(0, 5);
1171  CPPUNIT_ASSERT(mitk::Equal(5., dummy->GetExtentInMM(0)));
1172  CPPUNIT_ASSERT(
1173  mitk::Equal(5., dummy->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(0).magnitude()));
1174 
1175  dummy->SetExtentInMM(1, 4);
1176  CPPUNIT_ASSERT(mitk::Equal(4., dummy->GetExtentInMM(1)));
1177  CPPUNIT_ASSERT(
1178  mitk::Equal(4., dummy->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(1).magnitude()));
1179 
1180  dummy->SetExtentInMM(2, 2.5);
1181  CPPUNIT_ASSERT(mitk::Equal(2.5, dummy->GetExtentInMM(2)));
1182  CPPUNIT_ASSERT(
1183  mitk::Equal(2.5, dummy->GetIndexToWorldTransform()->GetMatrix().GetVnlMatrix().get_column(2).magnitude()));
1184  }
1185 
1186  void TestGetAxisVector()
1187  {
1188  DummyTestClass::Pointer dummy = DummyTestClass::New();
1189  dummy->SetIndexToWorldTransform(anotherTransform);
1190  double bounds[6] = {0, 11, 0, 12, 0, 13};
1191  dummy->SetFloatBounds(bounds);
1192 
1193  mitk::Vector3D vector;
1194  mitk::FillVector3D(vector, bounds[1], 0, 0);
1195  dummy->IndexToWorld(vector, vector);
1196  CPPUNIT_ASSERT(mitk::Equal(dummy->GetAxisVector(0), vector));
1197 
1198  mitk::FillVector3D(vector, 0, bounds[3], 0);
1199  dummy->IndexToWorld(vector, vector);
1200  CPPUNIT_ASSERT(mitk::Equal(dummy->GetAxisVector(1), vector));
1201 
1202  mitk::FillVector3D(vector, 0, 0, bounds[5]);
1203  dummy->IndexToWorld(vector, vector);
1204  CPPUNIT_ASSERT(mitk::Equal(dummy->GetAxisVector(2), vector));
1205  }
1206 
1207  void TestGetCenter()
1208  {
1209  DummyTestClass::Pointer dummy = DummyTestClass::New();
1210  dummy->SetIndexToWorldTransform(anotherTransform);
1211  double bounds[6] = {0, 11, 2, 12, 1, 13};
1212  dummy->SetFloatBounds(bounds);
1213 
1214  mitk::Point3D refCenter;
1215  for (int i = 0; i < 3; i++)
1216  refCenter.SetElement(i, (bounds[2 * i] + bounds[2 * i + 1]) / 2.0);
1217 
1218  dummy->IndexToWorld(refCenter, refCenter);
1219 
1220  CPPUNIT_ASSERT(mitk::Equal(dummy->GetCenter(), refCenter));
1221  }
1222 
1223  void TestGetDiagonalLength()
1224  {
1225  DummyTestClass::Pointer dummy = DummyTestClass::New();
1226  double bounds[6] = {1, 3, 5, 8, 7.5, 11.5};
1227  dummy->SetFloatBounds(bounds);
1228  // 3-1=2, 8-5=3, 11.5-7.5=4; 2^2+3^2+4^2 = 29
1229  double expectedLength = sqrt(29.);
1230 
1231  CPPUNIT_ASSERT(mitk::Equal(expectedLength, dummy->GetDiagonalLength(), mitk::eps, true));
1232  CPPUNIT_ASSERT(mitk::Equal(29., dummy->GetDiagonalLength2(), mitk::eps, true));
1233 
1234  // dummy must not have changed
1235  DummyTestClass::Pointer newDummy = DummyTestClass::New();
1236  newDummy->SetFloatBounds(bounds);
1237  MITK_ASSERT_EQUAL(dummy, newDummy, "Diagonal length");
1238  }
1239 
1240  void TestGetExtent()
1241  {
1242  DummyTestClass::Pointer dummy = DummyTestClass::New();
1243  double bounds[6] = {1, 3, 5, 8, 7.5, 11.5};
1244  dummy->SetFloatBounds(bounds);
1245 
1246  CPPUNIT_ASSERT(mitk::Equal(2., dummy->GetExtent(0)));
1247  CPPUNIT_ASSERT(mitk::Equal(3., dummy->GetExtent(1)));
1248  CPPUNIT_ASSERT(mitk::Equal(4., dummy->GetExtent(2)));
1249 
1250  // dummy must not have changed
1251  DummyTestClass::Pointer newDummy = DummyTestClass::New();
1252  newDummy->SetFloatBounds(bounds);
1253  MITK_ASSERT_EQUAL(dummy, newDummy, "Extend");
1254  }
1255 
1256  void TestIsInside()
1257  {
1258  DummyTestClass::Pointer dummy = DummyTestClass::New();
1259  double bounds[6] = {1, 3, 5, 8, 7.5, 11.5};
1260  dummy->SetFloatBounds(bounds);
1261 
1262  mitk::Point3D insidePoint;
1263  mitk::Point3D outsidePoint;
1264 
1265  mitk::FillVector3D(insidePoint, 2, 6, 7.6);
1266  mitk::FillVector3D(outsidePoint, 0, 9, 8.2);
1267 
1268  CPPUNIT_ASSERT(dummy->IsIndexInside(insidePoint));
1269  CPPUNIT_ASSERT(false == dummy->IsIndexInside(outsidePoint));
1270 
1271  dummy->IndexToWorld(insidePoint, insidePoint);
1272  dummy->IndexToWorld(outsidePoint, outsidePoint);
1273 
1274  CPPUNIT_ASSERT(dummy->IsInside(insidePoint));
1275  CPPUNIT_ASSERT(false == dummy->IsInside(outsidePoint));
1276 
1277  // dummy must not have changed
1278  DummyTestClass::Pointer newDummy = DummyTestClass::New();
1279  newDummy->SetFloatBounds(bounds);
1280  MITK_ASSERT_EQUAL(dummy, newDummy, "Is inside");
1281  }
1282 
1283  void TestInitialize()
1284  {
1285  // test standard constructor
1286  DummyTestClass::Pointer dummy1 = DummyTestClass::New();
1287 
1288  DummyTestClass::Pointer dummy2 = DummyTestClass::New();
1289  dummy2->SetOrigin(anotherPoint);
1290  dummy2->SetBounds(anotherBoundingBox->GetBounds());
1291  // mitk::TimeBounds timeBounds;
1292  // timeBounds[0] = 1;
1293  // timeBounds[1] = 9;
1294  // dummy2->SetTimeBounds(timeBounds);
1295  dummy2->SetIndexToWorldTransform(anotherTransform);
1296  dummy2->SetSpacing(anotherSpacing);
1297 
1298  dummy1->InitializeGeometry(dummy2);
1299 
1300  MITK_ASSERT_EQUAL(dummy1, dummy2, "Initialize 1");
1301 
1302  dummy1->Initialize();
1303 
1304  DummyTestClass::Pointer dummy3 = DummyTestClass::New();
1305  MITK_ASSERT_EQUAL(dummy3, dummy1, "Initialize 2");
1306  }
1307 
1308  void TestGetMatrixColumn()
1309  {
1310  DummyTestClass::Pointer dummy = DummyTestClass::New();
1311  dummy->SetIndexToWorldTransform(anotherTransform);
1312  mitk::Vector3D testVector, refVector;
1313 
1314  testVector.SetVnlVector(dummy->GetMatrixColumn(0));
1315  mitk::FillVector3D(refVector, 1, 0, 0);
1316  CPPUNIT_ASSERT(testVector == refVector);
1317 
1318  testVector.SetVnlVector(dummy->GetMatrixColumn(1));
1319  mitk::FillVector3D(refVector, 0, 2, 0);
1320  CPPUNIT_ASSERT(testVector == refVector);
1321 
1322  testVector.SetVnlVector(dummy->GetMatrixColumn(2));
1323  mitk::FillVector3D(refVector, 0, 0, 1);
1324  CPPUNIT_ASSERT(testVector == refVector);
1325 
1326  // dummy must not have changed
1327  DummyTestClass::Pointer newDummy = DummyTestClass::New();
1328  newDummy->SetIndexToWorldTransform(anotherTransform);
1329  MITK_ASSERT_EQUAL(dummy, newDummy, "GetMatrixColumn");
1330  }
1331 
1332  void IsSubGeometry_Spacing()
1333  {
1334  CPPUNIT_ASSERT(mitk::IsSubGeometry(*aDummyGeometry, *aDummyGeometry, mitk::eps, true));
1335 
1336  for (unsigned int i = 0; i < 3; ++i)
1337  {
1338  mitk::Vector3D wrongSpacing = aDummyGeometry->GetSpacing();
1339  wrongSpacing[i] += mitk::eps * 2;
1340  auto wrongGeometry = aDummyGeometry->Clone();
1341  wrongGeometry->SetSpacing(wrongSpacing);
1342 
1343  CPPUNIT_ASSERT(!mitk::IsSubGeometry(*wrongGeometry, *aDummyGeometry, mitk::eps, true));
1344  }
1345  for (unsigned int i = 0; i < 3; ++i)
1346  {
1347  mitk::Vector3D wrongSpacing = aDummyGeometry->GetSpacing();
1348  wrongSpacing[i] -= mitk::eps * 2;
1349  auto wrongGeometry = aDummyGeometry->Clone();
1350  wrongGeometry->SetSpacing(wrongSpacing);
1351 
1352  CPPUNIT_ASSERT(!mitk::IsSubGeometry(*wrongGeometry, *aDummyGeometry, mitk::eps, true));
1353  }
1354  }
1355 
1356  void IsSubGeometry_TransformMatrix()
1357  {
1358  CPPUNIT_ASSERT(mitk::IsSubGeometry(*aDummyGeometry, *aDummyGeometry, mitk::eps, true));
1359 
1360  for (unsigned int i = 0; i < 3; ++i)
1361  {
1362  for (unsigned int j = 0; j < 3; ++j)
1363  {
1364  itk::Matrix<mitk::ScalarType, 3, 3> wrongMatrix = aDummyGeometry->GetIndexToWorldTransform()->GetMatrix();
1365  wrongMatrix[i][j] += mitk::eps * 2;
1366  auto wrongGeometry = aDummyGeometry->Clone();
1367  wrongGeometry->GetIndexToWorldTransform()->SetMatrix(wrongMatrix);
1368 
1369  CPPUNIT_ASSERT(!mitk::IsSubGeometry(*wrongGeometry, *aDummyGeometry, mitk::eps, true));
1370  }
1371  }
1372  }
1373 
1374  void IsSubGeometry_Bounds()
1375  {
1376  IsSubGeometry_Bounds_internal(false);
1377  IsSubGeometry_Bounds_internal(true);
1378  }
1379 
1380  void IsSubGeometry_Bounds_internal(bool isImage)
1381  {
1382  auto newBounds = aDummyGeometry->GetBounds();
1383  newBounds[0] = 10;
1384  newBounds[1] = 20;
1385  newBounds[2] = 10;
1386  newBounds[3] = 20;
1387  newBounds[4] = 10;
1388  newBounds[5] = 20;
1389  aDummyGeometry->SetBounds(newBounds);
1390  aDummyGeometry->SetImageGeometry(isImage);
1391 
1392  CPPUNIT_ASSERT(mitk::IsSubGeometry(*aDummyGeometry, *aDummyGeometry, mitk::eps, true));
1393 
1394  for (unsigned int i = 0; i < 6; ++i)
1395  {
1396  auto legalBounds = newBounds;
1397  if (i % 2 == 0)
1398  {
1399  legalBounds[i] += 1;
1400  }
1401  else
1402  {
1403  legalBounds[i] -= 1;
1404  }
1405  auto legalGeometry = aDummyGeometry->Clone();
1406  legalGeometry->SetBounds(legalBounds);
1407 
1408  CPPUNIT_ASSERT(mitk::IsSubGeometry(*legalGeometry, *aDummyGeometry, mitk::eps, true));
1409  }
1410 
1411  for (unsigned int i = 0; i < 6; ++i)
1412  {
1413  auto wrongBounds = aDummyGeometry->GetBounds();
1414  if (i % 2 == 0)
1415  {
1416  wrongBounds[i] -= 1;
1417  }
1418  else
1419  {
1420  wrongBounds[i] += 1;
1421  }
1422  auto wrongGeometry = aDummyGeometry->Clone();
1423  wrongGeometry->SetBounds(wrongBounds);
1424 
1425  CPPUNIT_ASSERT(!mitk::IsSubGeometry(*wrongGeometry, *aDummyGeometry, mitk::eps, true));
1426  }
1427  }
1428 
1429  void IsSubGeometry_Grid()
1430  {
1431  IsSubGeometry_Grid_internal(true);
1432  IsSubGeometry_Grid_internal(false);
1433  }
1434 
1435  void IsSubGeometry_Grid_internal(bool isImage)
1436  {
1437  auto newBounds = aDummyGeometry->GetBounds();
1438  newBounds[0] = 0;
1439  newBounds[1] = 20;
1440  newBounds[2] = 0;
1441  newBounds[3] = 20;
1442  newBounds[4] = 0;
1443  newBounds[5] = 20;
1444  aDummyGeometry->SetBounds(newBounds);
1445  aDummyGeometry->SetImageGeometry(isImage);
1446 
1447  auto smallerGeometry = aDummyGeometry->Clone();
1448  newBounds[0] = 5;
1449  newBounds[1] = 10;
1450  newBounds[2] = 5;
1451  newBounds[3] = 10;
1452  newBounds[4] = 5;
1453  newBounds[5] = 10;
1454  smallerGeometry->SetBounds(newBounds);
1455 
1456  //legal negative shift
1457  for (unsigned int i = 0; i < 3; ++i)
1458  {
1459  auto legalOrigin = smallerGeometry->GetOrigin();
1460  legalOrigin[i] -= smallerGeometry->GetSpacing()[i];
1461  auto legalGeometry = smallerGeometry->Clone();
1462  legalGeometry->SetOrigin(legalOrigin);
1463 
1464  CPPUNIT_ASSERT(mitk::IsSubGeometry(*legalGeometry, *aDummyGeometry, mitk::eps, true));
1465  }
1466 
1467  //legal positive shift
1468  for (unsigned int i = 0; i < 3; ++i)
1469  {
1470  auto legalOrigin = smallerGeometry->GetOrigin();
1471  legalOrigin[i] += smallerGeometry->GetSpacing()[i];
1472  auto legalGeometry = smallerGeometry->Clone();
1473  legalGeometry->SetOrigin(legalOrigin);
1474 
1475  CPPUNIT_ASSERT(mitk::IsSubGeometry(*legalGeometry, *aDummyGeometry, mitk::eps, true));
1476  }
1477 
1478  //wrong negative shift
1479  for (unsigned int i = 0; i < 3; ++i)
1480  {
1481  auto wrongOrigin = smallerGeometry->GetOrigin();
1482  wrongOrigin[i] -= 2 * mitk::eps;
1483  auto wrongGeometry = smallerGeometry->Clone();
1484  wrongGeometry->SetOrigin(wrongOrigin);
1485 
1486  CPPUNIT_ASSERT(!mitk::IsSubGeometry(*wrongGeometry, *aDummyGeometry, mitk::eps, true));
1487  }
1488 
1489  //wrong positive shift
1490  for (unsigned int i = 0; i < 3; ++i)
1491  {
1492  auto wrongOrigin = smallerGeometry->GetOrigin();
1493  wrongOrigin[i] += 2 * mitk::eps;
1494  auto wrongGeometry = smallerGeometry->Clone();
1495  wrongGeometry->SetOrigin(wrongOrigin);
1496 
1497  CPPUNIT_ASSERT(!mitk::IsSubGeometry(*wrongGeometry, *aDummyGeometry, mitk::eps, true));
1498  }
1499  }
1500 
1501 
1502  /*
1503 
1504  void (){
1505  DummyTestClass::Pointer dummy = DummyTestClass::New();
1506 
1507  CPPUNIT_ASSERT();
1508 
1509  //undo changes, new and changed object need to be the same!
1510 
1511  DummyTestClass::Pointer newDummy = DummyTestClass::New();
1512  CPPUNIT_ASSERT(mitk::Equal(dummy,newDummy,mitk::eps,true));
1513  }
1514 
1515  */
1516 }; // end class mitkBaseGeometryTestSuite
1517 
1518 MITK_TEST_SUITE_REGISTRATION(mitkBaseGeometry)
bool EqualArray(TArrayType1 &arrayType1, TArrayType2 &arrayType2, int size, ScalarType eps=mitk::eps, bool verbose=false)
Definition: mitkArray.h:128
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
MITKCORE_EXPORT bool IsSubGeometry(const mitk::BaseGeometry &testGeo, const mitk::BaseGeometry &referenceGeo, ScalarType eps, bool verbose)
A function checks if a test geometry is a sub geometry of a given reference geometry.
void GetRotation(const mitk::BaseGeometry *geometry, TMatrixType &itkmatrix)
#define mitkNewMacro1Param(classname, type)
Definition: mitkCommon.h:72
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.
Definition: mitkMatrix.h:140
void PrintSelf(std::ostream &os, itk::Indent indent) const override
Base class of all Operation-classes.
Definition: mitkOperation.h:29
vnl_vector< ScalarType > VnlVector
Definition: mitkVector.h:134
double ScalarType
Follow Up Storage - Class to facilitate loading/accessing structured follow-up data.
Definition: testcase.h:28
#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)
static Matrix3D rotation
void FillVector3D(Tout &out, mitk::ScalarType x, mitk::ScalarType y, mitk::ScalarType z)
Definition: mitkArray.h:106
itk::SmartPointer< Self > Pointer
#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.
An object of this class represents an exception of MITK. Please don&#39;t instantiate exceptions manually...
Definition: mitkException.h:45
#define mitkClassMacro(className, SuperClassName)
Definition: mitkCommon.h:40
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)
itk::LightObject::Pointer InternalClone() const override=0
clones the geometry
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