Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkImageVtkMapper2DResliceInterpolationPropertyTest.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 // MITK
14 #include "mitkDataNode.h"
15 #include "mitkIOUtil.h"
17 #include "mitkTestingMacros.h"
19 
20 // VTK
22 #include <vtkRegressionTestImage.h>
23 
25 {
26  try
27  {
28  mitk::RenderingTestHelper openGlTest(640, 480);
29  }
30  catch (const mitk::TestNotRunException &e)
31  {
32  MITK_WARN << "Test not run: " << e.GetDescription();
33  return 77;
34  }
35  // load all arguments into a datastorage, take last argument as reference
36  // setup a renderwindow of fixed size X*Y
37  // render the datastorage
38  // compare rendering to reference image
39  // note: this test is supposed to test the reslice interpolation modes not the swiveling itself
40  MITK_TEST_BEGIN("mitkImageVtkMapper2DResliceInterpolationPropertyTest")
41 
42  mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv);
43 
44  // get resliceInterpolation from comandline arg
45  int resliceInterpolation = atoi(argv[argc - 4]);
46 
47  // Set interpolation mode for rendering
48  renderingHelper.SetImageProperty("reslice interpolation",
49  mitk::VtkResliceInterpolationProperty::New(resliceInterpolation));
50 
51  /*+++rotate plane+++*/
52  // center point for rotation
53  mitk::Point3D centerPoint;
54  centerPoint.Fill(0.0f);
55  // vector for rotating the slice
56  mitk::Vector3D rotationVector;
57  rotationVector.SetElement(0, 0.2);
58  rotationVector.SetElement(1, 0.3);
59  rotationVector.SetElement(2, 0.5);
60  // sets a swivel direction for the image
61 
62  // new version of setting the center point:
63  mitk::Image::Pointer image = static_cast<mitk::Image *>(
64  renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Image"))->GetData());
65 
66  // get the center point of the image
67  centerPoint = image->GetGeometry()->GetCenter();
68 
69  // rotate the image arround its own center
70  renderingHelper.ReorientSlices(centerPoint, rotationVector);
71 
72  // threshold for CompareRenderWindowAgainstReference
73  double threshold = 0.35; // difference between interpolation modes is very small
74 
75  //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper
76  MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv, threshold) == true,
77  "CompareRenderWindowAgainstReference test result positive?");
78 
79  // use this to generate a reference screenshot or save the file:
80  if (false)
81  {
82  renderingHelper.Render();
83  renderingHelper.SaveReferenceScreenShot("C:\\Users\\schroedt\\Pictures\\RenderingTestData\\Pic3dRefLinear.png");
84  }
85 
86  MITK_TEST_END();
87 }
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
void SaveReferenceScreenShot(std::string fileName)
SaveReferenceScreenShot Convenience method to save a reference screen shot.
bool CompareRenderWindowAgainstReference(int argc, char *argv[], double threshold=10.0)
CompareRenderWindowAgainstReference Convenience method to compare the image rendered in the internal ...
void SetImageProperty(const char *propertyKey, mitk::BaseProperty *property)
This method set the property of the member datastorage.
void ReorientSlices(mitk::Point3D origin, mitk::Vector3D rotation)
Reorient the slice (e.g. rotation and translation like the swivel mode).
#define MITK_WARN
Definition: mitkLogMacros.h:19
void Render()
Render everything into an mitkRenderWindow. Call SetViewDirection() and SetProperty() before this met...
#define MITK_TEST_CONDITION(COND, MSG)
Specialized mitk::Exception for skipped tests.
Image class for storing images.
Definition: mitkImage.h:72
mitk::Image::Pointer image
mitk::DataStorage::Pointer GetDataStorage()
Returns the datastorage, in order to modify the data inside a rendering test.
static Pointer New(const char *_arg)
and MITK_TEST_END()
int mitkImageVtkMapper2DResliceInterpolationPropertyTest(int argc, char *argv[])