Medical Imaging Interaction Toolkit  2016.11.0
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,
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 // MITK
18 #include "mitkDataNode.h"
19 #include "mitkIOUtil.h"
21 #include "mitkTestingMacros.h"
23 
24 // VTK
26 #include <vtkRegressionTestImage.h>
27 
29 {
30  // load all arguments into a datastorage, take last argument as reference
31  // setup a renderwindow of fixed size X*Y
32  // render the datastorage
33  // compare rendering to reference image
34  // note: this test is supposed to test the reslice interpolation modes not the swiveling itself
35  MITK_TEST_BEGIN("mitkImageVtkMapper2DResliceInterpolationPropertyTest")
36 
37  mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv);
38 
39  // get resliceInterpolation from comandline arg
40  int resliceInterpolation = atoi(argv[argc - 4]);
41 
42  // Set interpolation mode for rendering
43  renderingHelper.SetImageProperty("reslice interpolation",
44  mitk::VtkResliceInterpolationProperty::New(resliceInterpolation));
45 
46  /*+++rotate plane+++*/
47  // center point for rotation
48  mitk::Point3D centerPoint;
49  centerPoint.Fill(0.0f);
50  // vector for rotating the slice
51  mitk::Vector3D rotationVector;
52  rotationVector.SetElement(0, 0.2);
53  rotationVector.SetElement(1, 0.3);
54  rotationVector.SetElement(2, 0.5);
55  // sets a swivel direction for the image
56 
57  // new version of setting the center point:
58  mitk::Image::Pointer image = static_cast<mitk::Image *>(
59  renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Image"))->GetData());
60 
61  // get the center point of the image
62  centerPoint = image->GetGeometry()->GetCenter();
63 
64  // rotate the image arround its own center
65  renderingHelper.ReorientSlices(centerPoint, rotationVector);
66 
67  // threshold for CompareRenderWindowAgainstReference
68  double threshold = 0.35; // difference between interpolation modes is very small
69 
70  //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper
71  MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv, threshold) == true,
72  "CompareRenderWindowAgainstReference test result positive?");
73 
74  // use this to generate a reference screenshot or save the file:
75  if (false)
76  {
77  renderingHelper.Render();
78  renderingHelper.SaveReferenceScreenShot("C:\\Users\\schroedt\\Pictures\\RenderingTestData\\Pic3dRefLinear.png");
79  }
80 
81  MITK_TEST_END();
82 }
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).
void Render()
Render everything into an mitkRenderWindow. Call SetViewDirection() and SetProperty() before this met...
#define MITK_TEST_CONDITION(COND, MSG)
Image class for storing images.
Definition: mitkImage.h:76
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[])