#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "mitkCoreExtObjectFactory.h"
Go to the source code of this file.
Classes | |
struct | functionMapEntry |
Typedefs | |
typedef int(* | MainFuncPointer )(int, char *[]) |
Functions | |
int | mitkAutoCropImageFilterTest (int, char *[]) |
int | mitkBoundingObjectCutterTest (int, char *[]) |
int | mitkContourMapper2DTest (int, char *[]) |
int | mitkContourTest (int, char *[]) |
int | mitkCoreExtObjectFactoryTest (int, char *[]) |
int | mitkDataNodeExtTest (int, char *[]) |
int | mitkExternalToolsTest (int, char *[]) |
int | mitkMeshTest (int, char *[]) |
int | mitkMultiStepperTest (int, char *[]) |
int | mitkOrganTypePropertyTest (int, char *[]) |
ctest entry point | |
int | mitkPipelineSmartPointerCorrectnessTest (int, char *[]) |
int | mitkPlaneFitTest (int, char *[]) |
int | mitkPointLocatorTest (int, char *[]) |
int | mitkToolManagerTest (int, char *[]) |
int | mitkUnstructuredGridVtkWriterTest (int, char *[]) |
int | mitkCompressedImageContainerTest (int, char *[]) |
ctest entry point | |
int | mitkCylindricToCartesianFilterTest (int, char *[]) |
int | mitkExtractImageFilterTest (int, char *[]) |
ctest entry point | |
int | mitkManualSegmentationToSurfaceFilterTest (int, char *[]) |
int | mitkOverwriteSliceImageFilterTest (int, char *[]) |
ctest entry point | |
int | mitkSurfaceToImageFilterTest (int, char *[]) |
int | mitkLabeledImageToSurfaceFilterTest (int, char *[]) |
char * | lowercase (const char *string) |
int | main (int ac, char *av[]) |
Variables | |
functionMapEntry | cmakeGeneratedFunctionMapEntries [] |
typedef int(* MainFuncPointer)(int, char *[]) |
Definition at line 37 of file MitkExtTestDriver.cpp.
char* lowercase | ( | const char * | string ) |
Definition at line 140 of file MitkExtTestDriver.cpp.
{ char *new_string, *p; #ifdef __cplusplus new_string = static_cast<char *>(malloc(sizeof(char) * static_cast<size_t>(strlen(string) + 1))); #else new_string = (char *)(malloc(sizeof(char) * (size_t)(strlen(string) + 1))); #endif if (!new_string) { return 0; } strcpy(new_string, string); p = new_string; while (*p != 0) { #ifdef __cplusplus *p = static_cast<char>(tolower(*p)); #else *p = (char)(tolower(*p)); #endif ++p; } return new_string; }
int main | ( | int | ac, |
char * | av[] | ||
) |
Definition at line 170 of file MitkExtTestDriver.cpp.
References functionMapEntry::func, lowercase(), functionMapEntry::name, mitk::LoggingBackend::Register(), RegisterCoreExtObjectFactory(), and mitk::LoggingBackend::Unregister().
{ int i, NumTests, testNum, partial_match; char *arg, *test_name; int count; int testToRun = -1; for(count =0; cmakeGeneratedFunctionMapEntries[count].name != 0; count++) { } NumTests = count; /* If no test name was given */ /* process command line with user function. */ if (ac < 2) { /* Ask for a test. */ printf("Available tests:\n"); for (i =0; i < NumTests; ++i) { printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); } printf("To run a test, enter the test number: "); fflush(stdout); testNum = 0; if( scanf("%d", &testNum) != 1 ) { printf("Couldn't parse that input as a number\n"); return -1; } if (testNum >= NumTests) { printf("%3d is an invalid test number.\n", testNum); return -1; } testToRun = testNum; ac--; av++; } partial_match = 0; arg = 0; /* If partial match is requested. */ if(testToRun == -1 && ac > 1) { partial_match = (strcmp(av[1], "-R") == 0) ? 1 : 0; } if (partial_match && ac < 3) { printf("-R needs an additional parameter.\n"); return -1; } if(testToRun == -1) { arg = lowercase(av[1 + partial_match]); } for (i =0; i < NumTests && testToRun == -1; ++i) { test_name = lowercase(cmakeGeneratedFunctionMapEntries[i].name); if (partial_match && strstr(test_name, arg) != NULL) { testToRun = i; ac -=2; av += 2; } else if (!partial_match && strcmp(test_name, arg) == 0) { testToRun = i; ac--; av++; } free(test_name); } if(arg) { free(arg); } if(testToRun != -1) { int result; mitk::LoggingBackend::Register(); RegisterCoreExtObjectFactory(); result = (*cmakeGeneratedFunctionMapEntries[testToRun].func)(ac, av); mitk::LoggingBackend::Unregister(); return result; } /* Nothing was run, display the test names. */ printf("Available tests:\n"); for (i =0; i < NumTests; ++i) { printf("%3d. %s\n", i, cmakeGeneratedFunctionMapEntries[i].name); } printf("Failed: %s is an invalid test name.\n", av[1]); return -1; }
int mitkAutoCropImageFilterTest | ( | int | , |
char * | [] | ||
) |
Definition at line 22 of file mitkAutoCropImageFilterTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, and mitk::AutoCropImageFilter::New().
{ mitk::AutoCropImageFilter::Pointer filter; std::cout << "Testing mitk::AutoCropImageFilter::New(): "; filter = mitk::AutoCropImageFilter::New(); if (filter.IsNull()) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } //std::cout << "Testing mitk::SurfaceToImageFilter::*TESTED_METHOD_DESCRIPTION: "; //if (filter.IsNull()) { // std::cout<<"[FAILED]"<<std::endl; // return EXIT_FAILURE; //} //else { //std::cout<<"[PASSED]"<<std::endl; //} std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkBoundingObjectCutterTest | ( | int | , |
char * | [] | ||
) |
Definition at line 38 of file mitkBoundingObjectCutterTest.cpp.
References EXIT_SUCCESS, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_OUTPUT, mitkBoundingObjectCutterTest(), mitk::BoundingObjectCutter::New(), mitk::Cuboid::New(), and mitk::Image::New().
Referenced by mitkBoundingObjectCutterTest().
{ MITK_TEST_BEGIN(mitkBoundingObjectCutterTest); //Create Image out of nowhere mitk::Image::Pointer image; mitk::PixelType pt(typeid(int)); unsigned int dim[]={100,100,20}; MITK_TEST_OUTPUT(<< "Creating Image as imput for cutting: "); image=mitk::Image::New(); image->Initialize(mitk::PixelType(typeid(int)), 3, dim); int *p = (int*)image->GetData(); unsigned int i; unsigned int size = dim[0]*dim[1]*dim[2]; for(i=0; i<size; ++i, ++p) *p= (signed int)i; std::cout<<"[PASSED]"<<std::endl; MITK_TEST_OUTPUT(<< "Testing mitk::BoundingObject::FitGeometry(image->GetGeometry()) with an mitk::Cuboid (sub-class of mitk::BoundingObject): "); mitk::Cuboid::Pointer cuboid = mitk::Cuboid::New(); cuboid->FitGeometry(image->GetGeometry()); std::cout<<"[PASSED]"<<std::endl; MITK_TEST_OUTPUT(<< "Testing whether corners of the cuboid are identical to corners of the image: "); int c; for(c=0; c<6; ++c) { MITK_TEST_OUTPUT(<< " Testing GetCornerPoint(" << c << "): "); MITK_TEST_CONDITION_REQUIRED( mitk::Equal(image->GetGeometry()->GetCornerPoint(c),cuboid->GetGeometry()->GetCornerPoint(c)), ""); } MITK_TEST_OUTPUT(<< "Testing whether diagonal^2 of fitted mitk::Cuboid is identical to diagonal^2 of image: "); MITK_TEST_CONDITION_REQUIRED( mitk::Equal(image->GetGeometry()->GetDiagonalLength2(),cuboid->GetGeometry()->GetDiagonalLength2()), ""); MITK_TEST_OUTPUT(<< "Testing mitk::BoundingObjectCutter: "); mitk::BoundingObjectCutter::Pointer boCutter = mitk::BoundingObjectCutter::New(); boCutter->SetInput(image); boCutter->SetBoundingObject(cuboid); MITK_TEST_OUTPUT(<< " Testing mitk::BoundingObjectCutter::UpdateLargestPossibleRegion():: "); boCutter->UpdateLargestPossibleRegion(); std::cout<<"[PASSED]"<<std::endl; mitk::Image::Pointer cuttedImage = boCutter->GetOutput(); MITK_TEST_OUTPUT(<< " Testing whether origin of cutted image is identical to origin of original image: "); MITK_TEST_CONDITION_REQUIRED( mitk::Equal(image->GetGeometry()->GetOrigin(),cuttedImage->GetGeometry()->GetOrigin()), ""); MITK_TEST_OUTPUT(<< " Testing whether spacing of cutted image is identical to spacing of original image: "); MITK_TEST_CONDITION_REQUIRED( mitk::Equal(image->GetGeometry()->GetSpacing(),cuttedImage->GetGeometry()->GetSpacing()), ""); MITK_TEST_OUTPUT(<< " Testing whether center of cutted image is identical to center of original image: "); MITK_TEST_CONDITION_REQUIRED( mitk::Equal(image->GetGeometry()->GetCenter(),cuttedImage->GetGeometry()->GetCenter()), ""); MITK_TEST_OUTPUT(<< " Testing whether diagonal^2 of cutted image is identical to diagonal^2 of original image: "); MITK_TEST_CONDITION_REQUIRED( mitk::Equal(image->GetGeometry()->GetDiagonalLength2(),cuttedImage->GetGeometry()->GetDiagonalLength2()), ""); MITK_TEST_OUTPUT(<< " Testing whether corners of cutted image are identical to corners of original image: "); for(c=0; c<6; ++c) { MITK_TEST_OUTPUT(<< " Testing GetCornerPoint(" << c << "): "); MITK_TEST_CONDITION_REQUIRED( mitk::Equal(image->GetGeometry()->GetCornerPoint(c),cuttedImage->GetGeometry()->GetCornerPoint(c)), ""); } MITK_TEST_OUTPUT(<< " Testing whether pixel data of cutted image are identical to pixel data of original image: "); p = (int*)image->GetData(); int *pCutted = (int*)cuttedImage->GetData(); for(i=0; i<size; ++i, ++p, ++pCutted) { if(*p!=*pCutted) break; } MITK_TEST_CONDITION_REQUIRED(i==size, ""); MITK_TEST_OUTPUT(<< " Testing whether geometry of cutted image has ImageGeometry==true: "); MITK_TEST_CONDITION_REQUIRED(cuttedImage->GetGeometry()->GetImageGeometry(), ""); MITK_TEST_END(); return EXIT_SUCCESS; }
int mitkCompressedImageContainerTest | ( | int | , |
char * | [] | ||
) |
ctest entry point
Definition at line 114 of file mitkCompressedImageContainerTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::CompressedImageContainer::New(), mitk::DataNodeFactory::New(), and mitkCompressedImageContainerTestClass::Test().
{ // one big variable to tell if anything went wrong unsigned int numberFailed(0); // need one parameter (image filename) if(argc==0) { std::cerr<<"No file specified [FAILED]"<<std::endl; return EXIT_FAILURE; } // load the image mitk::Image::Pointer image = NULL; mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { std::cout << "Testing with parameter '" << argv[1] << "'" << std::endl; factory->SetFileName( argv[1] ); factory->Update(); if(factory->GetNumberOfOutputs()<1) { std::cerr<<"File could not be loaded [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::DataNode::Pointer node = factory->GetOutput( 0 ); image = dynamic_cast<mitk::Image*>(node->GetData()); if(image.IsNull()) { std::cout<<"File not an image - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } } catch ( itk::ExceptionObject & ex ) { ++numberFailed; std::cerr << "Exception: " << ex << "[FAILED]" << std::endl; return EXIT_FAILURE; } std::cout << " (II) Could load image." << std::endl; std::cout << "Testing instantiation" << std::endl; // instantiation mitk::CompressedImageContainer::Pointer container = mitk::CompressedImageContainer::New(); if (container.IsNotNull()) { std::cout << " (II) Instantiation works." << std::endl; } else { ++numberFailed; std::cout << "Test failed, and it's the ugliest one!" << std::endl; return EXIT_FAILURE; } // some real work mitkCompressedImageContainerTestClass::Test( container, image, numberFailed ); std::cout << "Testing destruction" << std::endl; // freeing container = NULL; std::cout << " (II) Freeing works." << std::endl; if (numberFailed > 0) { std::cerr << numberFailed << " tests failed." << std::endl; return EXIT_FAILURE; } else { std::cout << "PASSED all tests." << std::endl; return EXIT_SUCCESS; } }
int mitkContourMapper2DTest | ( | int | , |
char * | [] | ||
) |
Definition at line 30 of file mitkContourMapper2DTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::RenderingManager::GetInstance(), mitk::GlobalInteraction::GetInstance(), mitk::VtkPropRenderer::New(), mitk::StandaloneDataStorage::New(), mitk::Contour::New(), mitk::DataNode::New(), and mitk::ContourMapper2D::New().
{ mitk::Contour::Pointer contour; mitk::ContourMapper2D::Pointer contourMapper; mitk::DataNode::Pointer node; // Global interaction must(!) be initialized if used mitk::GlobalInteraction::GetInstance()->Initialize("global"); contourMapper = mitk::ContourMapper2D::New(); node = mitk::DataNode::New(); std::cout << "Testing mitk::ContourMapper2D::New(): "; contour = mitk::Contour::New(); node->SetData(contour); if (contour.IsNull()) { std::cout << "[FAILED]" << std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } contourMapper->SetDataNode( node ); contourMapper->Update(NULL); mitk::Contour* testContour = (mitk::Contour*)contourMapper->GetInput(); std::cout << testContour << std::endl; mitk::StandaloneDataStorage::Pointer ds = mitk::StandaloneDataStorage::New(); ds->Add( node ); mitk::BoundingBox::Pointer bounds = ds->ComputeBoundingBox(); std::cout << "bounds: " << bounds << std::endl; bounds = ds->ComputeVisibleBoundingBox(); std::cout << "visible bounds: " << bounds << std::endl; vtkRenderWindow* renWin = vtkRenderWindow::New(); mitk::VtkPropRenderer::Pointer renderer = mitk::VtkPropRenderer::New( "ContourRenderer",renWin, mitk::RenderingManager::GetInstance() ); std::cout<<"Testing mitk::BaseRenderer::SetData()"<<std::endl; renderer->SetDataStorage(ds); std::cout<<"[TEST DONE]"<<std::endl; renWin->Delete(); return EXIT_SUCCESS; }
int mitkContourTest | ( | int | , |
char * | [] | ||
) |
Definition at line 23 of file mitkContourTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, and mitk::Contour::New().
{ mitk::Contour::Pointer contour; std::cout << "Testing mitk::Contour::New(): "; contour = mitk::Contour::New(); if (contour.IsNull()) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing mitk::Contour::AddVertex(): "; mitk::Point3D p; p.Fill(0); contour->AddVertex(p); p.Fill(1); contour->AddVertex(p); p.Fill(2); contour->AddVertex(p); if (contour->GetNumberOfPoints() != 3) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing mitk::Contour::GetPoints()"; mitk::Contour::PointsContainerPointer points = contour->GetPoints(); if ( points.IsNull() ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing mitk::Contour::Initialize()"; contour->Initialize(); if (contour->GetNumberOfPoints() != 0) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } contour->SetPoints(points); if ( contour->GetNumberOfPoints() != 3) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; }; mitk::Contour::PathPointer path = contour->GetContourPath(); if ( path.IsNull() ) { return EXIT_FAILURE; } contour->UpdateOutputInformation(); contour->SetClosed(false); if (contour->GetClosed()) { std::cout<<"[FAILED] "<<std::endl; return EXIT_FAILURE; } std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkCoreExtObjectFactoryTest | ( | int | , |
char * | [] | ||
) |
Definition at line 22 of file mitkCoreExtObjectFactoryTest.cpp.
References mitk::CoreObjectFactory::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, and mitk::CoreExtObjectFactory::New().
{ MITK_TEST_BEGIN("CoreExtObjectFactory") mitk::CoreObjectFactory::Pointer instance = mitk::CoreObjectFactory::GetInstance(); MITK_TEST_CONDITION_REQUIRED(instance.IsNotNull(),"Testing instantiation"); MITK_TEST_CONDITION(strcmp(instance->GetNameOfClass(),"CoreObjectFactory") == 0,"Is this a CoreObjectFactory?"); instance->RegisterExtraFactory(mitk::CoreExtObjectFactory::New()); MITK_TEST_END() }
int mitkCylindricToCartesianFilterTest | ( | int | , |
char * | [] | ||
) |
Definition at line 25 of file mitkCylindricToCartesianFilterTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::ImageSliceSelector::New(), mitk::CylindricToCartesianFilter::New(), and mitk::DataNodeFactory::New().
{ std::cout << "Loading file: "; if(argc==0) { std::cout<<"no file specified [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::Image::Pointer image = NULL; mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { factory->SetFileName( argv[1] ); factory->Update(); if(factory->GetNumberOfOutputs()<1) { std::cout<<"file could not be loaded [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::DataNode::Pointer node = factory->GetOutput( 0 ); image = dynamic_cast<mitk::Image*>(node->GetData()); if(image.IsNull()) { std::cout<<"file not an image - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } } catch ( itk::ExceptionObject & ex ) { std::cout << "Exception: " << ex << "[FAILED]" << std::endl; return EXIT_FAILURE; } //Use CylindricToCartesianFilter mitk::CylindricToCartesianFilter::Pointer cyl2cart = mitk::CylindricToCartesianFilter::New(); cyl2cart->SetInput(image); cyl2cart->SetTargetXSize( 64 ); //Take a slice mitk::ImageSliceSelector::Pointer slice = mitk::ImageSliceSelector::New(); slice->SetInput(cyl2cart->GetOutput()); slice->SetSliceNr(1); slice->Update(); std::cout << "Testing IsInitialized(): "; if(slice->GetOutput()->IsInitialized()==false) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing IsSliceSet(): "; if(slice->GetOutput()->IsSliceSet(0)==false) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; if(image->GetDimension(3) > 1) { int time=image->GetDimension(3)-1; std::cout << "Testing 3D+t: Setting time to " << time << ": "; slice->SetTimeNr(time); if(slice->GetTimeNr()!=time) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing 3D+t: Updating slice: "; slice->Update(); if(slice->GetOutput()->IsInitialized()==false) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing 3D+t: IsSliceSet(): "; if(slice->GetOutput()->IsSliceSet(0)==false) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing 3D+t: First slice in reader available: "; if(image->IsSliceSet(0, time)==false) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; } std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkDataNodeExtTest | ( | int | , |
char * | [] | ||
) |
Definition at line 240 of file mitkDataNodeExtTest.cpp.
References mitk::GlobalInteraction::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::DataNode::New(), mitkDataNodeExtTestClass::TestDataSetting(), mitkDataNodeExtTestClass::TestInteractorSetting(), and mitkDataNodeExtTestClass::TestMapperSetting().
{ // always start with this! MITK_TEST_BEGIN("DataNode") // Global interaction must(!) be initialized mitk::GlobalInteraction::GetInstance()->Initialize("global"); // let's create an object of our class mitk::DataNode::Pointer myDataNode = mitk::DataNode::New(); // first test: did this work? // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since // it makes no sense to continue without an object. MITK_TEST_CONDITION_REQUIRED(myDataNode.IsNotNull(),"Testing instantiation") //test setData() Method mitkDataNodeExtTestClass::TestDataSetting(myDataNode); mitkDataNodeExtTestClass::TestMapperSetting(myDataNode); //note, that no data is set to the dataNode mitkDataNodeExtTestClass::TestInteractorSetting(myDataNode); // write your own tests here and use the macros from mitkTestingMacros.h !!! // do not write to std::cout and do not return from this function yourself! // always end with this! MITK_TEST_END() }
int mitkExternalToolsTest | ( | int | , |
char * | [] | ||
) |
Definition at line 25 of file mitkExternalToolsTest.cpp.
References EXIT_FAILURE, and EXIT_SUCCESS.
{ return EXIT_SUCCESS; // we'll go back to a CMake solution... std::cout << "Got " << argc << " parameters" << std::endl; if ( argc == 5 ) { // "parse" commandline // quote spaces in commandline parameters (all paths/files) //std::string cmakeBinary = itksys::SystemTools::EscapeChars( argv[1], " " ); std::string cmakeBinary = argv[1]; std::string cmakeGenerator = argv[2]; std::string mitkBinaryDirectory = argv[3]; std::string sourceDirectory = argv[4]; // try to configure MITK external project std::cout << "Calling CMake as '" << cmakeBinary << "'" << std::endl; std::cout << "Calling CMake for generator '" << cmakeGenerator << "'" << std::endl; std::cout << "MITK was compiled in '" << mitkBinaryDirectory << "'" << std::endl; std::cout << "Configuring project in '" << sourceDirectory << "'" << std::endl; if( itksys::SystemTools::ChangeDirectory(mitkBinaryDirectory.c_str()) != 0 ) { std::cerr << "Couldn't change to MITK build dir. See output above." << std::endl; return EXIT_FAILURE; } std::string oneCommandlineQuote("\""); std::string commandline( oneCommandlineQuote ); commandline += cmakeBinary; commandline += oneCommandlineQuote; commandline += " -G "; commandline += oneCommandlineQuote; commandline += cmakeGenerator; commandline += oneCommandlineQuote; commandline += " -DMITK_DIR:PATH="; commandline += oneCommandlineQuote; commandline += mitkBinaryDirectory; commandline += oneCommandlineQuote; commandline += " "; commandline += oneCommandlineQuote; commandline += sourceDirectory; commandline += oneCommandlineQuote; std::cout << "Calling system() with '" << commandline << "'" << std::endl; int returnCode = system(commandline.c_str()); std::cout << "system() returned " << returnCode << std::endl; if (returnCode != 0) { std::cerr << "Configure FAILED. See output above." << std::endl; return EXIT_FAILURE; } // try to build MITK external project #ifdef WIN32 #else commandline = "make"; // commented out because mbits configures with Qt4. Have to check this monday. //returnCode = system(commandline.c_str()); if (returnCode != 0) // make should return 0 { std::cout << "make returned " << returnCode << std::endl; std::cerr << "Building the project FAILED. See output above." << std::endl; return EXIT_FAILURE; } #endif // // TODO extend test here to support windows... // return returnCode; } else { std::cout << "Invoke this test with three parameters:" << std::endl; std::cout << " 1. CMake binary including necessary path" << std::endl; std::cout << " 2. CMake generator name" << std::endl; std::cout << " 3. MITK binary path (top-level directory)" << std::endl; std::cout << " 4. Source directory containing CMakeLists.txt" << std::endl; return EXIT_FAILURE; } }
int mitkExtractImageFilterTest | ( | int | , |
char * | [] | ||
) |
ctest entry point
Definition at line 362 of file mitkExtractImageFilterTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::ExtractImageFilter::New(), mitk::DataNodeFactory::New(), mitkExtractImageFilterTestClass::Test2D(), mitkExtractImageFilterTestClass::Test3D(), and mitkExtractImageFilterTestClass::Test4D().
{ // one big variable to tell if anything went wrong unsigned int numberFailed(0); // need one parameter (image filename) if(argc==0) { std::cerr<<"No file specified [FAILED]"<<std::endl; return EXIT_FAILURE; } // load the image mitk::Image::Pointer image = NULL; mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { std::cout << "Testing with parameter '" << argv[1] << "'" << std::endl; factory->SetFileName( argv[1] ); factory->Update(); if(factory->GetNumberOfOutputs()<1) { std::cerr<<"File could not be loaded [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::DataNode::Pointer node = factory->GetOutput( 0 ); image = dynamic_cast<mitk::Image*>(node->GetData()); if(image.IsNull()) { std::cout<<"File not an image - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } } catch ( itk::ExceptionObject & ex ) { ++numberFailed; std::cerr << "Exception: " << ex << "[FAILED]" << std::endl; return EXIT_FAILURE; } std::cout << " (II) Could load image." << std::endl; std::cout << "Testing filter instantiation" << std::endl; // instantiation mitk::ExtractImageFilter::Pointer filter = mitk::ExtractImageFilter::New(); if (filter.IsNotNull()) { std::cout << " (II) Instantiation works." << std::endl; } else { ++numberFailed; std::cout << "Test failed, and it's the ugliest one!" << std::endl; return EXIT_FAILURE; } // some real work if ( image->GetDimension() == 2 ) { mitkExtractImageFilterTestClass::Test2D( filter, image, numberFailed ); } else if ( image->GetDimension() == 3 ) { mitkExtractImageFilterTestClass::Test3D( filter, image, numberFailed ); } else if ( image->GetDimension() == 4 ) { mitkExtractImageFilterTestClass::Test4D( filter, image, numberFailed ); } std::cout << "Testing filter destruction" << std::endl; // freeing filter = NULL; std::cout << " (II) Freeing works." << std::endl; if (numberFailed > 0) { std::cerr << numberFailed << " tests failed." << std::endl; return EXIT_FAILURE; } else { std::cout << "PASSED all tests." << std::endl; return EXIT_SUCCESS; } }
int mitkLabeledImageToSurfaceFilterTest | ( | int | , |
char * | [] | ||
) |
Definition at line 30 of file mitkLabeledImageToSurfaceFilterTest.cpp.
References mitk::ImageToSurfaceFilter::DecimatePro, equals(), EXIT_FAILURE, EXIT_SUCCESS, mitk::LabeledImageToSurfaceFilter::New(), and mitk::DataNodeFactory::New().
{ if(argc<2) { std::cout<<"no path to testing specified [FAILED]"<<std::endl; return EXIT_FAILURE; } std::string fileIn = argv[1]; std::cout<<"Eingabe Datei: "<<fileIn<<std::endl; mitk::Image::Pointer image = NULL; mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { std::cout << "Loading file: "; factory->SetFileName( fileIn.c_str() ); factory->Update(); if(factory->GetNumberOfOutputs()<1) { std::cout<<"file could not be loaded [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::DataNode::Pointer node = factory->GetOutput( 0 ); image = dynamic_cast<mitk::Image*>(node->GetData()); if(image.IsNull()) { std::cout<<"file not an image - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } else if(image->GetPixelType() != mitk::PixelType(typeid(char)) || image->GetPixelType() != mitk::PixelType(typeid(unsigned char)) ) { std::cout<<"file not a char or unsigned char image - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } } catch ( itk::ExceptionObject & ex ) { std::cout << "Exception: " << ex << "[FAILED]" << std::endl; return EXIT_FAILURE; } std::cout << "Testing instantiation: " ; mitk::LabeledImageToSurfaceFilter::Pointer filter = mitk::LabeledImageToSurfaceFilter::New(); if (filter.IsNull()) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Create surface with default settings: "; filter->SetInput(image); filter->Update(); if ( filter->GetNumberOfOutputs() != 1 ) { std::cout<<"Wrong number of outputs, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput() == NULL ) { std::cout<<"Output is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput()->GetVtkPolyData() == NULL ) { std::cout<<"PolyData of surface is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing index to label conversion: "; if ( filter->GetLabelForNthOutput( 0 ) != 257 ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing volume for label calculation: "; if ( ! equals ( filter->GetVolumeForLabel( 257 ) , 14.328 ) ) { std::cout<<filter->GetVolumeForLabel( 257 )<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing volume for index calculation: "; if ( ! equals ( filter->GetVolumeForNthOutput( 0 ) , 14.328 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Create surface using optimised settings: "; filter->GenerateAllLabelsOn(); filter->SetGaussianStandardDeviation( 1.5 ); filter->SetSmooth(true); // smooth wireframe filter->SetDecimate( mitk::ImageToSurfaceFilter::DecimatePro ); filter->SetTargetReduction( 0.8 ); if( filter->GetNumberOfOutputs() != 1 ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Create surface for label 257: "; filter->GenerateAllLabelsOff(); filter->SetLabel(257); filter->Update(); if ( filter->GetNumberOfOutputs() != 1 ) { std::cout<<"Wrong number of outputs, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput() == NULL ) { std::cout<<"Output is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput()->GetVtkPolyData() == NULL ) { std::cout<<"PolyData of surface is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing volume for label calculation: "; if ( ! equals ( filter->GetVolumeForLabel( 257 ) , 14.328 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing volume for index calculation: "; if ( ! equals ( filter->GetVolumeForNthOutput( 0 ) , 14.328 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Create surface for multiple labels: "; filter->GenerateAllLabelsOn(); filter->SetBackgroundLabel(32000); filter->Update(); if ( filter->GetNumberOfOutputs() != 2 ) { std::cout<<"Wrong number of outputs, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput(0) == NULL ) { std::cout<<"Output 0 is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput(0)->GetVtkPolyData() == NULL ) { std::cout<<"PolyData of output 0 is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput(1) == NULL ) { std::cout<<"Output 1 is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput(1)->GetVtkPolyData() == NULL ) { std::cout<<"PolyData of output 1 is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing volume for label calculation: "; if ( ! equals ( filter->GetVolumeForLabel( 257 ) , 14.328 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( ! equals ( filter->GetVolumeForLabel( 0 ), 12.672 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing volume for index calculation: "; if ( ! equals( filter->GetVolumeForNthOutput( 1 ), 14.328 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( ! equals ( filter->GetVolumeForNthOutput( 0 ), 12.672 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } mitk::ReferenceCountWatcher::Pointer outputSurface1Watcher = new mitk::ReferenceCountWatcher(filter->GetOutput(1), "outputSurface1"); mitk::ReferenceCountWatcher::Pointer filterWatcher = new mitk::ReferenceCountWatcher(filter, "filter"); std::cout << "Create surface for background (label 0): " << std::flush; filter->GenerateAllLabelsOff(); filter->SetLabel(0); filter->SetBackgroundLabel(257); //mitk::Surface::Pointer surface = filter->GetOutput(1); //std::cout<< surface->GetReferenceCount() << std::endl; filter->Update(); //surface = NULL; if ( filter->GetNumberOfOutputs() != 1 ) { std::cout<<"Wrong number of outputs, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput() == NULL ) { std::cout<<"Output is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput()->GetVtkPolyData() == NULL ) { std::cout<<"PolyData of surface is NULL, [FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing reference count correctness of old output 1: " << std::flush; if ( outputSurface1Watcher->GetReferenceCount() != 0 ) { std::cout<<"outputSurface1Watcher->GetReferenceCount()==" << outputSurface1Watcher->GetReferenceCount() << "!=0, [FAILED]" << std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing reference count correctness of filter: " << std::flush; if ( filterWatcher->GetReferenceCount() != 2 ) { std::cout<<"filterWatcher->GetReferenceCount()==" << outputSurface1Watcher->GetReferenceCount() << "!=2, [FAILED]" << std::endl; return EXIT_FAILURE; } std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing index to label conversion: "; if ( filter->GetLabelForNthOutput( 0 ) != 0 ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing volume for label calculation: "; if ( ! equals ( filter->GetVolumeForLabel( filter->GetLabel() ) , 12.672 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Testing volume for index calculation: "; if ( ! equals( filter->GetVolumeForNthOutput( 0 ), 12.672 ) ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Create surface for invalid label: "; filter->GenerateAllLabelsOff(); filter->SetLabel(1); filter->Update(); if ( filter->GetNumberOfOutputs() != 1 ) { std::cout<<"Number of outputs != 1, [FAILED]"<<std::endl; return EXIT_FAILURE; } else if ( filter->GetOutput()->GetVtkPolyData()->GetNumberOfPoints() != 0 ) { std::cout<<"PolyData is not empty ("<<filter->GetOutput()->GetVtkPolyData()->GetNumberOfPoints()<<"), [FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkManualSegmentationToSurfaceFilterTest | ( | int | argc, |
char * | argv[] | ||
) |
Test class for ManualSegmentationToSurfaceFilter and ImageToSurface 1. Read an image 2. Create a surface 3. Create a Surface with all image processing facillities
Definition at line 32 of file mitkManualSegmentationToSurfaceFilterTest.cpp.
References mitk::ImageToSurfaceFilter::DecimatePro, EXIT_FAILURE, EXIT_SUCCESS, mitk::SurfaceVtkWriter< VTKWRITER >::GetVtkWriter(), MITK_ERROR, MITK_INFO, mitk::SurfaceVtkWriter< VTKWRITER >::New(), mitk::ManualSegmentationToSurfaceFilter::New(), mitk::DataNodeFactory::New(), mitk::SurfaceVtkWriter< VTKWRITER >::SetFileName(), mitk::SurfaceVtkWriter< VTKWRITER >::SetInput(), and mitk::SurfaceVtkWriter< VTKWRITER >::Write().
{ if(argc==0) { std::cout<<"no file specified [FAILED]"<<std::endl; return EXIT_FAILURE; } std::string path = argv[1]; itksys::SystemTools::ConvertToUnixSlashes(path); std::string fileIn = path; std::string fileOut = "BallBinary30x30x30.stl"; fileIn = itksys::SystemTools::ConvertToOutputPath(fileIn.c_str()); fileOut = itksys::SystemTools::ConvertToOutputPath(fileOut.c_str()); std::cout<<"Eingabe Datei: "<<fileIn<<std::endl; std::cout<<"Ausgabe Datei: "<<fileOut<<std::endl; mitk::Image::Pointer image = NULL; mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { std::cout << "Loading file: "<<std::flush; factory->SetFileName( fileIn.c_str() ); factory->Update(); if(factory->GetNumberOfOutputs()<1) { std::cout<<"file could not be loaded [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::DataNode::Pointer node = factory->GetOutput( 0 ); image = dynamic_cast<mitk::Image*>(node->GetData()); if(image.IsNull()) { std::cout<<"file not an image - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } } catch ( itk::ExceptionObject & ex ) { std::cout << "Exception: " << ex << "[FAILED]" << std::endl; return EXIT_FAILURE; } mitk::ManualSegmentationToSurfaceFilter::Pointer filter; std::cout << "Instantiat mitk::ManualSegmentationToSurfaceFilter - implicit: mitk::ImageToSurface: "; filter = mitk::ManualSegmentationToSurfaceFilter::New(); if (filter.IsNull()) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } //Wirter instance mitk::SurfaceVtkWriter<vtkSTLWriter>::Pointer writer = mitk::SurfaceVtkWriter<vtkSTLWriter>::New(); if (filter.IsNull()) { std::cout<<"Instantiat SurfaceVtkWirter: [FAILED]"<<std::endl; return EXIT_FAILURE; } else { writer->GlobalWarningDisplayOn(); writer->SetFileName(fileOut.c_str()); writer->GetVtkWriter()->SetFileTypeToBinary(); } std::cout << "Create surface with default settings: "; if (image->GetDimension()==3) { filter->SetInput(image); filter->Update(); writer->SetInput(filter->GetOutput()); writer->Write(); if( writer->GetNumberOfInputs() < 1 ) { std::cout<<"[FAILED]"<<std::endl; writer->Delete(); return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Create surface all optimised settings: "; //configure ImageToSurfaceFilter filter->MedianFilter3DOn(); filter->SetGaussianStandardDeviation(1.5); filter->InterpolationOn(); filter->UseGaussianImageSmoothOn(); filter->SetThreshold( 1 ); //if( Gauss ) --> TH manipulated for vtkMarchingCube filter->SetDecimate( mitk::ImageToSurfaceFilter::DecimatePro ); filter->SetTargetReduction(0.05f); filter->SmoothOn(); try { filter->Update(); } catch( itk::ExceptionObject & err ) { MITK_INFO << " ERROR!" << std::endl; MITK_ERROR << "ExceptionObject caught!" << std::endl; MITK_ERROR << err << std::endl; return EXIT_FAILURE; } writer->SetInput( filter->GetOutput() ); if( writer->GetNumberOfInputs() < 1 ) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; try { writer->Write(); } catch( itk::ExceptionObject e) { std::cout<<"caught exception: "<<e<<std::endl; } } } else { std::cout<<"Image not suitable for filter: Dimension!=3"<<std::endl; } std::cout<<"[TEST DONE]"<<std::endl; //writer->Delete(); return EXIT_SUCCESS; }
int mitkMeshTest | ( | int | , |
char * | [] | ||
) |
Definition at line 25 of file mitkMeshTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::PointOperation::GetPoint(), mitk::Mesh::New(), and mitk::OpINSERT.
{ //Create mesh mitk::Mesh::Pointer mesh; mesh = mitk::Mesh::New(); //try to get the itkmesh std::cout << "Create a mesh and try to get the itkMesh"; mitk::Mesh::DataType::Pointer itkdata = NULL; itkdata = mesh->GetMesh(); if (itkdata.IsNull()) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } //fresh mesh has to be empty! std::cout << "Is the mesh empty?"; if (mesh->GetSize() != 0) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } //create an operation and add a point. int position = 0; mitk::Point3D point; point.Fill(1); mitk::PointOperation* doOp = new mitk::PointOperation(mitk::OpINSERT, point, position); mesh->ExecuteOperation(doOp); //now check new condition! if ( (mesh->GetSize()!=1) || (!mesh->IndexExists(position))) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } delete doOp; //get the point and check if it is still the same std::cout << "Create an operation and add a point. Then try to get that point."; mitk::Point3D tempPoint; tempPoint.Fill(0); tempPoint = mesh->GetPoint(position); if (tempPoint != point) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } //well done!!! Passed! std::cout<<"[PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkMultiStepperTest | ( | int | , |
char * | [] | ||
) |
Definition at line 23 of file mitkMultiStepperTest.cpp.
References EXIT_SUCCESS, mitk::MultiStepper::New(), and mitk::Stepper::New().
{ mitk::Stepper::Pointer stepperA; stepperA = mitk::Stepper::New(); mitk::Stepper::Pointer stepperB = mitk::Stepper::New(); stepperA->SetSteps(4); stepperB->SetSteps(6); mitk::MultiStepper::Pointer multiStepper = mitk::MultiStepper::New(); multiStepper->AddStepper(stepperA,2); multiStepper->AddStepper(stepperB); for (int i=0 ; i<10; i++) { std::cout << i << ": A: " << stepperA->GetPos() << " B:" << stepperB->GetPos() << std::endl; multiStepper->Next(); } return EXIT_SUCCESS; }
int mitkOrganTypePropertyTest | ( | int | , |
char * | [] | ||
) |
ctest entry point
Definition at line 22 of file mitkOrganTypePropertyTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, and mitk::OrganTypeProperty::New().
{ const char* NEW_ORGAN = "Der Knopf von der Eingangstuer von der Siebenschlaeferbehausung ist aus Messing damit es nicht so schnell rostet"; // one big variable to tell if anything went wrong unsigned int numberFailed(0); std::cout << "Instantiation" << std::endl; // instantiation mitk::OrganTypeProperty::Pointer prop1 = mitk::OrganTypeProperty::New(); if (prop1.IsNotNull()) { std::cout << " (II) Instantiation works." << std::endl; } else { ++numberFailed; std::cout << numberFailed << " test failed, and it's the ugliest one!" << std::endl; return EXIT_FAILURE; } mitk::OrganTypeProperty::Pointer prop2 = mitk::OrganTypeProperty::New(); if (prop1.IsNotNull()) { std::cout << " (II) Instantiation still works." << std::endl; } else { ++numberFailed; std::cout << numberFailed << " test failed, and it's the ugliest one!" << std::endl; return EXIT_FAILURE; } // add an allowed value to prop1, test if it is now valid for prop2, too prop1->AddEnum( NEW_ORGAN, prop1->Size() ); if ( !prop1->IsValidEnumerationValue( NEW_ORGAN ) ) { ++numberFailed; std::cout << " (EE) New organ is not a valid enumeration type after adding calling AddEnum()." << std::endl; } else { std::cout << " (II) AddEnum() works." << std::endl; } if ( !prop2->IsValidEnumerationValue( NEW_ORGAN ) ) { ++numberFailed; std::cout << " (EE) New organ type did not propagate to a second instance of OrganTypeProperty." << std::endl; } std::cout << "Object destruction" << std::endl; // freeing prop1 = NULL; std::cout << " (II) Freeing works for first property." << std::endl; prop2 = NULL; std::cout << " (II) Freeing works for both properties." << std::endl; if (numberFailed > 0) { std::cout << numberFailed << " tests failed." << std::endl; return EXIT_FAILURE; } else { std::cout << "PASSED all tests." << std::endl; return EXIT_SUCCESS; } }
int mitkOverwriteSliceImageFilterTest | ( | int | , |
char * | [] | ||
) |
ctest entry point
Definition at line 295 of file mitkOverwriteSliceImageFilterTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::OverwriteSliceImageFilter::New(), mitk::DataNodeFactory::New(), mitkOverwriteSliceImageFilterTestClass::Test2D(), mitkOverwriteSliceImageFilterTestClass::Test3D(), and mitkOverwriteSliceImageFilterTestClass::TestOtherD().
{ // one big variable to tell if anything went wrong unsigned int numberFailed(0); // need one parameter (image filename) if(argc==0) { std::cerr<<"No file specified [FAILED]"<<std::endl; return EXIT_FAILURE; } // load the image mitk::Image::Pointer image = NULL; mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { std::cout << "Testing with parameter '" << argv[1] << "'" << std::endl; factory->SetFileName( argv[1] ); factory->Update(); if(factory->GetNumberOfOutputs()<1) { std::cerr<<"File could not be loaded [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::DataNode::Pointer node = factory->GetOutput( 0 ); image = dynamic_cast<mitk::Image*>(node->GetData()); if(image.IsNull()) { std::cout<<"File not an image - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } } catch ( itk::ExceptionObject & ex ) { ++numberFailed; std::cerr << "Exception: " << ex << "[FAILED]" << std::endl; return EXIT_FAILURE; } std::cout << " (II) Could load image." << std::endl; std::cout << "Testing filter instantiation" << std::endl; // instantiation mitk::OverwriteSliceImageFilter::Pointer filter = mitk::OverwriteSliceImageFilter::New(); if (filter.IsNotNull()) { std::cout << " (II) Instantiation works." << std::endl; } else { ++numberFailed; std::cout << "Test failed, and it's the ugliest one!" << std::endl; return EXIT_FAILURE; } // some real work if ( image->GetDimension() == 2 ) { mitkOverwriteSliceImageFilterTestClass::Test2D( filter, image, numberFailed ); } else if ( image->GetDimension() == 3 ) { mitkOverwriteSliceImageFilterTestClass::Test3D( filter, image, numberFailed ); } else { mitkOverwriteSliceImageFilterTestClass::TestOtherD( filter, image, numberFailed ); } std::cout << "Testing filter destruction" << std::endl; // freeing filter = NULL; std::cout << " (II) Freeing works." << std::endl; if (numberFailed > 0) { std::cerr << numberFailed << " tests failed." << std::endl; return EXIT_FAILURE; } else { std::cout << "PASSED all tests." << std::endl; return EXIT_SUCCESS; } }
int mitkPipelineSmartPointerCorrectnessTest | ( | int | , |
char * | [] | ||
) |
Definition at line 328 of file mitkPipelineSmartPointerCorrectnessTest.cpp.
References EXIT_SUCCESS, mitk::Image::New(), and mitk::Surface::New().
{ int result; result = runPipelineSmartPointerCorrectnessTestForFilterType<mitk::SurfaceToImageFilter, mitk::Surface>(mitk::Surface::New()); if( result != EXIT_SUCCESS ) return result; std::cout << std::endl; result = runPipelineSmartPointerCorrectnessTestForFilterType<mitk::GeometryClipImageFilter, mitk::Image>(mitk::Image::New()); if( result != EXIT_SUCCESS ) return result; std::cout << std::endl; result = runPipelineSmartPointerCorrectnessTestForFilterType<TwoOutputsFilter, mitk::Surface>(mitk::Surface::New()); if( result != EXIT_SUCCESS ) return result; result = runPipelineSmartPointerCorrectnessTestForFilterType<mitk::ImageSliceSelector, mitk::Image>(mitk::Image::New()); if( result != EXIT_SUCCESS ) return result; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkPlaneFitTest | ( | int | , |
char * | [] | ||
) |
Definition at line 25 of file mitkPlaneFitTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::PointSet::GetSize(), mitk::Geometry3D::New(), mitk::PointSet::New(), and mitk::PlaneFit::New().
{ //float bounds[]={0.0f,10.0f,0.0f,10.0f,0.0f,5.0f}; mitk::PlaneFit::Pointer PlaneFit = mitk::PlaneFit::New(); mitk::PointSet::Pointer PointSet = mitk::PointSet::New(); mitk::Geometry3D::Pointer Geometry3D = mitk::Geometry3D::New(); mitk::Point3D Point; //first without any point, then incrementally add points within thre points there will be a plane geometry std::cout <<"Start PlaneFitTest "<<std::endl; for(int position=0; position<6; position++) { //add a point directly mitk::FillVector3D(Point, (float) position , (float) position * 1.5 , 2.5); PointSet->GetPointSet()->GetPoints()->InsertElement(position, Point); } //Set Input PlaneFit->SetInput(PointSet); const mitk::PointSet* testPointSet = PlaneFit->GetInput(); std::cout<<" Size test of Input Method: "; if( testPointSet->GetSize() == PointSet->GetSize() ) { std::cout<<"[PASSED]"<<std::endl; } else { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } //Test Centroid std::cout << " Testing centroid calculaation: "; PlaneFit->Update(); const mitk::Point3D ¢roid = PlaneFit->GetCentroid(); mitk::Point3D expectedCentroid; expectedCentroid[0]=2.5; expectedCentroid[1]=3.75; expectedCentroid[2]=2.5; if ( centroid == expectedCentroid ) { std::cout<<"[PASSED]"<<std::endl; } else { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } //Test PlaneGeometry std::cout << " Test PlaneGeometry: "; mitk::Geometry2D* Geometry2D = dynamic_cast<mitk::Geometry2D*>( PlaneFit->GetOutput()->GetGeometry()); if( Geometry2D ) { std::cout<<"[PASSED]"<<std::endl; } else { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkPointLocatorTest | ( | int | , |
char * | [] | ||
) |
Definition at line 38 of file mitkPointLocatorTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, GenerateRandomNumber(), GenerateRandomPoint(), mitk::PointSet::New(), and mitk::PointLocator::New().
{ std::srand( 1 ); unsigned int num_points = 10000; // Create PointSet with randomly defined point std::cout << "Creating random point set of 10000 points "; vtkPoints* points = vtkPoints::New(); if ( points == NULL ) { std::cout << "vtkPoints == NULL. [FAILED]" << std::endl; return EXIT_FAILURE; } for (unsigned int i = 0; i < num_points ; ++i ) { points->InsertPoint(i, GenerateRandomNumber(), GenerateRandomNumber(), GenerateRandomNumber()); } vtkPolyData* pointSet = vtkPolyData::New(); pointSet->SetPoints( points ); points->Delete(); if ( (unsigned) pointSet->GetNumberOfPoints() != num_points ) { std::cout << "Number of points in the vtkPointSet != "<< num_points <<". [FAILED]" << std::endl; return EXIT_FAILURE; } std::cout << "[PASSED]" << std::endl; // feed the point set into a vtk point locator std::cout << "Building vtkPointLocator "; vtkPointLocator* vtkPointLoc = vtkPointLocator::New(); vtkPointLoc->SetDataSet( pointSet ); vtkPointLoc->BuildLocator(); std::cout << "[PASSED]" << std::endl; // feed the point set into the mitk point locator std::cout << "Building mitkPointLocator "; mitk::PointLocator::Pointer mitkPointLocator = mitk::PointLocator::New(); mitk::PointLocator::Pointer mitkPointLocator2 = mitk::PointLocator::New(); if ( mitkPointLocator.IsNull() ) { std::cout << "[FAILED]" << std::endl; return EXIT_FAILURE; } else { std::cout << "[PASSED]" << std::endl; } mitk::PointSet::Pointer mitkPointSet = mitk::PointSet::New(); for ( int i=0; i<pointSet->GetNumberOfPoints();i++ ) { mitk::Point3D pnt; pnt[0] = pointSet->GetPoint( i )[0]; pnt[1] = pointSet->GetPoint( i )[1]; pnt[2] = pointSet->GetPoint( i )[2]; mitkPointSet->InsertPoint(i, pnt ); } std::cout << "Setting random point set "; mitkPointLocator->SetPoints( pointSet ); mitkPointLocator2->SetPoints( mitkPointSet ); std::cout << "[PASSED]" << std::endl; std::cout << "Testing 1000 random points "; // generate N random points and calculate the closest // points with both the vtk and mitk pointlocator. // verify, that the point ids are the same. vtkFloatingPointType p[3], x, y, z; mitk::PointSet::PointType pointType; for ( unsigned int i = 0 ; i < 1000 ; ++i ) { GenerateRandomPoint( x, y, z ); p[0] = x; p[1] = y; p[2] = z; pointType[0] = p[0]; pointType[1] = p[1]; pointType[2] = p[2]; int closestPoint1 = vtkPointLoc->FindClosestPoint(p); int closestPoint2 = mitkPointLocator->FindClosestPoint(p); int closestPoint3 = mitkPointLocator->FindClosestPoint(x, y, z); int closestPoint4 = mitkPointLocator2->FindClosestPoint(p); int closestPoint5 = mitkPointLocator2->FindClosestPoint(pointType); if ( closestPoint1 != closestPoint2 ) { std::cout << "Id returned by vtkPointLocator doesn't match the one returned by mitk::PointLocator. [FAILED]" << std::endl; return EXIT_FAILURE; } if ( closestPoint2 != closestPoint3 ) { std::cout << "There is a mismatch between passing coords as array and as single x/y/z coords. [FAILED]" << std::endl; return EXIT_FAILURE; } if ( closestPoint2 != closestPoint4 ) { std::cout << "There is a mismatch between passing the points as mitkPointSet and vtkPointSet. [FAILED]" << std::endl; return EXIT_FAILURE; } if ( closestPoint4 != closestPoint5 ) { std::cout << "There is a mismatch between passing coords as array and as single x/y/z coords when using MITK-Types. [FAILED]" << std::endl; return EXIT_FAILURE; } } vtkPointLoc->Delete(); pointSet->Delete(); std::cout << "[PASSED]" << std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkSurfaceToImageFilterTest | ( | int | , |
char * | [] | ||
) |
Definition at line 27 of file mitkSurfaceToImageFilterTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::Image::New(), mitk::DataNodeFactory::New(), and mitk::SurfaceToImageFilter::New().
{ mitk::SurfaceToImageFilter::Pointer s2iFilter; std::cout << "Testing mitk::Surface::New(): " << std::flush; s2iFilter = mitk::SurfaceToImageFilter::New(); if (s2iFilter.IsNull()) { std::cout<<"[FAILED]"<<std::endl; return EXIT_FAILURE; } else { std::cout<<"[PASSED]"<<std::endl; } std::cout << "Loading file: " << std::flush; if(argc==0) { std::cout<<"no file specified [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::Surface::Pointer surface = NULL; mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { std::cout<<argv[1]<<std::endl; factory->SetFileName( argv[1] ); factory->Update(); if(factory->GetNumberOfOutputs()<1) { std::cout<<"file could not be loaded [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::DataNode::Pointer node = factory->GetOutput( 0 ); surface = dynamic_cast<mitk::Surface*>(node->GetData()); if(surface.IsNull()) { std::cout<<"file not a surface - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } } catch ( itk::ExceptionObject & ex ) { std::cout << "Exception: " << ex << "[FAILED]" << std::endl; return EXIT_FAILURE; } std::cout << "Testing number of points of surface: " << std::flush; if(surface->GetVtkPolyData()->GetNumberOfPoints() == 0) { std::cout<<"number of points is 0 - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } std::cout << "Testing creation of mitk::Image with same Geometry as Surface: " << std::flush; mitk::Image::Pointer image = mitk::Image::New(); //surface->UpdateOutputInformation(); //is not necessary anymore (bug #1536), should never be neccessary image->Initialize(typeid(unsigned int), *surface->GetGeometry()); std::cout << "Testing mitk::SurfaceToImageFilter::MakeOutputBinaryOn(): " << std::flush; s2iFilter->MakeOutputBinaryOn(); std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing mitk::SurfaceToImageFilter::SetInput(): " << std::flush; s2iFilter->SetInput(surface); std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing mitk::SurfaceToImageFilter::SetImage(): " << std::flush; s2iFilter->SetImage(image); std::cout<<"[PASSED]"<<std::endl; std::cout << "Testing mitk::SurfaceToImageFilter::Update(): " << std::flush; s2iFilter->Update(); std::cout<<"[PASSED]"<<std::endl; #ifdef WIN32 // Unix based systems do not seem to resolve pixel type correctly std::cout << "Testing if result image is of type unsigned char: " << std::flush; std::string typeId = s2iFilter->GetOutput()->GetPixelType().GetItkTypeAsString(); std::cout << std::endl << "XXX: " << typeId << std::endl; if( typeId != "unsigned char" ) { if(typeId != "unknown") return EXIT_FAILURE; else std::cout << "Warning: Pixel type can't be resolved." << std::flush; } std::cout<<"[PASSED]"<<std::endl; #endif //mitk::PicFileWriter::Pointer picWriter = mitk::PicFileWriter::New(); //picWriter->SetInput(s2iFilter->GetOutput()); //picWriter->SetFileName("SurfaceToImageFilterTestOutput.pic"); //picWriter->Write(); std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; }
int mitkToolManagerTest | ( | int | , |
char * | [] | ||
) |
Definition at line 62 of file mitkToolManagerTest.cpp.
References mitk::GlobalInteraction::GetInstance(), MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, mitk::ToolManager::New(), mitk::StandaloneDataStorage::New(), mitkToolManagerTestClass::TestSetterMethods(), and mitkToolManagerTestClass::TestToolManagerWithTools().
{ // always start with this! MITK_TEST_BEGIN("ToolManager") // Global interaction must(!) be initialized if used mitk::GlobalInteraction::GetInstance()->Initialize("global"); // instantiation mitk::StandaloneDataStorage::Pointer dataStorage = mitk::StandaloneDataStorage::New(); mitk::ToolManager::Pointer toolManager = mitk::ToolManager::New(dataStorage.GetPointer()); // first test: did this work? // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since // it makes no sense to continue without an object. MITK_TEST_CONDITION_REQUIRED(toolManager.IsNotNull(),"Testing instantiation") // write your own tests here and use the macros from mitkTestingMacros.h !!! // do not write to std::cout and do not return from this function yourself! //mitkToolManagerTestClass::TestToolManagerWithOutTools(toolManager); //now we add one tool toolManager = mitk::ToolManager::New(dataStorage.GetPointer()); //start test with tool mitkToolManagerTestClass::TestToolManagerWithTools(toolManager); //now the setter methods mitkToolManagerTestClass::TestSetterMethods(toolManager); // always end with this! MITK_TEST_END() }
int mitkUnstructuredGridVtkWriterTest | ( | int | argc, |
char * | argv[] | ||
) |
Simple example for a test for the (non-existent) class "ClassName".
argc and argv are the command line parameters which were passed to the ADD_TEST command in the CMakeLists.txt file. For the automatic tests, argv is either empty for the simple tests or contains the filename of a test image for the image tests (see CMakeLists.txt).
Definition at line 36 of file mitkUnstructuredGridVtkWriterTest.cpp.
References EXIT_FAILURE, MITK_INFO, MITK_TEST_BEGIN, MITK_TEST_CONDITION_REQUIRED, MITK_TEST_END, MITK_TEST_FOR_EXCEPTION_BEGIN, MITK_TEST_FOR_EXCEPTION_END, mitk::VtkUnstructuredGridReader::New(), mitk::UnstructuredGridVtkWriter< VTKWRITER >::New(), mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetFileName(), mitk::UnstructuredGridVtkWriter< VTKWRITER >::SetInput(), and mitk::UnstructuredGridVtkWriter< VTKWRITER >::Update().
{ // always start with this! MITK_TEST_BEGIN("UnstructuredGridVtkWriter") //let's create an object of our class mitk::UnstructuredGridVtkWriter<vtkUnstructuredGridWriter>::Pointer myUnstructuredGridVtkWriter = mitk::UnstructuredGridVtkWriter<vtkUnstructuredGridWriter>::New(); // first test: did this work? // using MITK_TEST_CONDITION_REQUIRED makes the test stop after failure, since // it makes no sense to continue without an object. MITK_TEST_CONDITION_REQUIRED(myUnstructuredGridVtkWriter.IsNotNull(),"Testing instantiation") if (argc<1) { MITK_INFO<<"Command line argument missing"; return 0; } // create contour by reading the file given in argv[1] mitk::UnstructuredGrid::Pointer unstructuredGrid; mitk::VtkUnstructuredGridReader::Pointer reader = mitk::VtkUnstructuredGridReader::New(); try { reader->SetFileName(argv[1]); reader->Update(); unstructuredGrid = reader->GetOutput(); } catch (itk::ExceptionObject e) { MITK_INFO<<e.GetDescription(); return 0; } try{ // test if exception is thrown when unstructured grid is tried to be saved in an non-existing/non-writable folder/file MITK_TEST_FOR_EXCEPTION_BEGIN(itk::ExceptionObject) myUnstructuredGridVtkWriter->SetInput(unstructuredGrid); // set non-existing (windows), non-writable (linux) file name myUnstructuredGridVtkWriter->SetFileName("/usr/bin"); myUnstructuredGridVtkWriter->Update(); MITK_TEST_FOR_EXCEPTION_END(itk::ExceptionObject) } catch(...) { //this means that a wrong exception (i.e. no itk:Exception) has been thrown MITK_INFO << "Wrong exception (i.e. no itk:Exception) caught during write [FAILED]" << std::endl; return EXIT_FAILURE; } //write your own tests here and use the macros from mitkTestingMacros.h !!! //do not write to std::cout and do not return from this function yourself! //always end with this! MITK_TEST_END() }
Definition at line 44 of file MitkExtTestDriver.cpp.