25 #include <vtkPoints.h>
26 #include <vtkSmartPointer.h>
27 #include <vtkUnstructuredGrid.h>
31 CPPUNIT_TEST_SUITE(mitkUnstructuredGridClusteringFilterTestSuite);
33 MITK_TEST(testUnstructuredGridClusteringFilterInitialization);
35 MITK_TEST(testUnstructuredGridGeneration);
39 CPPUNIT_TEST_SUITE_END();
50 std::vector<mitk::BaseData::Pointer> vector =
56 void testUnstructuredGridClusteringFilterInitialization()
59 CPPUNIT_ASSERT_MESSAGE(
"Testing instantiation of filter object", clusterFilter.IsNotNull());
65 clusterFilter->SetInput(m_UnstructuredGrid);
66 CPPUNIT_ASSERT_MESSAGE(
"Testing set / get input!", clusterFilter->GetInput() == m_UnstructuredGrid);
69 void testUnstructuredGridGeneration()
72 clusterFilter->SetInput(m_UnstructuredGrid);
73 clusterFilter->SetMeshing(
false);
74 clusterFilter->SetMinPts(4);
75 clusterFilter->Seteps(1.2);
76 clusterFilter->Update();
77 CPPUNIT_ASSERT_MESSAGE(
"Testing output generation!", clusterFilter->GetOutput() != NULL);
80 void testReturnedCluster()
83 clusterFilter->SetInput(m_UnstructuredGrid);
84 clusterFilter->SetMeshing(
false);
85 clusterFilter->SetMinPts(4);
86 clusterFilter->Seteps(1.2);
87 clusterFilter->Update();
89 CPPUNIT_ASSERT_MESSAGE(
"Testing the output cluster!",
90 cluster->GetVtkUnstructuredGrid()->GetPoints()->GetNumberOfPoints() == 620);
93 void testClusterVector()
96 clusterFilter->SetInput(m_UnstructuredGrid);
97 clusterFilter->SetMeshing(
false);
98 clusterFilter->SetMinPts(4);
99 clusterFilter->Seteps(1.2);
100 clusterFilter->Update();
101 std::vector<mitk::UnstructuredGrid::Pointer> clustervector = clusterFilter->GetAllClusters();
103 bool havePoints =
true;
104 for (
unsigned int i = 0; i < clustervector.size(); i++)
107 if (grid->GetVtkUnstructuredGrid()->GetPoints()->GetNumberOfPoints() < 1)
110 CPPUNIT_ASSERT_MESSAGE(
"Testing number of found clusters!", havePoints && clustervector.size() == 17);
113 void testGetNumberOfFoundClusters()
116 clusterFilter->SetInput(m_UnstructuredGrid);
117 clusterFilter->SetMeshing(
false);
118 clusterFilter->SetMinPts(4);
119 clusterFilter->Seteps(1.2);
120 clusterFilter->Update();
121 CPPUNIT_ASSERT_MESSAGE(
"Testing number of found clusters!", clusterFilter->GetNumberOfFoundClusters() == 17);
MITK_TEST_SUITE_REGISTRATION(mitkImageToItk)
#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.
Class for storing unstructured grids (vtkUnstructuredGrid)
static DataStorage::SetOfObjects::Pointer Load(const std::string &path, DataStorage &storage)
Load a file into the given DataStorage.