Medical Imaging Interaction Toolkit  2018.4.99-3e3f1a6e
Medical Imaging Interaction Toolkit
mitkPointSetVtkMapper2DTransformedPointsTest.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
15 #include "mitkTestingMacros.h"
16 #include <mitkBaseProperty.h>
19 #include <mitkPointSet.h>
20 
21 // 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 
36  // load all arguments into a datastorage, take last argument as reference rendering
37  // setup a renderwindow of fixed size X*Y
38  // render the datastorage
39  // compare rendering to reference image
40  MITK_TEST_BEGIN("mitkPointSetVtkMapper2DTransformedPointsTest")
41 
42  mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv);
43 
45 
46  mitk::DataNode *dataNode = renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("PointSet"));
47 
48  if (dataNode)
49  {
50  mitk::PointSet::Pointer pointSet = dynamic_cast<mitk::PointSet *>(dataNode->GetData());
51 
52  if (pointSet)
53  {
54  mitk::Point3D origin = pointSet->GetGeometry()->GetOrigin();
55 
56  origin[1] += 10;
57  origin[2] += 15;
58 
59  pointSet->GetGeometry()->SetOrigin(origin);
60  pointSet->Modified();
61  dataNode->Update();
62  }
63  }
64 
65  //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRenderingTestHelper
66  MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true,
67  "CompareRenderWindowAgainstReference test result positive?");
68 
69  // use this to generate a reference screenshot or save the file:
70  if (false)
71  {
72  renderingHelper.SaveReferenceScreenShot("D:/test/output.png");
73  }
74 
75  MITK_TEST_END();
76 }
void SetViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection)
Set the view direction of the renderwindow (e.g. sagittal, coronal, axial)
int mitkPointSetVtkMapper2DTransformedPointsTest(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 ...
BaseData * GetData() const
Get the data object (instance of BaseData, e.g., an Image) managed by this DataNode.
#define MITK_WARN
Definition: mitkLogMacros.h:19
Data structure which stores a set of points. Superclass of mitk::Mesh.
Definition: mitkPointSet.h:75
#define MITK_TEST_CONDITION(COND, MSG)
Specialized mitk::Exception for skipped tests.
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()
Class for nodes of the DataTree.
Definition: mitkDataNode.h:57