Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkTimeGeometryTest.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,
6 Division of Medical and Biological Informatics.
7 All rights reserved.
8 
9 This software is distributed WITHOUT ANY WARRANTY; without
10 even the implied warranty of MERCHANTABILITY or FITNESS FOR
11 A PARTICULAR PURPOSE.
12 
13 See LICENSE.txt or http://www.mitk.org for details.
14 
15 ===================================================================*/
16 
17 #include "mitkGeometry3D.h"
18 #include "mitkTimeGeometry.h"
19 
20 #include "mitkInteractionConst.h"
21 #include "mitkRotationOperation.h"
22 #include <mitkImageCast.h>
23 #include <mitkMatrixConvert.h>
24 
25 #include "mitkTestingMacros.h"
26 #include <fstream>
27 #include <mitkVector.h>
28 
29 #include "mitkImageGenerator.h"
30 #include "mitkPointSet.h"
31 #include <limits>
33 
34 static const mitk::ScalarType test_eps = 1E-6; /* some reference values in the test seem
35 to have been calculated with float precision. Thus, set this to float precision epsilon.*/
36 static const mitk::ScalarType test_eps_square = 1E-3;
37 
38 class mitkTimeGeometryTestClass
39 {
40 public:
41  void Translation_Image_MovedOrigin(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT)
42  {
43  // DimX, DimY, DimZ,
44  mitk::Image::Pointer image =
45  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
46  mitk::BaseGeometry::Pointer geometry = image->GetTimeGeometry()->GetGeometryForTimeStep(0);
47  mitk::Point3D imageOrigin = geometry->GetOrigin();
48  mitk::Point3D expectedOrigin;
49  expectedOrigin[0] = 0;
50  expectedOrigin[1] = 0;
51  expectedOrigin[2] = 0;
52  MITK_TEST_CONDITION(mitk::Equal(imageOrigin, expectedOrigin), "Original origin match expected origin");
53 
54  expectedOrigin[0] = 0.325;
55  expectedOrigin[1] = 0.487;
56  expectedOrigin[2] = 0.78;
57 
58  mitk::Vector3D translationVector;
59  translationVector[0] = expectedOrigin[0];
60  translationVector[1] = expectedOrigin[1];
61  translationVector[2] = expectedOrigin[2];
62 
63  for (mitk::TimeStepType timeStep = 0; timeStep < image->GetTimeGeometry()->CountTimeSteps(); ++timeStep)
64  {
65  image->GetTimeGeometry()->GetGeometryForTimeStep(timeStep)->Translate(translationVector);
66  }
67  imageOrigin = image->GetGeometry(0)->GetOrigin();
68  MITK_TEST_CONDITION(mitk::Equal(imageOrigin, expectedOrigin), "Translated origin match expected origin");
69 
70  expectedOrigin[0] = 2 * translationVector[0];
71  expectedOrigin[1] = 2 * translationVector[1];
72  expectedOrigin[2] = 2 * translationVector[2];
73 
74  for (mitk::TimeStepType timeStep = 0; timeStep < image->GetTimeGeometry()->CountTimeSteps(); ++timeStep)
75  {
76  image->GetTimeGeometry()->GetGeometryForTimeStep(timeStep)->Translate(translationVector);
77  }
78  imageOrigin = image->GetGeometry(0)->GetOrigin();
79  MITK_TEST_CONDITION(mitk::Equal(imageOrigin, expectedOrigin), "Translated origin match expected origin");
80  }
81 
82  void Rotate_Image_RotatedPoint(mitk::BaseData *baseData,
83  unsigned int /*DimX*/,
84  unsigned int /*DimY*/,
85  unsigned int /*DimZ*/,
86  unsigned int /*DimT*/)
87  {
90 
91  // DimX, DimY, DimZ,
92  dataNode->SetData(baseData);
93  ds->Add(dataNode);
95  mitk::Point3D expectedPoint;
96  expectedPoint[0] = 3 * 0.5;
97  expectedPoint[1] = 3 * 0.33;
98  expectedPoint[2] = 3 * 0.78;
100  originalPoint[0] = 3;
101  originalPoint[1] = 3;
102  originalPoint[2] = 3;
103  mitk::Point3D worldPoint;
104  geometry->IndexToWorld(originalPoint, worldPoint);
105  MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint, test_eps),
106  "Index-to-World without rotation as expected ");
107 
108  mitk::Point3D pointOfRotation;
109  pointOfRotation[0] = 0;
110  pointOfRotation[1] = 0;
111  pointOfRotation[2] = 0;
112  mitk::Vector3D vectorOfRotation;
113  vectorOfRotation[0] = 1;
114  vectorOfRotation[1] = 0.5;
115  vectorOfRotation[2] = 0.2;
116  mitk::ScalarType angleOfRotation = 73.0;
117  auto rotation = new mitk::RotationOperation(mitk::OpROTATE, pointOfRotation, vectorOfRotation, angleOfRotation);
118 
120  delete rotation;
121 
122  expectedPoint[0] = 2.6080379;
123  expectedPoint[1] = -0.75265157;
124  expectedPoint[2] = 1.1564401;
125 
126  baseData->GetGeometry(0)->IndexToWorld(originalPoint, worldPoint);
127  MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint, test_eps), "Rotation returns expected values ");
128  }
129 
130  void Scale_Image_ScaledPoint(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT)
131  {
132  // DimX, DimY, DimZ,
133  mitk::Image::Pointer image =
134  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
135  mitk::BaseGeometry::Pointer geometry = image->GetTimeGeometry()->GetGeometryForTimeStep(0);
136  mitk::Point3D expectedPoint;
137  expectedPoint[0] = 3 * 0.5;
138  expectedPoint[1] = 3 * 0.33;
139  expectedPoint[2] = 3 * 0.78;
141  originalPoint[0] = 3;
142  originalPoint[1] = 3;
143  originalPoint[2] = 3;
144  mitk::Point3D worldPoint;
145  geometry->IndexToWorld(originalPoint, worldPoint);
146  MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint, test_eps),
147  "Index-to-World with old Scaling as expected ");
148 
149  mitk::Vector3D newSpacing;
150  newSpacing[0] = 2;
151  newSpacing[1] = 1.254;
152  newSpacing[2] = 0.224;
153  image->SetSpacing(newSpacing);
154  expectedPoint[0] = 3 * 2;
155  expectedPoint[1] = 3 * 1.254;
156  expectedPoint[2] = 3 * 0.224;
157 
158  image->GetGeometry(0)->IndexToWorld(originalPoint, worldPoint);
159  MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint),
160  "Index-toWorld with new Scaling returns expected values ");
161  }
162 
163  void GetMinimumTimePoint_4DBaseData_Zero(mitk::BaseData *baseData, unsigned int /*DimT*/)
164  {
165  baseData->Update();
166  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
167  mitk::TimePointType expectedTimePoint = geometry->GetMinimumTimePoint();
168  MITK_TEST_CONDITION(mitk::Equal(expectedTimePoint, 0), "Returns correct minimum time point ");
169  }
170 
171  void GetMaximumTimePoint_4DBaseData_DimT(mitk::BaseData *baseData, unsigned int DimT)
172  {
173  baseData->Update();
174  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
175  mitk::TimePointType expectedTimePoint = geometry->GetMaximumTimePoint();
176  MITK_TEST_CONDITION(mitk::Equal(expectedTimePoint, DimT), "Returns correct maximum time point ");
177  }
178 
179  void CountTimeSteps_Image_ReturnDimT(
180  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
181  {
182  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
183  mitk::TimeStepType expectedTimeSteps = geometry->CountTimeSteps();
184  MITK_TEST_CONDITION(mitk::Equal(expectedTimeSteps, DimT), "Returns correct number of time Steps ");
185  }
186 
187  void GetMinimumTimePoint_3DImage_Min(mitk::BaseData *baseData,
188  unsigned int /*DimX*/,
189  unsigned int /*DimY*/,
190  unsigned int /*DimZ*/,
191  unsigned int /*DimT*/)
192  {
193  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
194  mitk::TimePointType expectedTimePoint = geometry->GetMinimumTimePoint();
195  MITK_TEST_CONDITION(mitk::Equal(expectedTimePoint, -std::numeric_limits<mitk::TimePointType>().max()),
196  "Returns correct minimum time point ");
197  }
198 
199  void GetMaximumTimePoint_3DImage_Max(mitk::BaseData *baseData,
200  unsigned int /*DimX*/,
201  unsigned int /*DimY*/,
202  unsigned int /*DimZ*/,
203  unsigned int /*DimT*/)
204  {
205  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
206  mitk::TimePointType expectedTimePoint = geometry->GetMaximumTimePoint();
207  MITK_INFO << expectedTimePoint;
208  MITK_INFO << std::numeric_limits<mitk::TimePointType>().max();
209  MITK_TEST_CONDITION(mitk::Equal(expectedTimePoint, std::numeric_limits<mitk::TimePointType>().max()),
210  "Returns correct maximum time point ");
211  }
212 
213  void GetTimeBounds_4DImage_ZeroAndDimT(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT)
214  {
215  mitk::Image::Pointer image =
216  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
217  mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry();
218  mitk::TimeBounds expectedTimeBounds = geometry->GetTimeBounds();
219  MITK_TEST_CONDITION(mitk::Equal(expectedTimeBounds[0], 0), "Returns correct minimum time point ");
220  MITK_TEST_CONDITION(mitk::Equal(expectedTimeBounds[1], DimT), "Returns correct maximum time point ");
221  }
222 
223  void GetTimeBounds_3DImage_ZeroAndDimT(mitk::BaseData *baseData,
224  unsigned int /*DimX*/,
225  unsigned int /*DimY*/,
226  unsigned int /*DimZ*/,
227  unsigned int /*DimT*/)
228  {
229  baseData->Update();
230  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
231  mitk::TimeBounds expectedTimeBounds = geometry->GetTimeBounds();
232  MITK_TEST_CONDITION(mitk::Equal(expectedTimeBounds[0], -std::numeric_limits<mitk::TimePointType>().max()),
233  "Returns correct minimum time point ");
234  MITK_TEST_CONDITION(mitk::Equal(expectedTimeBounds[1], std::numeric_limits<mitk::TimePointType>().max()),
235  "Returns correct maximum time point ");
236  }
237 
238  void IsValidTimePoint_ImageValidTimePoint_True(
239  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
240  {
241  baseData->Update();
242  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
243  bool isValid = geometry->IsValidTimePoint(DimT - 1);
244  MITK_TEST_CONDITION(mitk::Equal(isValid, true), "Is valid time Point correct minimum time point ");
245  }
246 
247  void IsValidTimePoint_ImageNegativInvalidTimePoint_False(unsigned int DimX,
248  unsigned int DimY,
249  unsigned int DimZ,
250  unsigned int DimT)
251  {
252  mitk::Image::Pointer image =
253  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
254  mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry();
255  bool isValid = geometry->IsValidTimePoint(-DimT);
256  MITK_TEST_CONDITION(mitk::Equal(isValid, false), "Is invalid time Point correct minimum time point ");
257  }
258 
259  void IsValidTimePoint_ImageInvalidTimePoint_False(unsigned int DimX,
260  unsigned int DimY,
261  unsigned int DimZ,
262  unsigned int DimT)
263  {
264  mitk::Image::Pointer image =
265  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
266  mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry();
267  bool isValid = geometry->IsValidTimePoint(DimT + 1);
268  MITK_TEST_CONDITION(mitk::Equal(isValid, false), "Is invalid time Point correct minimum time point ");
269  }
270 
271  void IsValidTimeStep_ImageValidTimeStep_True(
272  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
273  {
274  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
275  bool isValid = geometry->IsValidTimeStep(DimT - 1);
276  MITK_TEST_CONDITION(mitk::Equal(isValid, true), "Is valid time Point correct minimum time point ");
277  }
278 
279  void IsValidTimeStep_ImageNegativInvalidTimeStep_False(
280  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
281  {
282  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
283  bool isValid = geometry->IsValidTimeStep(-DimT);
284  MITK_TEST_CONDITION(mitk::Equal(isValid, false), "Is invalid time Point correct minimum time point ");
285  }
286 
287  void IsValidTimeStep_ImageInvalidTimeStep_False(
288  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
289  {
290  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
291  bool isValid = geometry->IsValidTimeStep(DimT);
292  MITK_TEST_CONDITION(mitk::Equal(isValid, false), "Is invalid time Point correct minimum time point ");
293  }
294 
295  void TimeStepToTimePoint_ImageValidTimeStep_TimePoint(
296  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
297  {
298  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
299  mitk::TimePointType timePoint = geometry->TimeStepToTimePoint(DimT - 1);
300  MITK_TEST_CONDITION(mitk::Equal(timePoint, DimT - 1), "Calculated right time Point for Time Step ");
301  }
302 
303  void TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(
304  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
305  {
306  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
307  mitk::TimePointType timePoint = geometry->TimeStepToTimePoint(DimT + 1);
308  MITK_TEST_CONDITION(mitk::Equal(timePoint, DimT + 1), "Calculated right time Point for invalid Time Step ");
309  }
310 
311  void TimePointToTimeStep_ImageValidTimePoint_TimePoint(
312  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
313  {
314  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
315  mitk::TimeStepType timePoint = geometry->TimePointToTimeStep(DimT - 0.5);
316  MITK_TEST_CONDITION(mitk::Equal(timePoint, DimT - 1), "Calculated right time step for valid time point");
317  }
318 
319  void TimePointToTimeStep_4DImageInvalidTimePoint_TimePoint(unsigned int DimX,
320  unsigned int DimY,
321  unsigned int DimZ,
322  unsigned int DimT)
323  {
324  mitk::Image::Pointer image =
325  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
326  mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry();
327  mitk::TimeStepType timePoint = geometry->TimePointToTimeStep(DimT + 1.5);
328  MITK_TEST_CONDITION(mitk::Equal(timePoint, DimT + 1), "Calculated right time step for invalid time point");
329  }
330 
331  void TimePointToTimeStep_4DImageNegativInvalidTimePoint_TimePoint(unsigned int DimX,
332  unsigned int DimY,
333  unsigned int DimZ,
334  unsigned int DimT)
335  {
336  mitk::Image::Pointer image =
337  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
338  mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry();
339  mitk::TimePointType negativTimePoint = (-1.0 * DimT) - 1.5;
340  mitk::TimeStepType timePoint = geometry->TimePointToTimeStep(negativTimePoint);
341  MITK_TEST_CONDITION(mitk::Equal(timePoint, 0), "Calculated right time step for negativ invalid time point");
342  }
343 
344  void GetGeometryForTimeStep_BaseDataValidTimeStep_CorrectGeometry(mitk::BaseData *baseData,
345  mitk::ScalarType inputX,
346  mitk::ScalarType inputY,
347  mitk::ScalarType inputZ,
348  mitk::ScalarType outputX,
349  mitk::ScalarType outputY,
350  mitk::ScalarType outputZ,
351  unsigned int DimT)
352  {
353  baseData->Update();
354  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
355  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryForTimeStep(DimT - 1);
356  MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry returned");
357 
358  mitk::Point3D expectedPoint;
359  expectedPoint[0] = outputX;
360  expectedPoint[1] = outputY;
361  expectedPoint[2] = outputZ;
363  originalPoint[0] = inputX;
364  originalPoint[1] = inputY;
365  originalPoint[2] = inputZ;
366  mitk::Point3D worldPoint;
367  geometry3D->IndexToWorld(originalPoint, worldPoint);
368  MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint, test_eps), "Geometry transformation match expection. ");
369  }
370 
371  void GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(
372  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
373  {
374  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
375  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryForTimeStep(DimT + 1);
376  MITK_TEST_CONDITION(geometry3D.IsNull(), "Null-Pointer geometry returned");
377  }
378 
379  void GetGeometryForTimePoint_BaseDataValidTimePoint_CorrectGeometry(mitk::BaseData *baseData,
380  mitk::ScalarType inputX,
381  mitk::ScalarType inputY,
382  mitk::ScalarType inputZ,
383  mitk::ScalarType outputX,
384  mitk::ScalarType outputY,
385  mitk::ScalarType outputZ,
386  unsigned int DimT)
387  {
388  baseData->Update();
389  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
390  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryForTimePoint(DimT - 0.5);
391  MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry returned");
392 
393  mitk::Point3D expectedPoint;
394  expectedPoint[0] = outputX;
395  expectedPoint[1] = outputY;
396  expectedPoint[2] = outputZ;
398  originalPoint[0] = inputX;
399  originalPoint[1] = inputY;
400  originalPoint[2] = inputZ;
401  mitk::Point3D worldPoint;
402  geometry3D->IndexToWorld(originalPoint, worldPoint);
403  MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint, test_eps), "Geometry transformation match expection. ");
404  }
405 
406  void GetGeometryForTimePoint_4DImageInvalidTimePoint_NullPointer(unsigned int DimX,
407  unsigned int DimY,
408  unsigned int DimZ,
409  unsigned int DimT)
410  {
411  mitk::Image::Pointer image =
412  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
413  mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry();
414  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryForTimePoint(DimT + 1);
415  MITK_TEST_CONDITION(geometry3D.IsNull(), "Null-Pointer geometry returned with invalid time point");
416  }
417 
418  void GetGeometryForTimePoint_4DImageNEgativInvalidTimePoint_NullPointer(unsigned int DimX,
419  unsigned int DimY,
420  unsigned int DimZ,
421  unsigned int DimT)
422  {
423  mitk::Image::Pointer image =
424  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
425  mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry();
426  mitk::TimePointType timePoint = (-1.0 * (DimT)) - 1;
427  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryForTimePoint(timePoint);
428  MITK_TEST_CONDITION(geometry3D.IsNull(), "Null-Pointer geometry returned with invalid negativ time point");
429  }
430 
431  void GetGeometryCloneForTimeStep_BaseDataValidTimeStep_CorrectGeometry(mitk::BaseData *baseData, unsigned int DimT)
432  {
433  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
434  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryCloneForTimeStep(DimT - 1);
435  MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry returned");
436 
437  mitk::Point3D expectedPoint;
439  originalPoint[0] = 3;
440  originalPoint[1] = 3;
441  originalPoint[2] = 3;
442  mitk::Point3D worldPoint;
443  geometry3D->IndexToWorld(originalPoint, expectedPoint);
444 
445  mitk::Vector3D translationVector;
446  translationVector[0] = 5;
447  translationVector[1] = 8;
448  translationVector[2] = 7;
449  geometry3D->Translate(translationVector);
450 
451  geometry3D = geometry->GetGeometryForTimeStep(DimT - 1);
452  geometry3D->IndexToWorld(originalPoint, worldPoint);
453  MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint), "Geometry transformation not changed. ");
454  }
455 
456  void GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(
457  mitk::BaseData *baseData, unsigned int /*DimX*/, unsigned int /*DimY*/, unsigned int /*DimZ*/, unsigned int DimT)
458  {
459  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
460  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryCloneForTimeStep(DimT + 1);
461  MITK_TEST_CONDITION(geometry3D.IsNull(), "Null-Pointer geometry returned");
462  }
463 
464  void SetTimeStepGeometry_BaseDataValidTimeStep_CorrectGeometry(mitk::BaseData *baseData,
465  mitk::ScalarType scaleX,
466  mitk::ScalarType scaleY,
467  mitk::ScalarType scaleZ,
468  unsigned int DimT)
469  {
470  baseData->Update();
471  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
472  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryCloneForTimeStep(DimT - 1);
473  MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry returned");
474 
475  mitk::Vector3D translationVector;
476  translationVector[0] = 5;
477  translationVector[1] = 8;
478  translationVector[2] = 7;
479  geometry3D->Translate(translationVector);
480 
481  geometry->SetTimeStepGeometry(geometry3D, DimT - 1);
482 
483  mitk::Point3D expectedPoint;
484  expectedPoint[0] = 3 * scaleX + 5;
485  expectedPoint[1] = 3 * scaleY + 8;
486  expectedPoint[2] = 3 * scaleZ + 7;
488  originalPoint[0] = 3;
489  originalPoint[1] = 3;
490  originalPoint[2] = 3;
491  mitk::Point3D worldPoint;
492  geometry->GetGeometryForTimeStep(DimT - 1)->IndexToWorld(originalPoint, worldPoint);
493  MITK_TEST_CONDITION(mitk::Equal(worldPoint, expectedPoint, test_eps), "Geometry transformation match expection. ");
494  }
495 
496  void Expand_BaseDataDoubleSize_SizeChanged(mitk::BaseData *baseData, unsigned int DimT)
497  {
498  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
499  MITK_TEST_CONDITION(geometry->CountTimeSteps() == DimT, "Number of time Steps match expection. ");
500 
501  geometry->Expand(DimT * 2);
502  MITK_TEST_CONDITION(geometry->CountTimeSteps() == DimT * 2, "Number of time Steps match expection. ");
503 
504  mitk::BaseGeometry::Pointer geometry3D = geometry->GetGeometryForTimeStep(DimT * 2 - 1);
505  MITK_TEST_CONDITION(geometry3D.IsNotNull(), "Non-zero geometry is generated. ");
506  }
507 
508  void CheckBounds_BaseData_PointsAsExpected(mitk::BaseData *baseData,
509  mitk::ScalarType minX,
510  mitk::ScalarType minY,
511  mitk::ScalarType minZ,
512  mitk::ScalarType maxX,
513  mitk::ScalarType maxY,
514  mitk::ScalarType maxZ)
515  {
516  baseData->Update();
517  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
518 
519  mitk::Point3D expectedPoint;
520 
521  expectedPoint[0] = minX;
522  expectedPoint[1] = minY;
523  expectedPoint[2] = minZ;
524  mitk::Point3D point = geometry->GetCornerPointInWorld(0);
525  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 0 as expected ");
526  point = geometry->GetCornerPointInWorld(true, true, true);
527  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 0 as expected ");
528 
529  point = geometry->GetCornerPointInWorld(1);
530  expectedPoint[0] = minX;
531  expectedPoint[1] = minY;
532  expectedPoint[2] = maxZ;
533  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "GBounding Point 1 as expected ");
534  point = geometry->GetCornerPointInWorld(true, true, false);
535  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 1 as expected ");
536 
537  point = geometry->GetCornerPointInWorld(2);
538  expectedPoint[0] = minX;
539  expectedPoint[1] = maxY;
540  expectedPoint[2] = minZ;
541  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 2 as expected ");
542  point = geometry->GetCornerPointInWorld(true, false, true);
543  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 2 as expected ");
544 
545  point = geometry->GetCornerPointInWorld(3);
546  expectedPoint[0] = minX;
547  expectedPoint[1] = maxY;
548  expectedPoint[2] = maxZ;
549  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 3 as expected ");
550  point = geometry->GetCornerPointInWorld(true, false, false);
551  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 3 as expected ");
552 
553  point = geometry->GetCornerPointInWorld(4);
554  expectedPoint[0] = maxX;
555  expectedPoint[1] = minY;
556  expectedPoint[2] = minZ;
557  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 4 as expected ");
558  point = geometry->GetCornerPointInWorld(false, true, true);
559  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 4 as expected ");
560 
561  point = geometry->GetCornerPointInWorld(5);
562  expectedPoint[0] = maxX;
563  expectedPoint[1] = minY;
564  expectedPoint[2] = maxZ;
565  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 5 as expected ");
566  point = geometry->GetCornerPointInWorld(false, true, false);
567  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 5 as expected ");
568 
569  point = geometry->GetCornerPointInWorld(6);
570  expectedPoint[0] = maxX;
571  expectedPoint[1] = maxY;
572  expectedPoint[2] = minZ;
573  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 6 as expected ");
574  point = geometry->GetCornerPointInWorld(false, false, true);
575  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 6 as expected ");
576 
577  point = geometry->GetCornerPointInWorld(7);
578  expectedPoint[0] = maxX;
579  expectedPoint[1] = maxY;
580  expectedPoint[2] = maxZ;
581  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 7 as expected ");
582  point = geometry->GetCornerPointInWorld(false, false, false);
583  MITK_TEST_CONDITION(mitk::Equal(expectedPoint, point, test_eps), "Bounding Point 7 as expected ");
584  }
585 
586  void CheckLength_BaseData_AsExpected(mitk::BaseData *baseData, double length, double squareLength)
587  {
588  baseData->Update();
589  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
590 
591  double dimension = geometry->GetDiagonalLengthInWorld();
592  MITK_TEST_CONDITION(mitk::Equal(dimension, length, test_eps), "Length as expected ");
593 
594  dimension = geometry->GetDiagonalLength2InWorld();
595  MITK_TEST_CONDITION(mitk::Equal(dimension, squareLength, test_eps_square), "Square length as expected ");
596  }
597 
598  void CheckPointInside_BaseDataPointInside_True(mitk::BaseData *baseData,
599  mitk::ScalarType pointX,
600  mitk::ScalarType pointY,
601  mitk::ScalarType pointZ)
602  {
603  baseData->Update();
604  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
605 
606  mitk::Point3D expectedPoint;
607 
608  expectedPoint[0] = pointX;
609  expectedPoint[1] = pointY;
610  expectedPoint[2] = pointZ;
611  bool isInside = geometry->IsWorldPointInside(expectedPoint);
612  MITK_TEST_CONDITION(isInside, "Point is inside Image...");
613  }
614 
615  void CheckPointInside_BaseDataPointOutside_False(mitk::BaseData *baseData,
616  mitk::ScalarType pointX,
617  mitk::ScalarType pointY,
618  mitk::ScalarType pointZ)
619  {
620  baseData->Update();
621  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
622 
623  mitk::Point3D expectedPoint;
624 
625  expectedPoint[0] = pointX;
626  expectedPoint[1] = pointY;
627  expectedPoint[2] = pointZ;
628  bool isInside = geometry->IsWorldPointInside(expectedPoint);
629  MITK_TEST_CONDITION(!isInside, "Point is outside Image...");
630  }
631 
632  void CheckBounds_Image_AsSet(unsigned int DimX, unsigned int DimY, unsigned int DimZ, unsigned int DimT)
633  {
634  mitk::Image::Pointer image =
635  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(DimX, DimY, DimZ, DimT, 0.5, 0.33, 0.78, 100);
636  mitk::TimeGeometry::Pointer geometry = image->GetTimeGeometry();
637 
638  mitk::BoundingBox::BoundsArrayType bound = geometry->GetBoundsInWorld();
639  bool isEqual = true;
640  isEqual = isEqual && mitk::Equal(bound[0], -0.5 * 0.5, test_eps);
641  isEqual = isEqual && mitk::Equal(bound[1], 29.5 * 0.5, test_eps);
642  isEqual = isEqual && mitk::Equal(bound[2], -0.5 * 0.33, test_eps);
643  isEqual = isEqual && mitk::Equal(bound[3], 24.5 * 0.33, test_eps);
644  isEqual = isEqual && mitk::Equal(bound[4], -0.5 * 0.78, test_eps);
645  isEqual = isEqual && mitk::Equal(bound[5], 19.5 * 0.78, test_eps);
646 
647  MITK_TEST_CONDITION(isEqual, "Bounds as precalculated...");
648  }
649 
650  void CheckBounds_BaseData_AsSet(mitk::BaseData *baseData,
651  mitk::ScalarType minBoundX,
652  mitk::ScalarType maxBoundX,
653  mitk::ScalarType minBoundY,
654  mitk::ScalarType maxBoundY,
655  mitk::ScalarType minBoundZ,
656  mitk::ScalarType maxBoundZ)
657  {
658  baseData->Update();
659  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
660 
661  mitk::BoundingBox::BoundsArrayType bound = geometry->GetBoundsInWorld();
662  bool isEqual = true;
663  isEqual = isEqual && mitk::Equal(bound[0], minBoundX);
664  isEqual = isEqual && mitk::Equal(bound[1], maxBoundX);
665  isEqual = isEqual && mitk::Equal(bound[2], minBoundY);
666  isEqual = isEqual && mitk::Equal(bound[3], maxBoundY);
667  isEqual = isEqual && mitk::Equal(bound[4], minBoundZ);
668  isEqual = isEqual && mitk::Equal(bound[5], maxBoundZ);
669 
670  MITK_TEST_CONDITION(isEqual, "Bounds as precalculated...");
671  }
672 
673  void CheckExtent_BaseData_AsSet(mitk::BaseData *baseData, double extentX, double extentY, double extentZ)
674  {
675  baseData->Update();
676  mitk::TimeGeometry::Pointer geometry = baseData->GetTimeGeometry();
677 
678  bool isEqual = true;
679  isEqual = isEqual && mitk::Equal(geometry->GetExtentInWorld(0), extentX, test_eps); // 30*0.5);
680  isEqual = isEqual && mitk::Equal(geometry->GetExtentInWorld(1), extentY, test_eps); // 25*0.33);
681  isEqual = isEqual && mitk::Equal(geometry->GetExtentInWorld(2), extentZ, test_eps); // 20*0.78);
682 
683  MITK_TEST_CONDITION(isEqual, "Extent as precalculated...");
684  }
685 
686  mitk::PointSet::Pointer makePointset()
687  {
689  mitk::Point3D pointA, pointB, pointC;
690  pointA.Fill(1);
691  pointB.Fill(2);
692  pointC.Fill(3);
693  pointSet->SetPoint(1, pointA);
694  pointSet->SetPoint(2, pointB);
695  pointSet->SetPoint(3, pointC);
696  pointSet->Update();
697  MITK_INFO << pointSet->GetPoint(0);
698  MITK_INFO << pointSet->GetPoint(1);
699  MITK_INFO << pointSet->GetPoint(2);
700  MITK_INFO << pointSet->GetPoint(3);
701 
702  mitk::PointSet::Pointer pointSet2 = pointSet->Clone();
703  MITK_INFO << pointSet2->GetPoint(0);
704  MITK_INFO << pointSet2->GetPoint(1);
705  MITK_INFO << pointSet2->GetPoint(2);
706  MITK_INFO << pointSet2->GetPoint(3);
707 
708  return pointSet;
709  }
710 };
711 
712 int mitkTimeGeometryTest(int /*argc*/, char * /*argv*/ [])
713 {
715 
716  mitkTimeGeometryTestClass testClass;
717 
718  MITK_TEST_OUTPUT(<< "Test for 3D image");
719  mitk::Image::Pointer image =
720  mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(30, 25, 20, 1, 0.5, 0.33, 0.78, 100);
721  testClass.Translation_Image_MovedOrigin(30, 25, 20, 1);
722  testClass.Rotate_Image_RotatedPoint(image->Clone(), 30, 25, 20, 1);
723  testClass.Scale_Image_ScaledPoint(30, 25, 20, 1);
724  testClass.CountTimeSteps_Image_ReturnDimT(image->Clone(), 30, 25, 20, 1);
725  testClass.GetMinimumTimePoint_3DImage_Min(image->Clone(), 30, 25, 20, 1);
726  testClass.GetMaximumTimePoint_3DImage_Max(image->Clone(), 30, 25, 20, 1);
727  testClass.GetTimeBounds_3DImage_ZeroAndDimT(image->Clone(), 30, 25, 20, 1);
728  testClass.IsValidTimePoint_ImageValidTimePoint_True(image->Clone(), 30, 25, 20, 1);
729  testClass.IsValidTimeStep_ImageValidTimeStep_True(image->Clone(), 30, 25, 20, 1);
730  testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(image->Clone(), 30, 25, 20, 1);
731  testClass.IsValidTimeStep_ImageInvalidTimeStep_False(image->Clone(), 30, 25, 20, 1);
732  testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(image->Clone(), 30, 25, 20, 1);
733  testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(image->Clone(), 30, 25, 20, 1);
734  testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(image->Clone(), 30, 25, 20, 1);
735  testClass.GetGeometryForTimeStep_BaseDataValidTimeStep_CorrectGeometry(
736  image->Clone(), 3, 3, 3, 3 * 0.5, 3 * 0.33, 3 * 0.78, 1);
737  testClass.GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(image->Clone(), 30, 25, 20, 1);
738  testClass.GetGeometryForTimePoint_BaseDataValidTimePoint_CorrectGeometry(
739  image->Clone(), 3, 3, 3, 3 * 0.5, 3 * 0.33, 3 * 0.78, 1);
740  testClass.GetGeometryCloneForTimeStep_BaseDataValidTimeStep_CorrectGeometry(image->Clone(), 1);
741  testClass.GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(image->Clone(), 30, 25, 20, 1);
742  testClass.SetTimeStepGeometry_BaseDataValidTimeStep_CorrectGeometry(image->Clone(), 0.5, 0.33, 0.78, 1);
743  testClass.Expand_BaseDataDoubleSize_SizeChanged(image->Clone(), 1);
744  testClass.CheckBounds_BaseData_PointsAsExpected(
745  image->Clone(), -0.5 * 0.5, -0.5 * 0.33, -0.5 * 0.78, 29.5 * 0.5, 24.5 * 0.33, 19.5 * 0.78);
746  testClass.CheckLength_BaseData_AsExpected(image->Clone(), 23.160796233014466, 536.42248214721712);
747  testClass.CheckPointInside_BaseDataPointInside_True(image->Clone(), 10, 5, 5);
748  testClass.CheckPointInside_BaseDataPointOutside_False(image->Clone(), 100, 500, 100);
749  testClass.CheckBounds_Image_AsSet(30, 25, 20, 1);
750  testClass.CheckExtent_BaseData_AsSet(image->Clone(), 30 * 0.5, 25 * 0.33, 20 * 0.78);
751 
752  MITK_TEST_OUTPUT(<< "Test for 2D image");
753  image = mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(30, 25, 1, 1, 0.5, 0.33, 0.78, 100);
754  testClass.Translation_Image_MovedOrigin(30, 25, 1, 1);
755  testClass.Rotate_Image_RotatedPoint(image->Clone(), 30, 25, 1, 1);
756  testClass.Scale_Image_ScaledPoint(30, 25, 1, 1);
757  testClass.CountTimeSteps_Image_ReturnDimT(image->Clone(), 30, 25, 1, 1);
758  testClass.GetMinimumTimePoint_3DImage_Min(image->Clone(), 30, 25, 1, 1);
759  testClass.GetMaximumTimePoint_3DImage_Max(image->Clone(), 30, 25, 1, 1);
760  testClass.GetTimeBounds_3DImage_ZeroAndDimT(image->Clone(), 30, 25, 1, 1);
761  testClass.IsValidTimePoint_ImageValidTimePoint_True(image->Clone(), 30, 25, 1, 1);
762  testClass.IsValidTimeStep_ImageValidTimeStep_True(image->Clone(), 30, 25, 1, 1);
763  testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(image->Clone(), 30, 25, 1, 1);
764  testClass.IsValidTimeStep_ImageInvalidTimeStep_False(image->Clone(), 30, 25, 1, 1);
765  testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(image->Clone(), 30, 25, 1, 1);
766  testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(image->Clone(), 30, 25, 1, 1);
767  testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(image->Clone(), 30, 25, 1, 1);
768  testClass.GetGeometryForTimeStep_BaseDataValidTimeStep_CorrectGeometry(
769  image->Clone(), 3, 3, 3, 3 * 0.5, 3 * 0.33, 3 * 0.78, 1);
770  testClass.GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(image->Clone(), 30, 25, 1, 1);
771  testClass.GetGeometryForTimePoint_BaseDataValidTimePoint_CorrectGeometry(
772  image->Clone(), 3, 3, 3, 3 * 0.5, 3 * 0.33, 3 * 0.78, 1);
773  testClass.GetGeometryCloneForTimeStep_BaseDataValidTimeStep_CorrectGeometry(image->Clone(), 1);
774  testClass.GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(image->Clone(), 30, 25, 1, 1);
775  testClass.SetTimeStepGeometry_BaseDataValidTimeStep_CorrectGeometry(image->Clone(), 0.5, 0.33, 0.78, 1);
776  testClass.Expand_BaseDataDoubleSize_SizeChanged(image->Clone(), 1);
777  testClass.CheckBounds_BaseData_PointsAsExpected(
778  image->Clone(), -0.5 * 0.5, -0.5 * 0.33, -0.5 * 0.78, 29.5 * 0.5, 24.5 * 0.33, 0.5 * 0.78);
779  testClass.CheckLength_BaseData_AsExpected(image->Clone(), 17.1368287615, 293.6709);
780  testClass.CheckPointInside_BaseDataPointInside_True(image->Clone(), 10, 5, 0);
781  testClass.CheckPointInside_BaseDataPointOutside_False(image->Clone(), 100, 500, 0.5);
782  testClass.CheckExtent_BaseData_AsSet(image->Clone(), 30 * 0.5, 25 * 0.33, 1 * 0.78);
783 
784  MITK_TEST_OUTPUT(<< "Test for 3D+time image");
785  image = mitk::ImageGenerator::GenerateRandomImage<mitk::ScalarType>(30, 25, 20, 5, 0.5, 0.33, 0.78, 100);
786  testClass.Translation_Image_MovedOrigin(30, 25, 20, 5); // Test with 3D+t-Image
787  testClass.Rotate_Image_RotatedPoint(image->Clone(), 30, 25, 20, 5); // Test with 3D+t-Image
788  testClass.Scale_Image_ScaledPoint(30, 25, 20, 5); // Test with 3D+t-Image
789  testClass.CountTimeSteps_Image_ReturnDimT(image->Clone(), 30, 25, 20, 5);
790  testClass.GetMinimumTimePoint_4DBaseData_Zero(image->Clone(), 5);
791  testClass.GetMaximumTimePoint_4DBaseData_DimT(image->Clone(), 5);
792  testClass.GetTimeBounds_4DImage_ZeroAndDimT(30, 25, 20, 5);
793  testClass.IsValidTimePoint_ImageValidTimePoint_True(image->Clone(), 30, 25, 20, 5);
794  testClass.IsValidTimePoint_ImageNegativInvalidTimePoint_False(30, 25, 20, 5);
795  testClass.IsValidTimePoint_ImageInvalidTimePoint_False(30, 25, 20, 5);
796  testClass.IsValidTimeStep_ImageValidTimeStep_True(image->Clone(), 30, 25, 20, 5);
797  testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(image->Clone(), 30, 25, 20, 5);
798  testClass.IsValidTimeStep_ImageInvalidTimeStep_False(image->Clone(), 30, 25, 20, 5);
799  testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(image->Clone(), 30, 25, 20, 5);
800  testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(image->Clone(), 30, 25, 20, 5);
801  testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(image->Clone(), 30, 25, 20, 5);
802  testClass.TimePointToTimeStep_4DImageInvalidTimePoint_TimePoint(30, 25, 20, 5);
803  testClass.TimePointToTimeStep_4DImageNegativInvalidTimePoint_TimePoint(30, 25, 20, 5);
804  testClass.GetGeometryForTimeStep_BaseDataValidTimeStep_CorrectGeometry(
805  image->Clone(), 3, 3, 3, 3 * 0.5, 3 * 0.33, 3 * 0.78, 5);
806  testClass.GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(image->Clone(), 30, 25, 20, 5);
807  testClass.GetGeometryForTimePoint_BaseDataValidTimePoint_CorrectGeometry(
808  image->Clone(), 3, 3, 3, 3 * 0.5, 3 * 0.33, 3 * 0.78, 5);
809  testClass.GetGeometryForTimePoint_4DImageInvalidTimePoint_NullPointer(30, 25, 20, 5);
810  testClass.GetGeometryForTimePoint_4DImageNEgativInvalidTimePoint_NullPointer(30, 25, 20, 5);
811  testClass.GetGeometryCloneForTimeStep_BaseDataValidTimeStep_CorrectGeometry(image->Clone(), 5);
812  testClass.GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(image->Clone(), 30, 25, 20, 5);
813  testClass.SetTimeStepGeometry_BaseDataValidTimeStep_CorrectGeometry(image->Clone(), 0.5, 0.33, 0.78, 5);
814  testClass.Expand_BaseDataDoubleSize_SizeChanged(image->Clone(), 5);
815  testClass.CheckBounds_BaseData_PointsAsExpected(
816  image->Clone(), -0.5 * 0.5, -0.5 * 0.33, -0.5 * 0.78, 29.5 * 0.5, 24.5 * 0.33, 19.5 * 0.78);
817  testClass.CheckLength_BaseData_AsExpected(image->Clone(), 23.160796233014466, 536.42248214721712);
818  testClass.CheckPointInside_BaseDataPointInside_True(image->Clone(), 10, 5, 5);
819  testClass.CheckPointInside_BaseDataPointOutside_False(image->Clone(), 100, 100, 500);
820  testClass.CheckBounds_Image_AsSet(30, 25, 20, 5);
821  testClass.CheckExtent_BaseData_AsSet(image->Clone(), 30 * 0.5, 25 * 0.33, 20 * 0.78);
822 
823  /*
824  MITK_TEST_OUTPUT(<< "Test for 2D+time image");
825  testClass.Translation_Image_MovedOrigin(30,25,1 ,5); // Test with 2D+t-Image
826  testClass.Rotate_Image_RotatedPoint(30,25,1 ,5); // Test with 2D+t-Image
827  testClass.Scale_Image_ScaledPoint(30,25,1 ,5); // Test with 2D+t-Image
828  */
829 
831  mitk::Point3D pointA, pointB, pointC;
832  pointA.Fill(1);
833  pointB.Fill(2);
834  pointC.Fill(3);
835  pointSet->SetPoint(0, pointA);
836  pointSet->SetPoint(1, pointB);
837  pointSet->SetPoint(2, pointC);
838  testClass.CountTimeSteps_Image_ReturnDimT(pointSet->Clone(), 30, 25, 20, 1);
839  // testClass.GetMinimumTimePoint_3DImage_Min(pointSet->Clone(),30,25,20,1);
840  // testClass.GetMaximumTimePoint_3DImage_Max(pointSet->Clone(),30,25,20,1);
841  // testClass.GetTimeBounds_3DImage_ZeroAndDimT(pointSet->Clone(),30,25,20,1);
842  testClass.IsValidTimePoint_ImageValidTimePoint_True(pointSet->Clone(), 30, 25, 20, 1);
843  testClass.IsValidTimeStep_ImageValidTimeStep_True(pointSet->Clone(), 30, 25, 20, 1);
844  testClass.IsValidTimeStep_ImageNegativInvalidTimeStep_False(pointSet->Clone(), 30, 25, 20, 1);
845  testClass.IsValidTimeStep_ImageInvalidTimeStep_False(pointSet->Clone(), 30, 25, 20, 1);
846  testClass.TimeStepToTimePoint_ImageValidTimeStep_TimePoint(pointSet->Clone(), 30, 25, 20, 1);
847  testClass.TimeStepToTimePoint_ImageInvalidTimeStep_TimePoint(pointSet->Clone(), 30, 25, 20, 1);
848  testClass.TimePointToTimeStep_ImageValidTimePoint_TimePoint(pointSet->Clone(), 30, 25, 20, 1);
849  testClass.GetGeometryForTimeStep_BaseDataValidTimeStep_CorrectGeometry(pointSet->Clone(), 3, 3, 3, 3, 3, 3, 1);
850  testClass.GetGeometryForTimeStep_ImageInvalidTimeStep_NullPointer(pointSet->Clone(), 30, 25, 20, 1);
851  testClass.GetGeometryForTimePoint_BaseDataValidTimePoint_CorrectGeometry(pointSet->Clone(), 3, 3, 3, 3, 3, 3, 1);
852  testClass.GetGeometryCloneForTimeStep_BaseDataValidTimeStep_CorrectGeometry(pointSet->Clone(), 1);
853  testClass.GetGeometryCloneForTimeStep_ImageInvalidTimeStep_NullPointer(pointSet->Clone(), 30, 25, 20, 1);
854  testClass.SetTimeStepGeometry_BaseDataValidTimeStep_CorrectGeometry(pointSet->Clone(), 1, 1, 1, 1);
855  testClass.Expand_BaseDataDoubleSize_SizeChanged(pointSet->Clone(), 1);
856  testClass.CheckBounds_BaseData_PointsAsExpected(pointSet->Clone(), 1, 1, 1, 3, 3, 3);
857  testClass.CheckLength_BaseData_AsExpected(pointSet->Clone(), 3.46410161, 12);
858  testClass.CheckPointInside_BaseDataPointInside_True(pointSet->Clone(), 2, 2, 3);
859  testClass.CheckPointInside_BaseDataPointOutside_False(pointSet->Clone(), 4, 5, 1);
860  testClass.CheckBounds_BaseData_AsSet(pointSet->Clone(), 1, 3, 1, 3, 1, 3);
861  testClass.CheckExtent_BaseData_AsSet(pointSet->Clone(), 2, 2, 2);
862 
863  MITK_TEST_END();
864 
865  return EXIT_SUCCESS;
866 }
static const mitk::ScalarType test_eps_square
itk::FixedArray< ScalarType, 2 > TimeBounds
Standard typedef for time-bounds.
#define MITK_INFO
Definition: mitkLogMacros.h:22
Base of all data objects.
Definition: mitkBaseData.h:39
int mitkTimeGeometryTest(int, char *[])
double ScalarType
static Pointer New()
const mitk::TimeGeometry * GetTimeGeometry() const
Return the TimeGeometry of the data as const pointer.
Definition: mitkBaseData.h:52
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
Constants for most interaction classes, due to the generic StateMachines.
static Matrix3D rotation
#define MITK_TEST_OUTPUT(x)
Output some text.
static const mitk::ScalarType test_eps
virtual void ExecuteOperation(Operation *op) override
Executes the given operation on all time steps.
static Pointer New()
#define MITK_TEST_CONDITION(COND, MSG)
mitk::ScalarType TimePointType
std::vcl_size_t TimeStepType
static T max(T x, T y)
Definition: svm.cpp:70
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.
void IndexToWorld(const mitk::Vector3D &vec_units, mitk::Vector3D &vec_mm) const
Convert (continuous or discrete) index coordinates of a vector vec_units to world coordinates (in mm)...
virtual BaseGeometry::Pointer GetGeometryForTimeStep(TimeStepType timeStep) const =0
Returns the geometry which corresponds to the given time step.
static Point3D originalPoint
and MITK_TEST_END()
mitk::BaseGeometry * GetGeometry(int t=0) const
Return the geometry, which is a TimeGeometry, of the data as non-const pointer.
Definition: mitkBaseData.h:129
Operation, that holds everything necessary for an rotation operation on mitk::BaseData.
BoundingBoxType::BoundsArrayType BoundsArrayType