Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageVtkMapper2DSwivelTest.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 "mitkImage.h"
20 #include "mitkTestingMacros.h"
22 
23 // VTK
24 #include <vtkRegressionTestImage.h>
25 
26 int mitkImageVtkMapper2DSwivelTest(int argc, char *argv[])
27 {
28  // load all arguments into a datastorage, take last argument as reference
29  // setup a renderwindow of fixed size X*Y
30  // render the datastorage
31  // compare rendering to reference image
32  MITK_TEST_BEGIN("mitkImageVtkMapper2DSwivelTest")
33 
34  mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv);
35  // center point for rotation
36  mitk::Point3D centerPoint;
37  centerPoint.Fill(0.0f);
38  // vector for rotating the slice
39  mitk::Vector3D rotationVector;
40  rotationVector.SetElement(0, 0.2);
41  rotationVector.SetElement(1, 0.3);
42  rotationVector.SetElement(2, 0.5);
43  // sets a swivel direction for the image
44 
45  // new version of setting the center point:
46  mitk::Image::Pointer image = static_cast<mitk::Image *>(
47  renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Image"))->GetData());
48 
49  // get the center point of the image
50  centerPoint = image->GetGeometry()->GetCenter();
51 
52  // rotate the image arround its own center
53  renderingHelper.ReorientSlices(centerPoint, rotationVector);
54 
55  //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper
56  MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true,
57  "CompareRenderWindowAgainstReference test result positive?");
58 
59  // use this to generate a reference screenshot or save the file:
60  if (false)
61  {
62  renderingHelper.SaveReferenceScreenShot(
63  "/media/hdd/thomasHdd/Pictures/RenderingTestData/pic3dSwivel640x480REF.png");
64  }
65 
66  MITK_TEST_END();
67 }
int mitkImageVtkMapper2DSwivelTest(int argc, char *argv[])
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 ReorientSlices(mitk::Point3D origin, mitk::Vector3D rotation)
Reorient the slice (e.g. rotation and translation like the swivel mode).
#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()