21 #include <vtkPoints.h> 22 #include <vtkSmartPointer.h> 23 #include <vtkUnstructuredGrid.h> 27 CPPUNIT_TEST_SUITE(mitkUnstructuredGridClusteringFilterTestSuite);
29 MITK_TEST(testUnstructuredGridClusteringFilterInitialization);
31 MITK_TEST(testUnstructuredGridGeneration);
35 CPPUNIT_TEST_SUITE_END();
46 std::vector<mitk::BaseData::Pointer> vector =
52 void testUnstructuredGridClusteringFilterInitialization()
55 CPPUNIT_ASSERT_MESSAGE(
"Testing instantiation of filter object", clusterFilter.IsNotNull());
61 clusterFilter->SetInput(m_UnstructuredGrid);
62 CPPUNIT_ASSERT_MESSAGE(
"Testing set / get input!", clusterFilter->GetInput() == m_UnstructuredGrid);
65 void testUnstructuredGridGeneration()
68 clusterFilter->SetInput(m_UnstructuredGrid);
69 clusterFilter->SetMeshing(
false);
70 clusterFilter->SetMinPts(4);
71 clusterFilter->Seteps(1.2);
72 clusterFilter->Update();
73 CPPUNIT_ASSERT_MESSAGE(
"Testing output generation!", clusterFilter->GetOutput() !=
nullptr);
76 void testReturnedCluster()
79 clusterFilter->SetInput(m_UnstructuredGrid);
80 clusterFilter->SetMeshing(
false);
81 clusterFilter->SetMinPts(4);
82 clusterFilter->Seteps(1.2);
83 clusterFilter->Update();
85 CPPUNIT_ASSERT_MESSAGE(
"Testing the output cluster!",
86 cluster->GetVtkUnstructuredGrid()->GetPoints()->GetNumberOfPoints() == 620);
89 void testClusterVector()
92 clusterFilter->SetInput(m_UnstructuredGrid);
93 clusterFilter->SetMeshing(
false);
94 clusterFilter->SetMinPts(4);
95 clusterFilter->Seteps(1.2);
96 clusterFilter->Update();
97 std::vector<mitk::UnstructuredGrid::Pointer> clustervector = clusterFilter->GetAllClusters();
99 bool havePoints =
true;
100 for (
unsigned int i = 0; i < clustervector.size(); i++)
103 if (grid->GetVtkUnstructuredGrid()->GetPoints()->GetNumberOfPoints() < 1)
106 CPPUNIT_ASSERT_MESSAGE(
"Testing number of found clusters!", havePoints && clustervector.size() == 17);
109 void testGetNumberOfFoundClusters()
112 clusterFilter->SetInput(m_UnstructuredGrid);
113 clusterFilter->SetMeshing(
false);
114 clusterFilter->SetMinPts(4);
115 clusterFilter->Seteps(1.2);
116 clusterFilter->Update();
117 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, const ReaderOptionsFunctorBase *optionsCallback=nullptr)
Load a file into the given DataStorage.