Medical Imaging Interaction Toolkit  2016.11.0
Medical Imaging Interaction Toolkit
mitkImageVtkMapper2DTransferFunctionTest.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
19 #include "mitkTestingMacros.h"
20 
21 // VTK
23 #include <mitkTransferFunction.h>
25 #include <vtkRegressionTestImage.h>
26 
27 int mitkImageVtkMapper2DTransferFunctionTest(int argc, char *argv[])
28 {
29  // load all arguments into a datastorage, take last argument as reference rendering
30  // setup a renderwindow of fixed size X*Y
31  // render the datastorage
32  // compare rendering to reference image
33  MITK_TEST_BEGIN("mitkImageVtkMapper2DTransferFunctionTest")
34 
35  mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv);
36 
37  // define an arbitrary colortransferfunction
38  vtkSmartPointer<vtkColorTransferFunction> colorTransferFunction = vtkSmartPointer<vtkColorTransferFunction>::New();
39  colorTransferFunction->SetColorSpaceToRGB();
40  colorTransferFunction->AddRGBPoint(0.0, 1, 0, 0); // black = red
41  colorTransferFunction->AddRGBPoint(127.5, 0, 1, 0); // grey = green
42  colorTransferFunction->AddRGBPoint(255.0, 0, 0, 1); // white = blue
44  transferFucntion->SetColorTransferFunction(colorTransferFunction);
45 
46  // set the rendering mode to use the transfer function
47  renderingHelper.SetImageProperty(
49  // set the property for the image
50  renderingHelper.SetImageProperty("Image Rendering.Transfer Function",
51  mitk::TransferFunctionProperty::New(transferFucntion));
52 
53  //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper
54  MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv, 20.0) == true,
55  "CompareRenderWindowAgainstReference test result positive?");
56 
57  // use this to generate a reference screenshot or save the file:
58  if (false)
59  {
60  renderingHelper.SaveReferenceScreenShot("/media/hdd/thomasHdd/Pictures/tmp/output2.png");
61  }
62 
63  MITK_TEST_END();
64 }
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.
int mitkImageVtkMapper2DTransferFunctionTest(int argc, char *argv[])
#define MITK_TEST_CONDITION(COND, MSG)
static Pointer New()
and MITK_TEST_END()
static itkEventMacro(BoundingShapeInteractionEvent, itk::AnyEvent) class MITKBOUNDINGSHAPE_EXPORT BoundingShapeInteractor Pointer New()
Basic interaction methods for mitk::GeometryData.