/**Documentation * Test if fiber transfortaiom methods work correctly */ int mitkFiberTransformationTest(int argc, char* argv[]) { MITK_TEST_BEGIN("mitkFiberTransformationTest"); MITK_TEST_CONDITION_REQUIRED(argc==3,"check for input data") try{ RegisterFiberTrackingObjectFactory(); mitk::FiberBundleX::Pointer groundTruthFibs = dynamic_cast<mitk::FiberBundleX*>(mitk::IOUtil::LoadDataNode(argv[1])->GetData()); mitk::FiberBundleX::Pointer transformedFibs = dynamic_cast<mitk::FiberBundleX*>(mitk::IOUtil::LoadDataNode(argv[2])->GetData()); groundTruthFibs->RotateAroundAxis(90, 45, 10); groundTruthFibs->TranslateFibers(2, 3, 5); groundTruthFibs->ScaleFibers(1, 0.1, 1.3); groundTruthFibs->RemoveLongFibers(150); groundTruthFibs->RemoveShortFibers(20); groundTruthFibs->DoFiberSmoothing(1.0); groundTruthFibs->ApplyCurvatureThreshold(3.0, true); groundTruthFibs->MirrorFibers(0); groundTruthFibs->MirrorFibers(1); groundTruthFibs->MirrorFibers(2); MITK_TEST_CONDITION_REQUIRED(groundTruthFibs->Equals(transformedFibs),"check transformation") } catch(...) { return EXIT_FAILURE; } // always end with this! MITK_TEST_END(); }
int mitkACVDTest(int argc, char* argv[]) { if (argc != 10) { MITK_ERROR << "Invalid argument count!\n" << "Usage: mitkACVDTest <filename> <t> <numVertices> <gradation> <subsampling>\n" << " <edgeSplitting> <optimizationLevel> <forceManifiold>\n" << " <boundaryFixing>\n" << " See MITK API documentation of mitk::ACVD::Remesh() for details."; return EXIT_FAILURE; } const std::string filename = argv[1]; const unsigned int t = lexical_cast<unsigned int>(argv[2]); const int numVertices = lexical_cast<int>(argv[3]); const double gradation = lexical_cast<double>(argv[4]); const int subsampling = lexical_cast<int>(argv[5]); const double edgeSplitting = lexical_cast<double>(argv[6]); const int optimizationLevel = lexical_cast<int>(argv[7]); const bool forceManifold = lexical_cast<bool>(argv[8]); const bool boundaryFixing = lexical_cast<bool>(argv[9]); MITK_TEST_BEGIN("mitkACVDTest") Remesh_SurfaceIsNull_ThrowsException(); Remesh_PolyDataIsNull_ThrowsException(); Remesh_SurfaceDoesNotHaveDataAtTimeStep_ThrowsException(); Remesh_SurfaceHasNoPolygons_ThrowsException(); Remesh_SurfaceIsValid_ReturnsRemeshedSurface(filename, t, numVertices, gradation, subsampling, edgeSplitting, optimizationLevel, forceManifold, boundaryFixing); MITK_TEST_END() }
int mitkPropertyDescriptionsTest(int, char* []) { MITK_TEST_BEGIN("mitkPropertyDescriptionsTest"); mitk::IPropertyDescriptions* propertyDescriptions = mitk::CoreServices::GetPropertyDescriptions(); MITK_TEST_CONDITION_REQUIRED(propertyDescriptions != NULL, "Get property descriptions service"); propertyDescriptions->AddDescription("propertyName1", "description1a"); propertyDescriptions->AddDescription("propertyName1", "description1b"); std::string description1 = propertyDescriptions->GetDescription("propertyName1"); MITK_TEST_CONDITION( description1 == "description1a", "Get description of \"propertyName1\""); propertyDescriptions->AddDescription("propertyName1", "description1b", "", true); description1 = propertyDescriptions->GetDescription("propertyName1"); MITK_TEST_CONDITION( description1 == "description1b", "Get overwritten description of \"propertyName1\""); propertyDescriptions->AddDescription("propertyName1", "description1c", "className"); std::string description2 = propertyDescriptions->GetDescription("propertyName1", "className"); description1 = propertyDescriptions->GetDescription("propertyName1"); MITK_TEST_CONDITION( description1 == "description1b" && description2 == "description1c", "Get description of \"propertyName1\" restricted to \"className\""); MITK_TEST_END(); }
int mitkSurfaceDepthSortingTest(int argc, char *argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkRenderingDepthSortingTest") mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); renderingHelper.SetMapperIDToRender3D(); mitk::DataNode *dataNode = renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Surface")); if (dataNode) { dataNode->SetOpacity(0.8); dataNode->SetBoolProperty("Depth Sorting", true); dataNode->Update(); } //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?"); MITK_TEST_END(); }
int mitkGenericPropertyTest(int /*argc*/, char* /*argv*/[]) { MITK_TEST_BEGIN(GenericPropertyTest) // testing for some different data types TestGenericPropertyForDataType<mitk::IntProperty>(1, 2, "1", "2", "int"); TestGenericPropertyForDataType<mitk::BoolProperty>(true, false, "1", "0", "bool"); TestGenericPropertyForDataType<mitk::FloatProperty>(1.0, -1.0, "1", "-1", "float"); TestGenericPropertyForDataType<mitk::DoubleProperty>(1.0, -1.0, "1", "-1", "double"); TestGenericPropertyForDataType<mitk::StringProperty>(std::string("eins"), std::string("zwei"), std::string("eins"), std::string("zwei"), "std::string"); { mitk::Point3D p1; p1[0] = 2.0; p1[1] = 3.0; p1[2] = 4.0; mitk::Point3D p2; p2[0] =-1.0; p2[1] = 2.0; p2[2] = 3.0; TestGenericPropertyForDataType<mitk::Point3dProperty>( p1, p2, "[2, 3, 4]", "[-1, 2, 3]", "mitk::Point3D"); } { mitk::Point4D p1; p1[0] = 2.0; p1[1] = 3.0; p1[2] = 4.0; p1[3] =-2.0; mitk::Point4D p2; p2[0] =-1.0; p2[1] = 2.0; p2[2] = 3.0; p2[3] = 5.0; TestGenericPropertyForDataType<mitk::Point4dProperty>( p1, p2, "[2, 3, 4, -2]", "[-1, 2, 3, 5]", "mitk::Point4D"); } /* THIS won't compile because of the interface of XMLWriter... that should be reworked perhaps { mitk::Vector2D p1; p1[0] = 2.0; p1[1] = 3.0; mitk::Vector2D p2; p2[0] =-1.0; p2[1] = 2.0; TestGenericPropertyForDataType<mitk::Vector2D>( p1, p2, "[2, 3]", "[-1, 2]", "mitk::Vector2D"); } */ { mitk::Vector3D p1; p1[0] = 2.0; p1[1] = 3.0; p1[2] = 4.0; mitk::Vector3D p2; p2[0] =-1.0; p2[1] = 2.0; p2[2] = 3.0; TestGenericPropertyForDataType<mitk::Vector3DProperty>( p1, p2, "[2, 3, 4]", "[-1, 2, 3]", "mitk::Vector3D"); } MITK_TEST_END(); }
/**Documentation * Test for factory registration */ int mitkFactoryRegistrationTest(int /* argc */, char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("FactoryRegistrationTest"); MITK_INFO << "Starting Factory registration test."; MITK_INFO << "Factory has been registered."; bool canWrite = false; mitk::DiffusionImage<short>::Pointer img = mitk::DiffusionImage<short>::New(); mitk::CoreObjectFactory::FileWriterList fileWriters = mitk::CoreObjectFactory::GetInstance()->GetFileWriters(); MITK_INFO << "Looking for diffusion image writer."; for (mitk::CoreObjectFactory::FileWriterList::iterator it = fileWriters.begin() ; it != fileWriters.end() ; ++it) { if ( (*it)->CanWriteBaseDataType(img.GetPointer()) ) { MITK_INFO << "Found diffusion image writer."; canWrite = true; break; } } MITK_TEST_CONDITION_REQUIRED(canWrite,"Testing factory registration"); // always end with this! MITK_TEST_END(); }
int mitkPointSetVtkMapper2DImageTest(int argc, char* argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkPointSetVtkMapper2DImageTest") mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); // disables anti-aliasing which is enabled on several graphics cards and // causes problems when doing a pixel-wise comparison to a reference image renderingHelper.GetVtkRenderWindow()->SetMultiSamples(0); //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); //use this to generate a reference screenshot or save the file: if(false) { renderingHelper.SaveReferenceScreenShot("C:/development_ITK4/output.png"); } MITK_TEST_END(); }
/** * This function is testing the Class mitk::NavigationData. For most tests we would need the MicronTracker hardware, so only a few * simple tests, which can run without the hardware are implemented yet (2009, January, 23rd). As soon as there is a working * concept to test the tracking classes which are very close to the hardware on all systems more tests are needed here. */ int mitkNavigationDataTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("NavigationData"); //TestInstatiation(); //TestGetterSetter(); //TestGraft(); //TestPrintSelf(); //TestWrongInputs(); //TestAffineConstructor(); //TestAffineConstructorErrorDeterminantNonEqualOne(); //TestAffineConstructorErrorTransposedNotInverse(); //TestAffineConstructorErrorCheckingFalse(); //TestAffineGetter(); //TestAffineToNaviDataToAffine(); //TestTransform(); //TestInverse(); //TestDoubleInverse(); TestInverseError(); //TestCompose(); //TestReverseCompose(); MITK_TEST_END(); }
/**Documentation * test for the class "ToFImageWriter". */ int mitkToFImageWriterTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("ToFImageWriter"); //testing initialization of object mitk::ToFImageWriter::Pointer tofWriter = mitk::ToFImageWriter::New(); MITK_TEST_CONDITION_REQUIRED(tofWriter.GetPointer(), "Testing initialization of test object!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetExtension()!= "", "Test initialization of member extension!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetDistanceImageFileName()== "", "Test initialization of member distanceImageFileName!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetAmplitudeImageFileName()== "", "Test initialization of member amplitudeImageFileName!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetIntensityImageFileName()== "", "Test initialization of member intnensityImageFileName!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetDistanceImageSelected()==true, "Test initialization of member distanceImageSelected!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetAmplitudeImageSelected()==false, "Test initialization of member amplitudeImageSelected!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetIntensityImageSelected()==false, "Test initialization of member intensityImageSelected!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetRGBImageSelected()==false, "Test initialization of member rgbImageSelected!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFCaptureWidth()== 200, "Test initialization of member captureWidth!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFCaptureHeight()== 200, "Test initialization of member captureHeight!"); MITK_TEST_CONDITION_REQUIRED(tofWriter->GetToFImageType()== mitk::ToFImageWriter::ToFImageType3D, "Test initialization of member ToFImageType!"); //set member parameter and test again unsigned int dimX = 255; unsigned int dimY = 188; std::string distanceImageFileName("distImg.pic"); std::string amplitudeImageFileName("amplImg.pic"); std::string intensityImageFileName("intImg.pic"); std::string rgbImageFileName("rgbImg.pic"); std::string fileExtension(".test"); bool distanceImageSelected = false; bool amplitudeImageSelected = false; bool intensityImageSelected = false; bool rgbImageSelected = false; tofWriter->SetToFCaptureWidth(dimX); tofWriter->SetToFCaptureHeight(dimY); tofWriter->SetDistanceImageFileName(distanceImageFileName); tofWriter->SetAmplitudeImageFileName(amplitudeImageFileName); tofWriter->SetIntensityImageFileName(intensityImageFileName); tofWriter->SetRGBImageFileName(rgbImageFileName); tofWriter->SetExtension(fileExtension); tofWriter->SetDistanceImageSelected(distanceImageSelected); tofWriter->SetAmplitudeImageSelected(amplitudeImageSelected); tofWriter->SetIntensityImageSelected(intensityImageSelected); tofWriter->SetRGBImageSelected(rgbImageSelected); tofWriter->SetToFImageType(mitk::ToFImageWriter::ToFImageType2DPlusT); MITK_TEST_CONDITION_REQUIRED(distanceImageFileName==tofWriter->GetDistanceImageFileName(), "Testing set/get distance image file name"); MITK_TEST_CONDITION_REQUIRED(amplitudeImageFileName==tofWriter->GetAmplitudeImageFileName(), "Testing set/get amplitude image file name"); MITK_TEST_CONDITION_REQUIRED(intensityImageFileName==tofWriter->GetIntensityImageFileName(), "Testing set/get intensity image file name"); MITK_TEST_CONDITION_REQUIRED(rgbImageFileName==tofWriter->GetRGBImageFileName(), "Testing set/get rgb image file name"); MITK_TEST_CONDITION_REQUIRED(dimX==tofWriter->GetToFCaptureWidth(), "Testing set/get CaptureWidth"); MITK_TEST_CONDITION_REQUIRED(dimY==tofWriter->GetToFCaptureHeight(), "Testing set/get CaptureHeight"); MITK_TEST_CONDITION_REQUIRED(distanceImageSelected==tofWriter->GetDistanceImageSelected(), "Testing set/get distance image selection"); MITK_TEST_CONDITION_REQUIRED(amplitudeImageSelected==tofWriter->GetAmplitudeImageSelected(), "Testing set/get amplitude image selection"); MITK_TEST_CONDITION_REQUIRED(intensityImageSelected==tofWriter->GetIntensityImageSelected(), "Testing set/get intensity image selection"); MITK_TEST_CONDITION_REQUIRED(rgbImageSelected==tofWriter->GetRGBImageSelected(), "Testing set/get rgb image selection"); MITK_TEST_CONDITION_REQUIRED(fileExtension==tofWriter->GetExtension(), "Testing set/get file extension"); MITK_TEST_CONDITION_REQUIRED(mitk::ToFImageWriter::ToFImageType2DPlusT==tofWriter->GetToFImageType(), "Testing set/get ToFImageType"); MITK_TEST_END(); }
/**Documentation * test for the class "ToFCameraPMDCamCubeController". */ int mitkToFCameraPMDCamCubeControllerTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("ToFCameraPMDCamCubeController"); mitk::ToFCameraPMDCamCubeController::Pointer camCubeController = mitk::ToFCameraPMDCamCubeController::New(); try { MITK_TEST_CONDITION_REQUIRED(camCubeController.IsNotNull(),"Testing initialzation!"); MITK_TEST_CONDITION_REQUIRED(camCubeController->GetCaptureHeight()== 200 ,"Testing initialization of CaptureHeight"); MITK_TEST_CONDITION_REQUIRED(camCubeController->GetCaptureWidth()== 200 ,"Testing initialization of CaptureWidth"); MITK_TEST_CONDITION_REQUIRED(camCubeController->OpenCameraConnection(),"Testing opening of camera connection!"); MITK_TEST_CONDITION_REQUIRED(camCubeController->UpdateCamera(),"Testing UpdateCamera()"); MITK_TEST_CONDITION_REQUIRED(camCubeController->SetDistanceOffset(0.5f),"Testing SetDistanceOffset()"); MITK_TEST_OUTPUT(<<"Call GetDistanceOffset()"); MITK_INFO<<camCubeController->GetDistanceOffset(); MITK_TEST_CONDITION_REQUIRED(camCubeController->SetRegionOfInterest(3,5,200,201),"Testing SetRegionOfInterest()"); MITK_TEST_OUTPUT(<<"Call GetRegionOfInterest()"); MITK_INFO<<camCubeController->GetRegionOfInterest(); MITK_TEST_CONDITION_REQUIRED(camCubeController->SetExposureMode(0),"Testing SetExposureMode()"); MITK_TEST_CONDITION_REQUIRED(camCubeController->SetFieldOfView(35.7f),"Testing SetFieldOfView()"); MITK_TEST_CONDITION_REQUIRED(camCubeController->SetFPNCalibration(true),"Testing SetFPNCalibration()"); MITK_TEST_CONDITION_REQUIRED(camCubeController->SetFPPNCalibration(true),"Testing SetFPPNCalibration()"); MITK_TEST_CONDITION_REQUIRED(camCubeController->SetLinearityCalibration(true),"Testing SetLinearityCalibration()"); MITK_TEST_CONDITION_REQUIRED(camCubeController->SetLensCalibration(true),"Testing SetLensCalibration()"); MITK_TEST_CONDITION_REQUIRED(camCubeController->CloseCameraConnection(),"Testing closing of camera connection!"); } catch(std::exception &e) { MITK_INFO << e.what(); } MITK_TEST_END(); }
int mitkTextOverlay2DRenderingTest(int argc, char* argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkTextOverlay2DRenderingTest") mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); // renderingHelper.SetAutomaticallyCloseRenderWindow(false); mitk::BaseRenderer* renderer = mitk::BaseRenderer::GetInstance(renderingHelper.GetVtkRenderWindow()); mitk::OverlayManager::Pointer OverlayManager = mitk::OverlayManager::New(); renderer->SetOverlayManager(OverlayManager); //Add the overlay to the overlayManager. It is added to all registered renderers automaticly OverlayManager->AddOverlay(createTextOverlay(20,1,0,0,200,400,"Test1").GetPointer()); OverlayManager->AddOverlay(createTextOverlay(30,0,1,0,400,400,"Test2").GetPointer()); OverlayManager->AddOverlay(createTextOverlay(15,0,0,1,400,200,"Test3").GetPointer()); OverlayManager->AddOverlay(createTextOverlay(10,1,0,0,20,200,"Test4").GetPointer()); renderingHelper.Render(); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { renderingHelper.SaveReferenceScreenShot("/home/christoph/Pictures/RenderingTestData/mitkTextOverlay2DRenderingTest_ball.png"); } //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); MITK_TEST_END(); }
int mitkSurfaceGLMapper2DOpacityTest(int argc, char* argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkSurfaceGLMapper2DOpacityTest") mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //Set the opacity for all images renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Surface"))->SetProperty("opacity", mitk::FloatProperty::New(0.5f)); //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); //#################### //Use this to generate a reference screenshot or save the file. //(Only in your local version of the test!) if(false) { renderingHelper.SaveReferenceScreenShot("/home/kilgus/Pictures/RenderingTestData/output.png"); } //#################### MITK_TEST_END(); }
int mitkImageVtkMapper2DOpacityTest(int argc, char* argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkImageVtkMapper2DTest") mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //Set the opacity for all images renderingHelper.SetImageProperty("opacity", mitk::FloatProperty::New(0.5f)); //for now this test renders in coronal view direction renderingHelper.SetViewDirection(mitk::SliceNavigationController::Frontal); //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); //use this to generate a reference screenshot or save the file: if(false) { renderingHelper.SaveReferenceScreenShot("d:/tmp/renderingtest.png"); } MITK_TEST_END(); }
/**Documentation * Test for mitk::NDIProtocol */ int mitkNDIProtocolTest(int /* argc */, char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("NDIProtocolTest"); // let's create an object of our class mitk::NDIProtocol::Pointer myNDIProtocol = NDIProtocolTestClass::New().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(myNDIProtocol.IsNotNull(),"Testing instantiation"); //COMM(mitk::SerialCommunication::BaudRate baudRate , mitk::SerialCommunication::DataBits dataBits, mitk::SerialCommunication::Parity parity, mitk::SerialCommunication::StopBits stopBits, mitk::SerialCommunication::HardwareHandshake hardwareHandshake) //No testing possible, hardware required //All other methods //No testing possible, hardware required // always end with this! MITK_TEST_END(); }
/**Documentation * test for the class "ToFProcessingCommon". */ int mitkToFProcessingCommonTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("ToFProcessingCommon"); unsigned int i = 10; unsigned int j = 50; mitk::ScalarType distance = 1000; mitk::ScalarType focalLength = 10; mitk::Point2D interPixelDistance; interPixelDistance[0] = 0.05; interPixelDistance[1] = 0.05; mitk::Point2D principalPoint; principalPoint[0] = 100; principalPoint[1] = 100; // expected coordinate mitk::ToFProcessingCommon::ToFPoint3D expectedCoordinate; expectedCoordinate[0] = -400.0988; expectedCoordinate[1] = -222.2771; expectedCoordinate[2] = 889.1084; // resulting coordinate mitk::ToFProcessingCommon::ToFPoint3D resultingCoordinate = mitk::ToFProcessingCommon::IndexToCartesianCoordinates(i,j,distance,focalLength,interPixelDistance,principalPoint); MITK_TEST_CONDITION_REQUIRED(mitk::Equal(expectedCoordinate,resultingCoordinate),"Testing IndexToCartesianCoordinates()"); // expected index mitk::ToFProcessingCommon::ToFPoint3D expectedIndex; expectedIndex[0] = i; expectedIndex[1] = j; expectedIndex[2] = 1000; mitk::ToFProcessingCommon::ToFPoint3D resultingIndex = mitk::ToFProcessingCommon::CartesianToIndexCoordinates(expectedCoordinate,focalLength,interPixelDistance,principalPoint); MITK_TEST_CONDITION_REQUIRED(mitk::Equal(expectedIndex,resultingIndex),"Testing CartesianToIndexCoordinates()"); MITK_TEST_END(); }
int mitkSceneIOCompatibilityTest(int argc, char *argv[]) { try { mitk::RenderingTestHelper openGlTest(640, 480); } catch (const mitk::TestNotRunException &e) { MITK_WARN << "Test not run: " << e.GetDescription(); return 77; } // Load all arguments but last into a DataStorage, // Take last argument as reference rendering. // // Setup a renderwindow of fixed size X*Y. // Render the DataStorage. // Compare rendering to reference image. MITK_TEST_BEGIN("mitkSceneIOCompatibilityTest") mitk::RenderingTestHelper renderingHelper(200, 200, argc, argv); // Usage of CompareRenderWindowAgainstReference: See documentation of mitkRenderingTestHelper MITK_TEST_CONDITION(renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?"); // You can use this to generate a new reference // on your platform or after changes: if (false) { renderingHelper.SaveReferenceScreenShot("/where/you/want.png"); } MITK_TEST_END(); }
int mitkPropertyExtensionsTest(int, char *[]) { MITK_TEST_BEGIN("mitkPropertyExtensionsTest"); mitk::IPropertyExtensions *propertyExtensions = mitk::CoreServices::GetPropertyExtensions(); MITK_TEST_CONDITION_REQUIRED(propertyExtensions != NULL, "Get property extensions service"); propertyExtensions->AddExtension("propertyName1", TestPropertyExtension::New("extension1a").GetPointer()); propertyExtensions->AddExtension("propertyName1", TestPropertyExtension::New("extension1b").GetPointer()); TestPropertyExtension::Pointer extension1 = dynamic_cast<TestPropertyExtension *>(propertyExtensions->GetExtension("propertyName1").GetPointer()); MITK_TEST_CONDITION(extension1.IsNotNull() && extension1->GetName() == "extension1a", "Get extension of \"propertyName1\""); propertyExtensions->AddExtension("propertyName1", TestPropertyExtension::New("extension1b").GetPointer(), "", true); extension1 = dynamic_cast<TestPropertyExtension *>(propertyExtensions->GetExtension("propertyName1").GetPointer()); MITK_TEST_CONDITION(extension1.IsNotNull() && extension1->GetName() == "extension1b", "Get overwritten extension of \"propertyName1\""); propertyExtensions->AddExtension( "propertyName1", TestPropertyExtension::New("extension1c").GetPointer(), "className"); TestPropertyExtension::Pointer extension2 = dynamic_cast<TestPropertyExtension *>(propertyExtensions->GetExtension("propertyName1", "className").GetPointer()); extension1 = dynamic_cast<TestPropertyExtension *>(propertyExtensions->GetExtension("propertyName1").GetPointer()); MITK_TEST_CONDITION(extension1.IsNotNull() && extension1->GetName() == "extension1b" && extension2.IsNotNull() && extension2->GetName() == "extension1c", "Get extension of \"propertyName1\" restricted to \"className\""); MITK_TEST_END(); }
int mitkImageVtkMapper2DLevelWindowTest(int argc, char* argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkImageVtkMapper2DTest") mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //chose a level window: here we randomly chosen the blood preset. mitk::LevelWindowPreset* levelWindowPreset = mitk::LevelWindowPreset::New(); bool loadedPreset = levelWindowPreset->LoadPreset(); MITK_TEST_CONDITION_REQUIRED(loadedPreset == true, "Testing if level window preset could be loaded"); double level = levelWindowPreset->getLevel("Blood"); double window = levelWindowPreset->getWindow("Blood"); //apply level window to all images renderingHelper.SetImageProperty("levelwindow", mitk::LevelWindowProperty::New(mitk::LevelWindow(level, window)) ); //for now this test renders Sagittal renderingHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); //use this to generate a reference screenshot or save the file: if(false) { renderingHelper.SaveReferenceScreenShot("/media/hdd/thomasHdd/Pictures/tmp/output1.png"); } MITK_TEST_END(); }
/** * mitkplanarPolygonTest tests the methods and behavior of mitk::PlanarPolygon with sub-tests: * * 1. Instantiation and basic tests, including feature evaluation * */ int mitkPlanarPolygonTest(int /* argc */, char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("planarPolygon") // create PlaneGeometry on which to place the planarPolygon mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New(); planeGeometry->InitializeStandardPlane( 100.0, 100.0 ); // ************************************************************************** // 1. Instantiation and basic tests, including feature evaluation mitk::PlanarPolygon::Pointer planarPolygon = mitk::PlanarPolygon::New(); planarPolygon->SetGeometry2D( planeGeometry ); // first test: did this work? MITK_TEST_CONDITION_REQUIRED( planarPolygon.IsNotNull(), "Testing instantiation" ); // Test placement of planarPolygon by control points mitkPlanarPolygonTestClass::TestPlanarPolygonPlacement( planarPolygon ); mitkPlanarPolygonTestClass::TestPlanarPolygonEditing( planarPolygon ); // always end with this! MITK_TEST_END(); }
int mitkImageVtkMapper2DColorTest(int argc, char* argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkImageVtkMapper2DTest") mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); //Set the opacity for all images renderingHelper.SetImageProperty("color", mitk::ColorProperty::New(0.0f, 0.0f, 255.0f)); //for now this test renders in sagittal view direction renderingHelper.SetViewDirection(mitk::SliceNavigationController::Sagittal); //#################### //Use this to generate a reference screenshot or save the file. //(Only in your local version of the test!) if(false) { renderingHelper.SaveReferenceScreenShot("/home/kilgus/Pictures/RenderingTestData/output.png"); } //#################### //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); MITK_TEST_END(); }
/**Documentation * Test for factory registration */ int mitkPlanarFigureObjectFactoryTest(int /* argc */, char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("PlanarFigureObjectFactoryTest"); // always end with this! MITK_TEST_END(); }
int mitkLabelOverlay3DRendering2DTest(int argc, char* argv[]) { // load all arguments into a datastorage, take last argument as reference rendering // setup a renderwindow of fixed size X*Y // render the datastorage // compare rendering to reference image MITK_TEST_BEGIN("mitkLabelOverlay3DRendering2DTest") mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); // renderingHelper.SetAutomaticallyCloseRenderWindow(false); mitk::BaseRenderer* renderer = mitk::BaseRenderer::GetInstance(renderingHelper.GetVtkRenderWindow()); mitk::OverlayManager::Pointer OverlayManager = mitk::OverlayManager::New(); renderer->SetOverlayManager(OverlayManager); mitk::PointSet::Pointer pointset = mitk::PointSet::New(); mitk::LabelOverlay3D::Pointer label3d = mitk::LabelOverlay3D::New(); mitk::Point3D offset; offset[0] = .5; offset[1] = .5; offset[2] = .5; std::vector<std::string> labels; int idx = 0; for(int i=-10 ; i < 10 ; i+=4){ for(int j=-10 ; j < 10 ; j+=4){ mitk::Point3D point; point[0] = i; point[1] = j; point[2] = (i*j)/10; pointset->InsertPoint(idx++, point); labels.push_back("test"); } } label3d->SetLabelCoordinates(pointset); label3d->SetLabelVector(labels); label3d->SetOffsetVector(offset); OverlayManager->AddOverlay(label3d.GetPointer()); mitk::DataNode::Pointer datanode = mitk::DataNode::New(); datanode->SetData(pointset); datanode->SetName("pointSet"); renderingHelper.AddNodeToStorage(datanode); renderingHelper.Render(); //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { renderingHelper.SaveReferenceScreenShot("/home/christoph/Pictures/RenderingTestData/mitkLabelOverlay3DRendering2DTest.png"); } MITK_TEST_END(); }
/** * mitkPlanarCrossTest tests the methods and behavior of mitk::PlanarCross with four sub-tests: * * 1. Double-line mode instantiation and basic tests * 2. Single-line mode instantiation and basic tests * 3. Tests of application of spatial constraints for double-line mode * 4. Tests if editing of PlanarCross works as intended * */ int mitkPlanarCrossTest(int /* argc */, char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("PlanarCross") // create PlaneGeometry on which to place the PlanarCross mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New(); planeGeometry->InitializeStandardPlane( 100.0, 100.0 ); // ************************************************************************** // 1. Double-line mode instantiation and basic tests mitk::PlanarCross::Pointer planarCross = mitk::PlanarCross::New(); planarCross->SetGeometry2D( planeGeometry ); // first test: did this work? MITK_TEST_CONDITION_REQUIRED( planarCross.IsNotNull(), "Testing instantiation" ); // test: default cross-mode (not single-line-mode)? MITK_TEST_CONDITION_REQUIRED( !planarCross->GetSingleLineMode(), "Testing default cross mode" ); // Test placement of PlanarCross by control points mitkPlanarCrossTestClass::TestPlanarCrossPlacement( planarCross ); // ************************************************************************** // 2. Single-line mode instantiation and basic tests planarCross = mitk::PlanarCross::New(); planarCross->SingleLineModeOn(); planarCross->SetGeometry2D( planeGeometry ); // test: single-line mode? MITK_TEST_CONDITION_REQUIRED( planarCross->GetSingleLineMode(), "Testing activation of single-line mode" ); // Test placement of single-line PlanarCross by control points mitkPlanarCrossTestClass::TestPlanarCrossPlacementSingleLine( planarCross ); // ************************************************************************** // 3. Tests of application of spatial constraints for double-line mode planarCross = mitk::PlanarCross::New(); planarCross->SetGeometry2D( planeGeometry ); // Test placement with various out-of-bounds control points (automatic application of // constraints expected) mitkPlanarCrossTestClass::TestPlanarCrossPlacementConstrained( planarCross ); // ************************************************************************** // 4. Tests if editing of PlanarCross works as intended mitkPlanarCrossTestClass::TestPlanarCrossEdit( planarCross ); // always end with this! MITK_TEST_END() }
/** * Test for class mitk::VtkWidgetRendering (for rendering vtkWidgets on the * screen) * * 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). */ int mitkVtkWidgetRenderingTest(int /* argc */, char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("mitkVTKWidgetRenderingTest") // Test: instantiation mitk::VtkWidgetRendering::Pointer widgetRendering = mitk::VtkWidgetRendering::New(); MITK_TEST_CONDITION_REQUIRED(widgetRendering.IsNotNull(),"Testing instantiation") // Test: Create and set vtkRenderWindow vtkRenderWindow *renderWindow = vtkRenderWindow::New(); //mitk::VtkPropRenderer::Pointer propRenderer = mitk::VtkPropRenderer::New( "the renderer", renderWindow ); //propRenderer->SetMapperID(2); widgetRendering->SetRenderWindow( renderWindow ); MITK_TEST_CONDITION_REQUIRED(widgetRendering->GetRenderWindow() == renderWindow, "Setting vtkRenderWindow...") // Test: Try to enable before widget has been set (should stay disabled) widgetRendering->Enable(); MITK_TEST_CONDITION(!widgetRendering->IsEnabled(), "Trying to enable widget rendering before setting widget") widgetRendering->Disable(); // Test: Retrieve widget before it has been set (should return NULL) MITK_TEST_CONDITION(widgetRendering->GetVtkWidget() == NULL, "Trying to retrieve widget before it has been set") // Test: Create vtkWidget instance (vtkScalarWidget) and add it vtkScalarBarWidget *scalarBarWidget = vtkScalarBarWidget::New(); widgetRendering->SetVtkWidget( scalarBarWidget ); MITK_TEST_CONDITION(widgetRendering->GetVtkWidget() == scalarBarWidget, "Retrieving widget after it has been set") // Test: Try to enable widget rendering (should work now) widgetRendering->Enable(); MITK_TEST_CONDITION(widgetRendering->IsEnabled(), "Enabling widget rendering") // Test: Try to disable widget rendering (should be disabled) widgetRendering->Disable(); MITK_TEST_CONDITION(!widgetRendering->IsEnabled(), "Disabling widget rendering") // Clean up scalarBarWidget->Delete(); renderWindow->Delete(); // 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() }
/** * This function is testing methods of the class USImage2D. */ int mitkUSImageTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("mitkUSImage2DTest"); mitkUSImageTestClass::TestInstantiation(); mitkUSImageTestClass::TestMetadataInProperties(); MITK_TEST_END(); }
int mitkContourModelIOTest(int argc, char* argv[]) { MITK_TEST_BEGIN("mitkContourModelIOTest") TestContourModelIO_OneTimeStep(); TestContourModelIO_EmptyContourModel(); MITK_TEST_END() }
int mitkMultiComponentImageDataComparisonFilterTest(int /*argc*/, char *argv[]) { MITK_TEST_BEGIN("MultiComponentImageDataComparisonFilter"); // instantiation mitk::MultiComponentImageDataComparisonFilter::Pointer testObject = mitk::MultiComponentImageDataComparisonFilter::New(); MITK_TEST_CONDITION_REQUIRED(testObject.IsNotNull(), "Testing instantiation of test class!"); MITK_TEST_CONDITION_REQUIRED(testObject->GetCompareFilterResult() == nullptr, "Testing initialization of result struct"); MITK_TEST_CONDITION_REQUIRED(testObject->GetTolerance() == 0.0f, "Testing initialization of tolerance member"); MITK_TEST_CONDITION_REQUIRED(testObject->GetResult() == false, "Testing initialization of CompareResult member"); // initialize compare result struct and pass it to the filter mitk::CompareFilterResults compareResult; compareResult.m_MaximumDifference = 0.0f; compareResult.m_MinimumDifference = itk::NumericTraits<double>::max(); compareResult.m_MeanDifference = 0.0f; compareResult.m_FilterCompleted = false; compareResult.m_TotalDifference = 0.0f; compareResult.m_PixelsWithDifference = 0; testObject->SetCompareFilterResult(&compareResult); MITK_TEST_CONDITION_REQUIRED(testObject->GetCompareFilterResult() != nullptr, "Testing set/get of compare result struct"); MITK_TEST_CONDITION_REQUIRED(testObject->GetResult() == false, "CompareResult still false"); // now load an image with several components and present it to the filter mitk::Image::Pointer testImg = dynamic_cast<mitk::Image*>(mitk::IOUtil::Load(argv[1])[0].GetPointer()); mitk::Image::Pointer testImg2 = testImg->Clone(); testObject->SetValidImage(testImg); testObject->SetTestImage(testImg2); MITK_TEST_CONDITION_REQUIRED(testObject->GetNumberOfIndexedInputs() == 2, "Testing correct handling of input images"); testObject->Update(); MITK_TEST_CONDITION_REQUIRED(testObject->GetResult(), "Testing filter processing with equal image data"); // now change some of the data and check if the response is correct mitk::ImageReadAccessor imgAcc(testImg2); unsigned char *imgData = (unsigned char *)imgAcc.GetData(); imgData[10] += 1; imgData[20] += 2; imgData[30] += 3; testObject->Update(); MITK_TEST_CONDITION_REQUIRED(testObject->GetResult() == false, "Testing filter processing with unequal image data"); MITK_TEST_CONDITION_REQUIRED( mitk::Equal((int)testObject->GetCompareFilterResult()->m_PixelsWithDifference, (int)3) && mitk::Equal((double)testObject->GetCompareFilterResult()->m_MaximumDifference, (double)3.0) && mitk::Equal((double)testObject->GetCompareFilterResult()->m_MeanDifference, (double)2.0), "Assessing calculated image differences"); MITK_TEST_END(); }
/**Documentation * test for the class "mitkThreadedToFRawDataReconstruction". */ int mitkThreadedToFRawDataReconstructionTest(int /* argc */, char* /*argv*/[]) { MITK_TEST_BEGIN("mitkThreadedToFRawDataReconstruction"); mitk::ThreadedToFRawDataReconstruction::Pointer testObject = mitk::ThreadedToFRawDataReconstruction::New(); MITK_TEST_CONDITION_REQUIRED(testObject.GetPointer(), "Testing initializing of class"); MITK_TEST_CONDITION_REQUIRED(!testObject->GetInit(), "Testing initial state of GetInit()"); int width = 176; int height = 144; int modfreq = 20; int sdsize = width*height*8*sizeof(short); testObject->Initialize(width, height, modfreq, sdsize ); MITK_TEST_CONDITION_REQUIRED(testObject->GetInit(), "Testing state of GetInit() after initialization"); // generate artificial data short* shortSource = new short[sdsize]; vtkShortArray* channelData = vtkShortArray::New(); for(long i = 0; i < sdsize; ++i) { shortSource[i] = i+1; } // use the helper object to set required variables RawDataDeviceHelperImpl::Pointer testHelper = RawDataDeviceHelperImpl::New(); testHelper->SetCaptureWidth(width); testHelper->SetCaptureHeight(height); testHelper->GetChannelSourceData(shortSource, channelData); testObject->SetChannelData( channelData ); testObject->Update(); float* distances = new float[width*height]; float* amplitudes = new float[width*height]; float* intensties = new float[width*height]; // set random value and check if it has changed after filter update distances[50] = -111; amplitudes[50] = -111; intensties[50] = -111; float before = distances[50]; testObject->GetDistances(distances); testObject->GetAmplitudes(amplitudes); testObject->GetIntensities(intensties); MITK_TEST_CONDITION_REQUIRED(before != distances[50], "Testing distance data generation and output"); MITK_TEST_CONDITION_REQUIRED(before != amplitudes[50], "Testing ampltude data generation and output"); MITK_TEST_CONDITION_REQUIRED(before != intensties[50], "Testing intensity data generation and output"); // clean up the mess delete[] distances; delete[] amplitudes; delete[] intensties; delete[] shortSource; channelData->Delete(); MITK_TEST_END(); }
/** * mitkPlanarArrowTest tests the methods and behavior of mitk::PlanarArrow with sub-tests: * * 1. Instantiation and basic tests * */ int mitkPlanarArrowTest(int /* argc */, char* /*argv*/[]) { // always start with this! MITK_TEST_BEGIN("PlanarArrow") // create PlaneGeometry on which to place the PlanarArrow mitk::PlaneGeometry::Pointer planeGeometry = mitk::PlaneGeometry::New(); planeGeometry->InitializeStandardPlane( 100.0, 100.0 ); // ************************************************************************** // 1. Instantiation and basic tests mitk::PlanarArrow::Pointer PlanarArrow = mitk::PlanarArrow::New(); PlanarArrow->SetPlaneGeometry( planeGeometry ); // first test: did this work? MITK_TEST_CONDITION_REQUIRED( PlanarArrow.IsNotNull(), "Testing instantiation" ); // Test placement of PlanarArrow by control points mitkPlanarArrowTestClass::TestPlanarArrowPlacement( PlanarArrow ); PlanarArrow->EvaluateFeatures(); mitk::PlanarArrow::Pointer clonedArrow = PlanarArrow->Clone(); MITK_TEST_CONDITION_REQUIRED( clonedArrow.IsNotNull(), "Testing cloning" ); bool identical( true ); identical &= clonedArrow->GetMinimumNumberOfControlPoints() == PlanarArrow->GetMinimumNumberOfControlPoints(); identical &= clonedArrow->GetMaximumNumberOfControlPoints() == PlanarArrow->GetMaximumNumberOfControlPoints(); identical &= clonedArrow->IsClosed() == PlanarArrow->IsClosed(); identical &= clonedArrow->IsPlaced() == PlanarArrow->IsPlaced(); identical &= clonedArrow->GetNumberOfControlPoints() == PlanarArrow->GetNumberOfControlPoints(); identical &= clonedArrow->GetNumberOfControlPoints() == PlanarArrow->GetNumberOfControlPoints(); identical &= clonedArrow->GetSelectedControlPoint() == PlanarArrow->GetSelectedControlPoint(); identical &= clonedArrow->IsPreviewControlPointVisible() == PlanarArrow->IsPreviewControlPointVisible(); identical &= clonedArrow->GetPolyLinesSize() == PlanarArrow->GetPolyLinesSize(); identical &= clonedArrow->GetHelperPolyLinesSize() == PlanarArrow->GetHelperPolyLinesSize(); identical &= clonedArrow->ResetOnPointSelect() == PlanarArrow->ResetOnPointSelect(); for ( unsigned int i=0; i<clonedArrow->GetNumberOfControlPoints(); ++i ) { identical &= clonedArrow->GetControlPoint(i) == PlanarArrow->GetControlPoint(i); } for ( unsigned int i=0; i<clonedArrow->GetPolyLinesSize(); ++i ) { mitk::PlanarFigure::PolyLineType polyLine = clonedArrow->GetPolyLine( i ); for ( unsigned int j=0; j<polyLine.size(); ++j ) { identical &= polyLine.at(j) == PlanarArrow->GetPolyLine(i).at(j); } } MITK_TEST_CONDITION_REQUIRED( identical, "Cloning completely successful" ); // always end with this! MITK_TEST_END(); }
int mitkCoreObjectFactoryTest(int /*argc*/, char * /*argv*/ []) { MITK_TEST_BEGIN("CoreObjectFactory") 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?"); MITK_TEST_END() }