diff --git a/CMakeExternals/MITKData.cmake b/CMakeExternals/MITKData.cmake index 899e92b61a..b6f96d9211 100644 --- a/CMakeExternals/MITKData.cmake +++ b/CMakeExternals/MITKData.cmake @@ -1,36 +1,36 @@ #----------------------------------------------------------------------------- # MITK Data #----------------------------------------------------------------------------- # Sanity checks if(DEFINED MITK_DATA_DIR AND NOT EXISTS ${MITK_DATA_DIR}) message(FATAL_ERROR "MITK_DATA_DIR variable is defined but corresponds to non-existing directory") endif() set(proj MITK-Data) set(proj_DEPENDENCIES) set(MITK-Data_DEPENDS ${proj}) if(BUILD_TESTING) - set(revision_tag f04939c6) # first 8 characters of hash-tag + set(revision_tag 7a7d873f) # first 8 characters of hash-tag # ^^^^^^^^ these are just to check correct length of hash part ExternalProject_Add(${proj} URL ${MITK_THIRDPARTY_DOWNLOAD_PREFIX_URL}/MITK-Data_${revision_tag}.tar.gz UPDATE_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" DEPENDS ${proj_DEPENDENCIES} ) set(MITK_DATA_DIR ${ep_source_dir}/${proj}) else() mitkMacroEmptyExternalProject(${proj} "${proj_DEPENDENCIES}") endif(BUILD_TESTING) diff --git a/Modules/AlgorithmsExt/Testing/files.cmake b/Modules/AlgorithmsExt/Testing/files.cmake index fc97d9b4a9..bf35ab73a0 100644 --- a/Modules/AlgorithmsExt/Testing/files.cmake +++ b/Modules/AlgorithmsExt/Testing/files.cmake @@ -1,13 +1,14 @@ set(MODULE_TESTS mitkAutoCropImageFilterTest.cpp mitkBoundingObjectCutterTest.cpp mitkImageToUnstructuredGridFilterTest.cpp mitkSimpleHistogramTest.cpp mitkCovarianceMatrixCalculatorTest.cpp mitkAnisotropicIterativeClosestPointRegistrationTest.cpp + mitkUnstructuredGridClusteringFilterTest.cpp mitkUnstructuredGridToUnstructuredGridFilterTest.cpp ) set(MODULE_CUSTOM_TESTS mitkLabeledImageToSurfaceFilterTest.cpp ) diff --git a/Modules/AlgorithmsExt/Testing/mitkUnstructuredGridClusteringFilterTest.cpp b/Modules/AlgorithmsExt/Testing/mitkUnstructuredGridClusteringFilterTest.cpp new file mode 100644 index 0000000000..8f2409f9e7 --- /dev/null +++ b/Modules/AlgorithmsExt/Testing/mitkUnstructuredGridClusteringFilterTest.cpp @@ -0,0 +1,129 @@ +/*=================================================================== + +The Medical Imaging Interaction Toolkit (MITK) + +Copyright (c) German Cancer Research Center, +Division of Medical and Biological Informatics. +All rights reserved. + +This software is distributed WITHOUT ANY WARRANTY; without +even the implied warranty of MERCHANTABILITY or FITNESS FOR +A PARTICULAR PURPOSE. + +See LICENSE.txt or http://www.mitk.org for details. + +===================================================================*/ + +#include "mitkTestingMacros.h" +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +class mitkUnstructuredGridClusteringFilterTestSuite : public mitk::TestFixture +{ + CPPUNIT_TEST_SUITE(mitkUnstructuredGridClusteringFilterTestSuite); + + vtkDebugLeaks::SetExitError(0); + + MITK_TEST(testUnstructuredGridClusteringFilterInitialization); + MITK_TEST(testInput); + MITK_TEST(testUnstructuredGridGeneration); + MITK_TEST(testReturnedCluster); + MITK_TEST(testClusterVector); + MITK_TEST(testGetNumberOfFoundClusters); + CPPUNIT_TEST_SUITE_END(); + +private: + + mitk::UnstructuredGrid::Pointer m_UnstructuredGrid; + +public: + + void setUp() + { + m_UnstructuredGrid = mitk::UnstructuredGrid::New(); + + //Loading the test data + std::vector< mitk::BaseData::Pointer > vector = mitk::IOUtil::Load(GetTestDataFilePath("UnstructuredGrid/scoredGrid.vtu")); + mitk::BaseData::Pointer base = vector.at(0); + m_UnstructuredGrid = dynamic_cast(base.GetPointer()); + } + + void testUnstructuredGridClusteringFilterInitialization() + { + mitk::UnstructuredGridClusteringFilter::Pointer clusterFilter = mitk::UnstructuredGridClusteringFilter::New(); + CPPUNIT_ASSERT_MESSAGE("Testing instantiation of filter object", clusterFilter.IsNotNull()); + } + + void testInput() + { + mitk::UnstructuredGridClusteringFilter::Pointer clusterFilter = mitk::UnstructuredGridClusteringFilter::New(); + clusterFilter->SetInput(m_UnstructuredGrid); + CPPUNIT_ASSERT_MESSAGE("Testing set / get input!", clusterFilter->GetInput() == m_UnstructuredGrid); + } + + void testUnstructuredGridGeneration() + { + mitk::UnstructuredGridClusteringFilter::Pointer clusterFilter = mitk::UnstructuredGridClusteringFilter::New(); + clusterFilter->SetInput(m_UnstructuredGrid); + clusterFilter->SetMeshing(false); + clusterFilter->SetMinPts(4); + clusterFilter->Seteps(1.2); + clusterFilter->Update(); + CPPUNIT_ASSERT_MESSAGE("Testing output generation!", clusterFilter->GetOutput() != NULL); + } + + void testReturnedCluster() + { + mitk::UnstructuredGridClusteringFilter::Pointer clusterFilter = mitk::UnstructuredGridClusteringFilter::New(); + clusterFilter->SetInput(m_UnstructuredGrid); + clusterFilter->SetMeshing(false); + clusterFilter->SetMinPts(4); + clusterFilter->Seteps(1.2); + clusterFilter->Update(); + mitk::UnstructuredGrid::Pointer cluster = clusterFilter->GetOutput(); + CPPUNIT_ASSERT_MESSAGE("Testing the output cluster!", cluster->GetVtkUnstructuredGrid()->GetPoints()->GetNumberOfPoints() == 620); + } + + void testClusterVector() + { + mitk::UnstructuredGridClusteringFilter::Pointer clusterFilter = mitk::UnstructuredGridClusteringFilter::New(); + clusterFilter->SetInput(m_UnstructuredGrid); + clusterFilter->SetMeshing(false); + clusterFilter->SetMinPts(4); + clusterFilter->Seteps(1.2); + clusterFilter->Update(); + std::vector< mitk::UnstructuredGrid::Pointer > clustervector = clusterFilter->GetAllClusters(); + //test that all clusters have points: + bool havePoints = true; + for(unsigned int i=0; iGetVtkUnstructuredGrid()->GetPoints()->GetNumberOfPoints()<1) + havePoints = false; + } + CPPUNIT_ASSERT_MESSAGE("Testing number of found clusters!", havePoints && clustervector.size() == 17); + } + + void testGetNumberOfFoundClusters() + { + mitk::UnstructuredGridClusteringFilter::Pointer clusterFilter = mitk::UnstructuredGridClusteringFilter::New(); + clusterFilter->SetInput(m_UnstructuredGrid); + clusterFilter->SetMeshing(false); + clusterFilter->SetMinPts(4); + clusterFilter->Seteps(1.2); + clusterFilter->Update(); + CPPUNIT_ASSERT_MESSAGE("Testing number of found clusters!", clusterFilter->GetNumberOfFoundClusters() == 17); + } + +}; + +MITK_TEST_SUITE_REGISTRATION(mitkUnstructuredGridClusteringFilter)