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