MCPcopy Create free account
hub / github.com/MITK/MITK / mitkTransferFunctionTest

Function mitkTransferFunctionTest

Modules/Core/test/mitkTransferFunctionTest.cpp:28–235  ·  view source on GitHub ↗

* Unit test for class mitk::TransferFunction. * * argc and argv are the command line parameters which were passed to * the ADD_TEST command in the CMakeLists.txt file. For the automatic * tests, argv is either empty for the simple tests or contains the filename * of a test image for the image tests (see CMakeLists.txt). */

Source from the content-addressed store, hash-verified

26* of a test image for the image tests (see CMakeLists.txt).
27*/
28int mitkTransferFunctionTest(int /* argc */, char * /*argv*/ [])
29{
30 // always start with this!
31 MITK_TEST_BEGIN("TransferFunction");
32
33 // let's create an object of our class
34 mitk::TransferFunction::Pointer myTransferFunction = mitk::TransferFunction::New();
35
36 // first test: did this work?
37 // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since
38 // it makes no sense to continue without an object.
39 MITK_TEST_CONDITION_REQUIRED(myTransferFunction.IsNotNull(), "Testing instantiation");
40
41 /*************************************************************************/
42 // Create and set control point arrays for scalar opacity transfer function
43 mitk::TransferFunction::ControlPoints scalarOpacityPoints;
44 scalarOpacityPoints.push_back(std::make_pair(0.0, 0.0));
45 scalarOpacityPoints.push_back(std::make_pair(5.0, 0.3));
46 scalarOpacityPoints.push_back(std::make_pair(10.0, 1.0));
47 myTransferFunction->SetScalarOpacityPoints(scalarOpacityPoints);
48 MITK_TEST_CONDITION_REQUIRED(myTransferFunction->GetScalarOpacityFunction()->GetSize() == 3,
49 "Adding three point/value pairs to scalar opacity transfer function via VTK interface");
50
51 // Create and set control point arrays for gradient opacity transfer function
52 mitk::TransferFunction::ControlPoints gradientOpacityPoints;
53 gradientOpacityPoints.push_back(std::make_pair(0.0, 0.2));
54 gradientOpacityPoints.push_back(std::make_pair(3.0, 0.7));
55 gradientOpacityPoints.push_back(std::make_pair(7.0, 0.8));
56 gradientOpacityPoints.push_back(std::make_pair(15.0, 0.9));
57 myTransferFunction->SetGradientOpacityPoints(gradientOpacityPoints);
58 MITK_TEST_CONDITION_REQUIRED(myTransferFunction->GetGradientOpacityFunction()->GetSize() == 4,
59 "Adding four point/value pairs to gradient opacity transfer function via VTK interface");
60
61 // Create and set control point arrays for color transfer function
62 mitk::TransferFunction::RGBControlPoints colorPoints;
63 itk::RGBPixel<double> rgb0, rgb1, rgb2, rgb3;
64 rgb0[0] = 0.1f;
65 rgb0[1] = 0.3f;
66 rgb0[2] = 0.5f;
67 colorPoints.push_back(std::make_pair(2.0, rgb0));
68 rgb1[0] = 0.3;
69 rgb1[1] = 0.8;
70 rgb1[2] = 0.9;
71 colorPoints.push_back(std::make_pair(3.0, rgb1));
72 rgb2[0] = 0.6;
73 rgb2[1] = 0.5;
74 rgb2[2] = 0.4;
75 colorPoints.push_back(std::make_pair(4.0, rgb2));
76 rgb3[0] = 0.7;
77 rgb3[1] = 0.1;
78 rgb3[2] = 0.2;
79 colorPoints.push_back(std::make_pair(5.0, rgb3));
80
81 myTransferFunction->SetRGBPoints(colorPoints);
82 MITK_TEST_CONDITION_REQUIRED(myTransferFunction->GetColorTransferFunction()->GetSize() == 4,
83 "Adding four point/value pairs to color transfer function via VTK interface");
84
85 /*************************************************************************/

Callers

nothing calls this directly

Calls 15

IsNotNullMethod · 0.80
SetRGBPointsMethod · 0.80
AddScalarOpacityPointMethod · 0.80
AddRGBPointMethod · 0.80
RemoveRGBPointMethod · 0.80

Tested by

no test coverage detected