21 vtkPoints *p1 = s1->GetVtkPolyData()->GetPoints();
22 vtkPoints *p2 = s2->GetVtkPolyData()->GetPoints();
24 if (p1->GetNumberOfPoints() != p2->GetNumberOfPoints())
27 for (
int i = 0; i < p1->GetNumberOfPoints(); ++i)
29 if (p1->GetPoint(i)[0] != p2->GetPoint(i)[0] || p1->GetPoint(i)[1] != p2->GetPoint(i)[1] ||
30 p1->GetPoint(i)[2] != p2->GetPoint(i)[2])
40 CPPUNIT_TEST_SUITE(mitkImageToSurfaceFilterTestSuite);
41 MITK_TEST(testImageToSurfaceFilterInitialization);
47 CPPUNIT_TEST_SUITE_END();
58 void setUp()
override { m_BallImage = mitk::IOUtil::Load<mitk::Image>(
GetTestDataFilePath(
"BallBinary30x30x30.nrrd")); }
59 void tearDown()
override {}
60 void testImageToSurfaceFilterInitialization()
63 CPPUNIT_ASSERT_MESSAGE(
"Testing instantiation of test object", testObject.IsNotNull());
66 CPPUNIT_ASSERT_MESSAGE(
"Testing initialization of threshold member variable", testObject->GetThreshold() == 1.0f);
67 CPPUNIT_ASSERT_MESSAGE(
"Testing initialization of smooth member variable", testObject->GetSmooth() ==
false);
68 CPPUNIT_ASSERT_MESSAGE(
"Testing initialization of decimate member variable",
70 CPPUNIT_ASSERT_MESSAGE(
"Testing initialization of target reduction member variable",
71 testObject->GetTargetReduction() == 0.95f);
77 testObject->SetInput(m_BallImage);
78 CPPUNIT_ASSERT_MESSAGE(
"Testing set / get input!", testObject->GetInput() == m_BallImage);
81 void testSurfaceGeneration()
84 testObject->SetInput(m_BallImage);
87 resultSurface = testObject->GetOutput();
88 CPPUNIT_ASSERT_MESSAGE(
"Testing surface generation!", testObject->GetOutput() !=
nullptr);
91 void testDecimatePromeshDecimation()
94 testObject->SetInput(m_BallImage);
97 resultSurface = testObject->GetOutput();
102 testObject->SetTargetReduction(0.5f);
103 testObject->Update();
106 CPPUNIT_ASSERT_MESSAGE(
"Testing DecimatePro mesh decimation!",
107 testSurface1->GetVtkPolyData()->GetPoints()->GetNumberOfPoints() >
108 testSurface2->GetVtkPolyData()->GetPoints()->GetNumberOfPoints());
111 void testQuadricDecimation()
114 testObject->SetInput(m_BallImage);
115 testObject->Update();
117 resultSurface = testObject->GetOutput();
122 testObject->SetTargetReduction(0.5f);
123 testObject->Update();
126 CPPUNIT_ASSERT_MESSAGE(
"Testing QuadricDecimation mesh decimation!",
127 testSurface1->GetVtkPolyData()->GetPoints()->GetNumberOfPoints() >
128 testSurface3->GetVtkPolyData()->GetPoints()->GetNumberOfPoints());
131 void testSmoothingOfSurface()
134 testObject->SetInput(m_BallImage);
135 testObject->Update();
137 resultSurface = testObject->GetOutput();
141 testObject->SetSmooth(
true);
143 testObject->Update();
145 CPPUNIT_ASSERT_MESSAGE(
"Testing smoothing of surface changes point data!",
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
bool CompareSurfacePointPositions(mitk::Surface::Pointer s1, mitk::Surface::Pointer s2)
#define MITK_TEST(TESTMETHOD)
Adds a test to the current test suite.
static std::string GetTestDataFilePath(const std::string &testData)
Get the absolute path for test data.
Test fixture for parameterized tests.