48 scalarOpacityPoints.push_back(std::make_pair(0.0, 0.0));
49 scalarOpacityPoints.push_back(std::make_pair(5.0, 0.3));
50 scalarOpacityPoints.push_back(std::make_pair(10.0, 1.0));
51 myTransferFunction->SetScalarOpacityPoints(scalarOpacityPoints);
53 "Adding three point/value pairs to scalar opacity transfer function via VTK interface");
57 gradientOpacityPoints.push_back(std::make_pair(0.0, 0.2));
58 gradientOpacityPoints.push_back(std::make_pair(3.0, 0.7));
59 gradientOpacityPoints.push_back(std::make_pair(7.0, 0.8));
60 gradientOpacityPoints.push_back(std::make_pair(15.0, 0.9));
61 myTransferFunction->SetGradientOpacityPoints(gradientOpacityPoints);
63 "Adding four point/value pairs to gradient opacity transfer function via VTK interface");
67 itk::RGBPixel<double> rgb0, rgb1, rgb2, rgb3;
71 colorPoints.push_back(std::make_pair(2.0, rgb0));
75 colorPoints.push_back(std::make_pair(3.0, rgb1));
79 colorPoints.push_back(std::make_pair(4.0, rgb2));
83 colorPoints.push_back(std::make_pair(5.0, rgb3));
85 myTransferFunction->SetRGBPoints(colorPoints);
87 "Adding four point/value pairs to color transfer function via VTK interface");
91 myTransferFunction->AddScalarOpacityPoint(3.0, 0.2);
93 "Adding new point/value to scalar opacity transfer function via MITK interface");
96 myTransferFunction->AddGradientOpacityPoint(19.0, 1.0);
98 "Adding new point/value to gradient opacity transfer function via MITK interface");
101 myTransferFunction->AddRGBPoint(1.0, 0.0, 0.1, 0.2);
103 "Adding new point/value to color transfer function via MITK interface");
108 v1 = myTransferFunction->GetScalarOpacityFunction()->GetValue(3.0);
109 v2 = myTransferFunction->GetScalarOpacityFunction()->GetValue(10.0);
111 "Retrieving values at two points from scalar opacity transfer function");
114 v1 = myTransferFunction->GetGradientOpacityFunction()->GetValue(0.0);
115 v2 = myTransferFunction->GetGradientOpacityFunction()->GetValue(19.0);
117 "Retrieving values at two points from gradient opacity transfer function");
120 double vrgb1[3], vrgb2[3];
121 myTransferFunction->GetColorTransferFunction()->GetColor(1.0, vrgb1);
122 myTransferFunction->GetColorTransferFunction()->GetColor(4.0, vrgb2);
123 std::cout << vrgb2[0] <<
", " << vrgb2[1] <<
", " << vrgb2[2] << std::endl;
125 (fabs(vrgb1[2] - 0.2) < 1.0e-5) && (fabs(vrgb2[0] - 0.6) < 1.0e-5) &&
126 (fabs(vrgb2[1] - 0.5) < 1.0e-5) && (fabs(vrgb2[2] - 0.4) < 1.0e-5),
127 "Retrieving values at two points from color transfer function");
133 "Removing point from scalar opacity transfer function (should return point index)");
138 "Removing point from gradient opacity transfer function (should return point index)");
143 "Removing point from color transfer function (should return point ndex)");
148 myTransferFunction->RemoveScalarOpacityPoint(2.5) == -1,
149 "Trying to remove non-existing point from scalar opacity transfer function (should return -1)");
153 myTransferFunction->RemoveGradientOpacityPoint(2.5) == -1,
154 "Trying to remove non-existing point from gradient opacity transfer function (should return -1)");
158 "Trying to remove non-existing point from color transfer function (should return -1)");
164 (fabs(newScalarOpacityPoints[2].first - 10.0) < 1.0e-5) &&
165 (fabs(newScalarOpacityPoints[2].second - 1.0) < 1.0e-5),
166 "Retrieving copy of scalar opacity points (checking for correct content and size)");
171 (fabs(newGradientOpacityPoints[3].first - 19.0) < 1.0e-5) &&
172 (fabs(newGradientOpacityPoints[3].second - 1.0) < 1.0e-5),
173 "Retrieving copy of gradient opacity points (checking for correct content and size)");
178 (newRGBPoints.size() == 4) && (fabs(newRGBPoints[3].first - 4.0) < 1.0e-5) &&
179 (fabs(newRGBPoints[3].second[0] - 0.6) < 1.0e-5) && (fabs(newRGBPoints[3].second[1] - 0.5) < 1.0e-5) &&
180 (fabs(newRGBPoints[3].second[2] - 0.4) < 1.0e-5),
181 "Retrieving copy of color transfer function points (checking for correct content and size)");
185 myTransferFunction->ClearScalarOpacityPoints();
187 "Clearing scalar opacity points (resulting array should be empty)");
189 myTransferFunction->ClearGradientOpacityPoints();
191 "Clearing gradient opacity points (resulting array should be empty)");
193 myTransferFunction->ClearRGBPoints();
195 "Clearing color transfer function points (resulting array should be empty)");
203 "Testing if Transferfunction is the correct one");
205 transferInit->SetTransferFunction(myTransferFunction);
208 "Testing if Set Transferfunction works");
210 "Testing if Set Transferfunction sets the correct one");
213 int arPointNumbers[size][3] = {
214 {3, 1, 6}, {2, 1, 2}, {4, 1, 5}, {3, 1, 5}, {4, 1, 7}, {4, 2, 7}, {4, 1, 4}, {6, 2, 6}};
216 std::string names[size] = {
"SetDefaultMode",
217 "SetCtBlackWhiteMode",
218 "SetCtThoraxLargeMode",
219 "SetCtThoraxSmallMode",
221 "SetCtBoneGradientMode",
225 for (
int i = 0; i < size; i++)
227 transferInit->SetTransferFunctionMode(i);
229 std::cout <<
"Punkte: " << myTransferFunction->GetScalarOpacityFunction()->GetSize() << std::endl;
231 "Testing if in " << names[i] <<
" the Scalar Opacity Function is set");
233 "Testing if in " << names[i] <<
" the Gradient Opacity Function is set");
235 "Testing if in " << names[i] <<
" the Color Transfer Function is set");
#define MITK_TEST_CONDITION_REQUIRED(COND, MSG)
int mitkTransferFunctionTest(int, char *[])
section GeneralTestsDeprecatedOldTestingStyle Deprecated macros All tests with MITK_TEST_BEGIN()
std::vector< std::pair< double, itk::RGBPixel< double > > > RGBControlPoints
std::vector< std::pair< double, double > > ControlPoints