diff --git a/Core/Code/Rendering/mitkRenderingTestHelper.cpp b/Core/Code/Rendering/mitkRenderingTestHelper.cpp index a6e86079e3..66cf3f2f69 100644 --- a/Core/Code/Rendering/mitkRenderingTestHelper.cpp +++ b/Core/Code/Rendering/mitkRenderingTestHelper.cpp @@ -1,237 +1,237 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //VTK #include #include #include #include //MITK #include #include #include #include #include #include #include // include gl to read out properties #include #include //VTK Testing to compare the rendered image pixel-wise against a reference screen shot #include "vtkTesting.h" -mitkRenderingTestHelper::mitkRenderingTestHelper(int width, int height) +mitk::RenderingTestHelper::RenderingTestHelper(int width, int height) : m_AutomaticallyCloseRenderWindow(true) { this->Initialize(width, height); } -mitkRenderingTestHelper::mitkRenderingTestHelper(int width, int height, int argc, char* argv[]) +mitk::RenderingTestHelper::RenderingTestHelper(int width, int height, int argc, char* argv[]) : m_AutomaticallyCloseRenderWindow(true) { this->Initialize(width, height); this->SetInputFileNames(argc, argv); } -void mitkRenderingTestHelper::Initialize(int width, int height) +void mitk::RenderingTestHelper::Initialize(int width, int height) { // Global interaction must(!) be initialized mitk::GlobalInteraction::GetInstance()->Initialize("global"); m_RenderWindow = mitk::RenderWindow::New(); m_DataStorage = mitk::StandaloneDataStorage::New(); m_RenderWindow->GetRenderer()->SetDataStorage(m_DataStorage); this->SetMapperIDToRender2D(); this->GetVtkRenderWindow()->SetSize( width, height ); m_RenderWindow->GetRenderer()->Resize( width, height); //Prints the glinfo after creation of the vtkrenderwindow, we always want to do this for debugging. this->PrintGLInfo(); } -mitkRenderingTestHelper::~mitkRenderingTestHelper() +mitk::RenderingTestHelper::~RenderingTestHelper() { } -void mitkRenderingTestHelper::PrintGLInfo() +void mitk::RenderingTestHelper::PrintGLInfo() { GLint maxTextureSize; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize);; MITK_INFO << "OpenGL Render Context Information: \n" << "- GL_VENDOR: "<< glGetString(GL_VENDOR) << "\n" << "- GL_RENDERER: "<< glGetString(GL_RENDERER) << "\n" << "- GL_VERSION: "<< glGetString(GL_VERSION) << "\n" << "- GL_MAX_TEXTURE_SIZE: "<< maxTextureSize << "\n" << "- GL_EXTENSIONS: "<< glGetString(GL_EXTENSIONS); } -void mitkRenderingTestHelper::SetMapperID( mitk::BaseRenderer::StandardMapperSlot id) +void mitk::RenderingTestHelper::SetMapperID( mitk::BaseRenderer::StandardMapperSlot id) { m_RenderWindow->GetRenderer()->SetMapperID(id); } -void mitkRenderingTestHelper::SetMapperIDToRender3D() +void mitk::RenderingTestHelper::SetMapperIDToRender3D() { this->SetMapperID(mitk::BaseRenderer::Standard3D); } -void mitkRenderingTestHelper::SetMapperIDToRender2D() +void mitk::RenderingTestHelper::SetMapperIDToRender2D() { this->SetMapperID(mitk::BaseRenderer::Standard2D); } -void mitkRenderingTestHelper::Render() +void mitk::RenderingTestHelper::Render() { //if the datastorage is initialized and at least 1 image is loaded render it if(m_DataStorage.IsNotNull() || m_DataStorage->GetAll()->Size() >= 1 ) { //Prepare the VTK camera before rendering. m_RenderWindow->GetRenderer()->PrepareRender(); this->GetVtkRenderWindow()->Render(); if(m_AutomaticallyCloseRenderWindow == false) { //Use interaction to stop the test this->GetVtkRenderWindow()->GetInteractor()->Start(); } } else { MITK_ERROR << "No images loaded in data storage!"; } } -mitk::DataStorage::Pointer mitkRenderingTestHelper::GetDataStorage() +mitk::DataStorage::Pointer mitk::RenderingTestHelper::GetDataStorage() { return m_DataStorage; } -void mitkRenderingTestHelper::SetInputFileNames(int argc, char* argv[]) +void mitk::RenderingTestHelper::SetInputFileNames(int argc, char* argv[]) { //i is set 1, because 0 is the testname as string //parse parameters for (int i = 1; i < argc; ++i) { //add everything to a list but -T and -V std::string tmp = argv[i]; if((tmp.compare("-T")) && (tmp.compare("-V"))) { this->AddToStorage(tmp); } else { break; } } } -void mitkRenderingTestHelper::SetViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection) +void mitk::RenderingTestHelper::SetViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection) { mitk::BaseRenderer::GetInstance(m_RenderWindow->GetVtkRenderWindow())->GetSliceNavigationController()->SetDefaultViewDirection(viewDirection); mitk::RenderingManager::GetInstance()->InitializeViews( m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()) ); } -void mitkRenderingTestHelper::ReorientSlices(mitk::Point3D origin, mitk::Vector3D rotation) +void mitk::RenderingTestHelper::ReorientSlices(mitk::Point3D origin, mitk::Vector3D rotation) { mitk::SliceNavigationController::Pointer sliceNavigationController = mitk::BaseRenderer::GetInstance(m_RenderWindow->GetVtkRenderWindow())->GetSliceNavigationController(); sliceNavigationController->ReorientSlices(origin, rotation); } -vtkRenderer* mitkRenderingTestHelper::GetVtkRenderer() +vtkRenderer* mitk::RenderingTestHelper::GetVtkRenderer() { return m_RenderWindow->GetRenderer()->GetVtkRenderer(); } -void mitkRenderingTestHelper::SetImageProperty(const char *propertyKey, mitk::BaseProperty* property ) +void mitk::RenderingTestHelper::SetImageProperty(const char *propertyKey, mitk::BaseProperty* property ) { this->m_DataStorage->GetNode(mitk::NodePredicateDataType::New("Image"))->SetProperty(propertyKey, property); } -vtkRenderWindow* mitkRenderingTestHelper::GetVtkRenderWindow() +vtkRenderWindow* mitk::RenderingTestHelper::GetVtkRenderWindow() { return m_RenderWindow->GetVtkRenderWindow(); } -bool mitkRenderingTestHelper::CompareRenderWindowAgainstReference(int argc, char* argv[], double threshold) +bool mitk::RenderingTestHelper::CompareRenderWindowAgainstReference(int argc, char* argv[], double threshold) { this->Render(); //retVal meanings: (see VTK/Rendering/vtkTesting.h) //0 = test failed //1 = test passed //2 = test not run //3 = something with vtkInteraction if(vtkTesting::Test(argc, argv, this->GetVtkRenderWindow(), threshold) == 1) return true; else return false; } //method to save a screenshot of the renderwindow (e.g. create a reference screenshot) -void mitkRenderingTestHelper::SaveAsPNG(std::string fileName) +void mitk::RenderingTestHelper::SaveAsPNG(std::string fileName) { vtkSmartPointer renderer = this->GetVtkRenderer(); bool doubleBuffering( renderer->GetRenderWindow()->GetDoubleBuffer() ); renderer->GetRenderWindow()->DoubleBufferOff(); vtkSmartPointer magnifier = vtkSmartPointer::New(); magnifier->SetInput(renderer); magnifier->SetMagnification(1); vtkSmartPointer fileWriter = vtkSmartPointer::New(); fileWriter->SetInput(magnifier->GetOutput()); fileWriter->SetFileName(fileName.c_str()); fileWriter->Write(); renderer->GetRenderWindow()->SetDoubleBuffer(doubleBuffering); } -void mitkRenderingTestHelper::SetAutomaticallyCloseRenderWindow(bool automaticallyCloseRenderWindow) +void mitk::RenderingTestHelper::SetAutomaticallyCloseRenderWindow(bool automaticallyCloseRenderWindow) { m_AutomaticallyCloseRenderWindow = automaticallyCloseRenderWindow; } -void mitkRenderingTestHelper::SaveReferenceScreenShot(std::string fileName) +void mitk::RenderingTestHelper::SaveReferenceScreenShot(std::string fileName) { this->SaveAsPNG(fileName); } -void mitkRenderingTestHelper::AddToStorage(const std::string &filename) +void mitk::RenderingTestHelper::AddToStorage(const std::string &filename) { try { mitk::DataNode::Pointer node = mitk::IOUtil::LoadDataNode(filename); this->AddNodeToStorage(node); } catch ( itk::ExceptionObject & e ) { MITK_ERROR << "Failed loading test data '" << filename << "': " << e.what(); } } -void mitkRenderingTestHelper::AddNodeToStorage(mitk::DataNode::Pointer node) +void mitk::RenderingTestHelper::AddNodeToStorage(mitk::DataNode::Pointer node) { this->m_DataStorage->Add(node); mitk::RenderingManager::GetInstance()->InitializeViews( m_DataStorage->ComputeBoundingGeometry3D(m_DataStorage->GetAll()) ); } diff --git a/Core/Code/Rendering/mitkRenderingTestHelper.h b/Core/Code/Rendering/mitkRenderingTestHelper.h index f01bde6241..22f0a69d50 100644 --- a/Core/Code/Rendering/mitkRenderingTestHelper.h +++ b/Core/Code/Rendering/mitkRenderingTestHelper.h @@ -1,168 +1,171 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #ifndef mitkRenderingTestHelper_h #define mitkRenderingTestHelper_h #include #include #include #include #include class vtkRenderWindow; class vtkRenderer; -class MITK_CORE_EXPORT mitkRenderingTestHelper +namespace mitk +{ + +class MITK_CORE_EXPORT RenderingTestHelper { public: /** @brief Generate a rendering test helper object including a render window of the size width * height (in pixel). @param argc Number of parameters. (here: Images) "Usage: [filename1 filenam2 -V referenceScreenshot (optional -T /directory/to/save/differenceImage)] @param argv Given parameters. If no data is inserted via commandline, you can add data later via AddNodeToDataStorage(). **/ - mitkRenderingTestHelper(int width, int height, int argc, char *argv[]); + RenderingTestHelper(int width, int height, int argc, char *argv[]); /** @brief Generate a rendering test helper object including a render window of the size width * height (in pixel).*/ - mitkRenderingTestHelper(int width, int height); + RenderingTestHelper(int width, int height); /** Default destructor */ - ~mitkRenderingTestHelper(); + ~RenderingTestHelper(); /** @brief Getter for the vtkRenderer. **/ vtkRenderer* GetVtkRenderer(); /** @brief Getter for the vtkRenderWindow which should be used to call vtkRegressionTestImage. **/ vtkRenderWindow* GetVtkRenderWindow(); /** @brief Method can be used to save a screenshot (e.g. reference screenshot as a .png file. @param fileName The filename of the new screenshot (including path). **/ void SaveAsPNG(std::string fileName); /** * @brief SetStopRenderWindow Convenience method to make the renderwindow hold after rendering. Usefull for debugging. * @param flag Flag indicating whether the renderwindow should automatically close (false, default) or stay open (true). Usefull for debugging. */ void SetAutomaticallyCloseRenderWindow(bool automaticallyCloseRenderWindow); /** @brief This method set the property of the member datastorage @param property Set a property for each image in the datastorage m_DataStorage. If you want to set the property for a single data node, use GetDataStorage() and set the property yourself for the destinct node. **/ void SetImageProperty(const char *propertyKey, mitk::BaseProperty *property); /** @brief Set the view direction of the renderwindow (e.g. sagittal, coronal, axial) **/ void SetViewDirection(mitk::SliceNavigationController::ViewDirection viewDirection); /** @brief Reorient the slice (e.g. rotation and translation like the swivel mode). **/ void ReorientSlices(mitk::Point3D origin, mitk::Vector3D rotation); /** @brief Render everything into an mitkRenderWindow. Call SetViewDirection() and SetProperty() before this method. **/ void Render(); /** @brief Returns the datastorage, in order to modify the data inside a rendering test. **/ mitk::DataStorage::Pointer GetDataStorage(); /** * @brief SetMapperID Change between Standard2D and 3D mappers. * @param id Enum mitk::BaseRenderer::StandardMapperSlot which defines the mapper. */ void SetMapperID(mitk::BaseRenderer::StandardMapperSlot id); /** * @brief AddNodeToStorage Add a node to the datastorage and perform a reinit which is necessary for rendering. * @param node The data you want to add. */ void AddNodeToStorage(mitk::DataNode::Pointer node); /** * @brief SetMapperIDToRender3D Convenience method to render in a 3D renderwindow. * @warning Does not add helper objects like the image planes to render images in 3D. */ void SetMapperIDToRender3D(); /** * @brief SetMapperIDToRender2D Convenience method to render in a 2D renderwindow. */ void SetMapperIDToRender2D(); /** * @brief SaveReferenceScreenShot Convenience method to save a reference screen shot. * @param fileName Path/to/save/the/png/file. */ void SaveReferenceScreenShot(std::string fileName); /** * @brief CompareRenderWindowAgainstReference Convenience method to compare the image rendered in the internal renderwindow against a reference screen shot. * Usage of vtkTesting::Test: vtkTesting::Test( argc, argv, vtkRenderWindow, threshold ) Set a vtkRenderWindow containing the desired scene. This is automatically rendered. vtkTesting::Test() automatically searches in argc and argv[] for a path a valid image with -V. If the test failed with the first image (foo.png) it checks if there are images of the form foo_N.png (where N=1,2,3...) and compare against them. This allows for multiple valid images. * @param argc Number of arguments. * @param argv Arguments must(!) contain the term "-V Path/To/Valid/Image.png" * @param threshold Allowed difference between two images. Default = 10.0 and was taken from VTK. * @return True if the images are equal regarding the threshold. False in all other cases. */ bool CompareRenderWindowAgainstReference(int argc, char *argv[], double threshold = 10.0); protected: /** * @brief Initialize Internal method to initialize the renderwindow and set the datastorage. * @param width Height of renderwindow. * @param height Width of renderwindow. */ void Initialize(int width, int height); /** @brief Prints the opengl information, e.g. version, vendor and extensions, * This function can only be called after an opengl context is active. * It only prints the context after the vtkRenderwindow is fully initialized. **/ void PrintGLInfo(); /** @brief This method tries to load the given file into a member datastorage, in order to render it. @param fileName The filename of the file to be loaded (including path). **/ void AddToStorage(const std::string& filename); /** @brief This method tries to parse the given argv for files (e.g. images) and load them into a member datastorage, in order to render it. @param argc Number of parameters. @param argv Given parameters. **/ void SetInputFileNames(int argc, char *argv[]); mitk::RenderWindow::Pointer m_RenderWindow; //<< Contains the mitkRenderWindow into which the test renders the data mitk::DataStorage::Pointer m_DataStorage; //<< Contains the mitkDataStorage which contains the data to be rendered bool m_AutomaticallyCloseRenderWindow; //<< Flag indicating whether the renderwindow should automatically close (true, default) or stay open (false). Usefull for debugging. }; - +}//namespace mitk #endif diff --git a/Core/Code/Testing/files.cmake b/Core/Code/Testing/files.cmake index 6b914a3728..a09ec44ca2 100644 --- a/Core/Code/Testing/files.cmake +++ b/Core/Code/Testing/files.cmake @@ -1,145 +1,144 @@ # tests with no extra command line parameter set(MODULE_TESTS mitkAccessByItkTest.cpp mitkCoreObjectFactoryTest.cpp mitkMaterialTest.cpp mitkActionTest.cpp mitkDispatcherTest.cpp mitkEnumerationPropertyTest.cpp mitkEventTest.cpp mitkFocusManagerTest.cpp mitkGenericPropertyTest.cpp mitkGeometry3DTest.cpp mitkGeometryDataToSurfaceFilterTest.cpp mitkGlobalInteractionTest.cpp mitkImageDataItemTest.cpp #mitkImageMapper2DTest.cpp mitkImageGeneratorTest.cpp mitkBaseDataTest.cpp #mitkImageToItkTest.cpp mitkInstantiateAccessFunctionTest.cpp mitkInteractorTest.cpp #mitkITKThreadingTest.cpp mitkLevelWindowTest.cpp mitkMessageTest.cpp #mitkPipelineSmartPointerCorrectnessTest.cpp mitkPixelTypeTest.cpp mitkPlaneGeometryTest.cpp mitkPointSetFileIOTest.cpp mitkPointSetTest.cpp mitkPointSetWriterTest.cpp mitkPointSetReaderTest.cpp mitkPointSetInteractorTest.cpp mitkPropertyTest.cpp mitkPropertyListTest.cpp #mitkRegistrationBaseTest.cpp #mitkSegmentationInterpolationTest.cpp mitkSlicedGeometry3DTest.cpp mitkSliceNavigationControllerTest.cpp mitkStateMachineTest.cpp ##mitkStateMachineContainerTest.cpp ## rewrite test, indirect since no longer exported Bug 14529 mitkStateTest.cpp mitkSurfaceTest.cpp mitkSurfaceToSurfaceFilterTest.cpp mitkTimeSlicedGeometryTest.cpp mitkTransitionTest.cpp mitkUndoControllerTest.cpp mitkVtkWidgetRenderingTest.cpp mitkVerboseLimitedLinearUndoTest.cpp mitkWeakPointerTest.cpp mitkTransferFunctionTest.cpp #mitkAbstractTransformGeometryTest.cpp mitkStepperTest.cpp itkTotalVariationDenoisingImageFilterTest.cpp mitkRenderingManagerTest.cpp vtkMitkThickSlicesFilterTest.cpp mitkNodePredicateSourceTest.cpp mitkVectorTest.cpp mitkClippedSurfaceBoundsCalculatorTest.cpp - #QmitkRenderingTestHelper.cpp mitkExceptionTest.cpp mitkExtractSliceFilterTest.cpp mitkLogTest.cpp mitkImageDimensionConverterTest.cpp mitkLoggingAdapterTest.cpp mitkUIDGeneratorTest.cpp mitkShaderRepositoryTest.cpp ) # test with image filename as an extra command line parameter set(MODULE_IMAGE_TESTS mitkPlanePositionManagerTest.cpp mitkSurfaceVtkWriterTest.cpp #mitkImageSliceSelectorTest.cpp mitkImageTimeSelectorTest.cpp # mitkVtkPropRendererTest.cpp mitkDataNodeFactoryTest.cpp #mitkSTLFileReaderTest.cpp mitkImageAccessorTest.cpp ) # list of images for which the tests are run set(MODULE_TESTIMAGES # Pic-Factory no more available in Core, test images now in .nrrd format US4DCyl.nrrd Pic3D.nrrd Pic2DplusT.nrrd BallBinary30x30x30.nrrd binary.stl ball.stl ) set(MODULE_CUSTOM_TESTS #mitkLabeledImageToSurfaceFilterTest.cpp #mitkExternalToolsTest.cpp mitkDataStorageTest.cpp mitkDataNodeTest.cpp mitkDicomSeriesReaderTest.cpp mitkDICOMLocaleTest.cpp mitkEventMapperTest.cpp mitkEventConfigTest.cpp mitkNodeDependentPointSetInteractorTest.cpp mitkStateMachineFactoryTest.cpp mitkPointSetLocaleTest.cpp mitkImageTest.cpp mitkImageWriterTest.cpp mitkImageVtkMapper2DTest.cpp mitkImageVtkMapper2DLevelWindowTest.cpp mitkImageVtkMapper2DOpacityTest.cpp mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp mitkImageVtkMapper2DColorTest.cpp mitkImageVtkMapper2DSwivelTest.cpp mitkImageVtkMapper2DTransferFunctionTest.cpp mitkIOUtilTest.cpp mitkSurfaceVtkMapper3DTest mitkSurfaceVtkMapper3DTexturedSphereTest.cpp mitkVolumeCalculatorTest.cpp mitkLevelWindowManagerTest.cpp ) set(MODULE_RESOURCE_FILES Interactions/AddAndRemovePoints.xml Interactions/globalConfig.xml Interactions/StatemachineTest.xml Interactions/StatemachineConfigTest.xml ) # Create an artificial module initializing class for # the usServiceListenerTest.cpp usFunctionGenerateModuleInit(testdriver_init_file NAME ${MODULE_NAME}TestDriver DEPENDS "Mitk" VERSION "0.1.0" EXECUTABLE ) # Embed the resources set(testdriver_resources ) usFunctionEmbedResources(testdriver_resources EXECUTABLE_NAME ${MODULE_NAME}TestDriver ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/Resources FILES ${MODULE_RESOURCE_FILES} ) set(TEST_CPP_FILES ${testdriver_init_file} ${testdriver_resources}) diff --git a/Core/Code/Testing/mitkImageVtkMapper2DColorTest.cpp b/Core/Code/Testing/mitkImageVtkMapper2DColorTest.cpp index 2ce87c0e70..50a793ebb8 100644 --- a/Core/Code/Testing/mitkImageVtkMapper2DColorTest.cpp +++ b/Core/Code/Testing/mitkImageVtkMapper2DColorTest.cpp @@ -1,53 +1,53 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" //VTK #include 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); + mitk::RenderingTestHelper 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(); } diff --git a/Core/Code/Testing/mitkImageVtkMapper2DLevelWindowTest.cpp b/Core/Code/Testing/mitkImageVtkMapper2DLevelWindowTest.cpp index ee59981e32..d763a4b1fe 100644 --- a/Core/Code/Testing/mitkImageVtkMapper2DLevelWindowTest.cpp +++ b/Core/Code/Testing/mitkImageVtkMapper2DLevelWindowTest.cpp @@ -1,58 +1,58 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" #include #include //VTK #include 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") - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + 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); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { 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(); } diff --git a/Core/Code/Testing/mitkImageVtkMapper2DOpacityTest.cpp b/Core/Code/Testing/mitkImageVtkMapper2DOpacityTest.cpp index be59fe014a..b8e2579a4d 100644 --- a/Core/Code/Testing/mitkImageVtkMapper2DOpacityTest.cpp +++ b/Core/Code/Testing/mitkImageVtkMapper2DOpacityTest.cpp @@ -1,51 +1,51 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" //VTK #include 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") - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + 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); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { 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(); } diff --git a/Core/Code/Testing/mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp b/Core/Code/Testing/mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp index 52768018a8..66e91183bf 100644 --- a/Core/Code/Testing/mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp +++ b/Core/Code/Testing/mitkImageVtkMapper2DResliceInterpolationPropertyTest.cpp @@ -1,85 +1,85 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" #include #include "mitkIOUtil.h" #include "mitkDataNode.h" //VTK #include #include int mitkImageVtkMapper2DResliceInterpolationPropertyTest(int argc, char* argv[]) { //load all arguments into a datastorage, take last argument as reference //setup a renderwindow of fixed size X*Y //render the datastorage //compare rendering to reference image //note: this test is supposed to test the reslice interpolation modes not the swiveling itself MITK_TEST_BEGIN("mitkImageVtkMapper2DResliceInterpolationPropertyTest") - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //get resliceInterpolation from comandline arg int resliceInterpolation = atoi(argv[argc-4]); //Set interpolation mode for rendering renderingHelper.SetImageProperty("reslice interpolation", mitk::VtkResliceInterpolationProperty::New( resliceInterpolation )); /*+++rotate plane+++*/ //center point for rotation mitk::Point3D centerPoint; centerPoint.Fill(0.0f); //vector for rotating the slice mitk::Vector3D rotationVector; rotationVector.SetElement(0, 0.2); rotationVector.SetElement(1, 0.3); rotationVector.SetElement(2, 0.5); //sets a swivel direction for the image //new version of setting the center point: mitk::Image::Pointer image = static_cast(renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Image"))->GetData()); //get the center point of the image centerPoint = image->GetGeometry()->GetCenter(); //rotate the image arround its own center renderingHelper.ReorientSlices(centerPoint, rotationVector); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { renderingHelper.Render(); renderingHelper.SaveReferenceScreenShot("C:\\Users\\schroedt\\Pictures\\RenderingTestData\\Pic3dRefLinear.png"); } //threshold for CompareRenderWindowAgainstReference double threshold = 0.35;//difference between interpolation modes is very small //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv, threshold) == true, "CompareRenderWindowAgainstReference test result positive?" ); MITK_TEST_END(); } diff --git a/Core/Code/Testing/mitkImageVtkMapper2DSwivelTest.cpp b/Core/Code/Testing/mitkImageVtkMapper2DSwivelTest.cpp index b17e39356b..1442ff9f40 100644 --- a/Core/Code/Testing/mitkImageVtkMapper2DSwivelTest.cpp +++ b/Core/Code/Testing/mitkImageVtkMapper2DSwivelTest.cpp @@ -1,66 +1,66 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" #include //VTK #include int mitkImageVtkMapper2DSwivelTest(int argc, char* argv[]) { //load all arguments into a datastorage, take last argument as reference //setup a renderwindow of fixed size X*Y //render the datastorage //compare rendering to reference image MITK_TEST_BEGIN("mitkImageVtkMapper2DSwivelTest") - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //center point for rotation mitk::Point3D centerPoint; centerPoint.Fill(0.0f); //vector for rotating the slice mitk::Vector3D rotationVector; rotationVector.SetElement(0, 0.2); rotationVector.SetElement(1, 0.3); rotationVector.SetElement(2, 0.5); //sets a swivel direction for the image //new version of setting the center point: mitk::Image::Pointer image = static_cast(renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Image"))->GetData()); //get the center point of the image centerPoint = image->GetGeometry()->GetCenter(); //rotate the image arround its own center renderingHelper.ReorientSlices(centerPoint, rotationVector); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { renderingHelper.SaveReferenceScreenShot("/media/hdd/thomasHdd/Pictures/RenderingTestData/pic3dSwivel640x480REF.png"); } //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); MITK_TEST_END(); } diff --git a/Core/Code/Testing/mitkImageVtkMapper2DTest.cpp b/Core/Code/Testing/mitkImageVtkMapper2DTest.cpp index aacce7ef4a..64d9f5f13d 100644 --- a/Core/Code/Testing/mitkImageVtkMapper2DTest.cpp +++ b/Core/Code/Testing/mitkImageVtkMapper2DTest.cpp @@ -1,47 +1,47 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" //VTK #include int mitkImageVtkMapper2DTest(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); + mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { 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(); } diff --git a/Core/Code/Testing/mitkImageVtkMapper2DTransferFunctionTest.cpp b/Core/Code/Testing/mitkImageVtkMapper2DTransferFunctionTest.cpp index dfa3f53280..fe957919d3 100644 --- a/Core/Code/Testing/mitkImageVtkMapper2DTransferFunctionTest.cpp +++ b/Core/Code/Testing/mitkImageVtkMapper2DTransferFunctionTest.cpp @@ -1,63 +1,63 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" //VTK #include #include #include #include int mitkImageVtkMapper2DTransferFunctionTest(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("mitkImageVtkMapper2DTransferFunctionTest") - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //define an arbitrary colortransferfunction vtkSmartPointer colorTransferFunction = vtkSmartPointer::New(); colorTransferFunction->SetColorSpaceToRGB(); colorTransferFunction->AddRGBPoint(0.0, 1, 0, 0); //black = red colorTransferFunction->AddRGBPoint(127.5, 0, 1, 0); //grey = green colorTransferFunction->AddRGBPoint(255.0, 0, 0, 1); //white = blue mitk::TransferFunction::Pointer transferFucntion = mitk::TransferFunction::New(); transferFucntion->SetColorTransferFunction( colorTransferFunction ); //set the rendering mode to use the transfer function renderingHelper.SetImageProperty("Image Rendering.Mode", mitk::RenderingModeProperty::New(mitk::RenderingModeProperty::COLORTRANSFERFUNCTION_COLOR)); //set the property for the image renderingHelper.SetImageProperty("Image Rendering.Transfer Function", mitk::TransferFunctionProperty::New(transferFucntion)); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { renderingHelper.SaveReferenceScreenShot("/home/kilgus/Pictures/RenderingTestData/output.png"); } //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv, 20.0) == true, "CompareRenderWindowAgainstReference test result positive?" ); MITK_TEST_END(); } diff --git a/Core/Code/Testing/mitkSurfaceVtkMapper3DTest.cpp b/Core/Code/Testing/mitkSurfaceVtkMapper3DTest.cpp index be479ee684..fcfa38a019 100644 --- a/Core/Code/Testing/mitkSurfaceVtkMapper3DTest.cpp +++ b/Core/Code/Testing/mitkSurfaceVtkMapper3DTest.cpp @@ -1,105 +1,105 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" #include #include #include //VTK #include #include #include #include #include #include #include #include int mitkSurfaceVtkMapper3DTest(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("mitkSurfaceVtkMapper3DTest") - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //3D rendering test, thus 3D mapper ID. renderingHelper.SetMapperID(mitk::BaseRenderer::Standard3D); vtkSmartPointer textureCoordinates = vtkSmartPointer::New(); textureCoordinates->SetNumberOfComponents(2); textureCoordinates->SetName("TextureCoordinates"); mitk::Image::Pointer textureImage = static_cast< mitk::Image* > ( renderingHelper.GetDataStorage()->GetNode( mitk::NodePredicateDataType::New("Image"))->GetData() ); //generate texture coordinates assuming that surface and texture can be mapped 1 to 1 unsigned int* dims = textureImage->GetDimensions(); for(unsigned int j = 0; j < dims[1]; ++j) { for(unsigned int i = 0; i < dims[0]; ++i) { int pixelID = i + j*dims[0]; float xNorm = (((float)i)/dims[0]); float yNorm = ((float)j)/dims[1]; textureCoordinates->InsertTuple2(pixelID, xNorm, yNorm); } } mitk::Surface::Pointer surfaceToPutTextureOn = static_cast< mitk::Surface* > ( renderingHelper.GetDataStorage()->GetNode( mitk::NodePredicateDataType::New("Surface"))->GetData() ); surfaceToPutTextureOn->GetVtkPolyData()->GetPointData()->SetTCoords(textureCoordinates); mitk::SmartPointerProperty::Pointer textureProperty = mitk::SmartPointerProperty::New(textureImage); renderingHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Surface"))->SetProperty("Surface.Texture", textureProperty); //remove the image from the data storage in order to not disturb the world geometry //(only the surface geometry should be used for rendering) renderingHelper.GetDataStorage()->Remove( renderingHelper.GetDataStorage()->GetNode( mitk::NodePredicateDataType::New("Image")) ); //Perform reinit, because we removed data. mitk::RenderingManager::GetInstance()->InitializeViews( renderingHelper.GetDataStorage()->ComputeBoundingGeometry3D(renderingHelper.GetDataStorage()->GetAll()) ); //Find a nice camera position to view the surface from the front. //This has to be done after calling renderingHelper.Render(), //because it would overwrite the camera position with global reinit. //It is not necessary, but else the surface is ugly rendered from the side. mitk::Point3D surfaceCenter= surfaceToPutTextureOn->GetGeometry()->GetCenter(); vtkCamera* camera3d = renderingHelper.GetVtkRenderer()->GetActiveCamera(); //1m distance to camera should be a nice default value for most cameras camera3d->SetPosition(0,0,-1000); camera3d->SetViewUp(0,-1,0); camera3d->SetFocalPoint(0,0,surfaceCenter[2]); camera3d->SetViewAngle(40); // camera3d->SetClippingRange(1, 10000); renderingHelper.GetVtkRenderer()->ResetCamera(); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { 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(); } diff --git a/Core/Code/Testing/mitkSurfaceVtkMapper3DTexturedSphereTest.cpp b/Core/Code/Testing/mitkSurfaceVtkMapper3DTexturedSphereTest.cpp index 5161978eaa..ea862bc4f1 100644 --- a/Core/Code/Testing/mitkSurfaceVtkMapper3DTexturedSphereTest.cpp +++ b/Core/Code/Testing/mitkSurfaceVtkMapper3DTexturedSphereTest.cpp @@ -1,90 +1,90 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" #include #include #include //VTK #include #include #include #include #include #include #include /** * @brief mitkSurfaceVtkMapper3DTexturedSphereTest This test puts a texture onto a sphere. It is a nice example how to use VTK methods to generate texture coordinates for MITK surfaces. * @param argv Just any image serving as texture. */ int mitkSurfaceVtkMapper3DTexturedSphereTest(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("mitkSurfaceVtkMapper3DTexturedSphereTest") - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //This is a test for a 3D surface, thus we need to set the mapper ID to 3D renderingHelper.SetMapperID(mitk::BaseRenderer::Standard3D); //######## Exmaple code begin ######## //Generate a sphere in order to map texture on it vtkSmartPointer sphere = vtkSmartPointer::New(); sphere->SetThetaResolution(12); sphere->SetPhiResolution(12); sphere->SetRadius(50.0); //just to make it huge sphere->SetCenter(50,0,0); //just to center the sphere in the screen //taken from VTK example: http://www.vtk.org/Wiki/VTK/Examples/Python/Visualization/SphereTexture vtkSmartPointer mapToSphere = vtkSmartPointer::New(); mapToSphere->SetInputConnection(sphere->GetOutputPort()); mapToSphere->PreventSeamOn(); //get the texture image from the helper's data storage mitk::Image::Pointer textureImage = static_cast< mitk::Image* > ( renderingHelper.GetDataStorage()->GetNode( mitk::NodePredicateDataType::New("Image"))->GetData() ); //Generate MITK surface mitk::Surface::Pointer surfaceToPutTextureOn = mitk::Surface::New(); surfaceToPutTextureOn->SetVtkPolyData(static_cast(mapToSphere->GetOutput())); //Generate a node mitk::DataNode::Pointer surfaceNode = mitk::DataNode::New(); surfaceNode->SetData( surfaceToPutTextureOn ); //Make a Property and add to the node mitk::SmartPointerProperty::Pointer textureProperty = mitk::SmartPointerProperty::New(textureImage); surfaceNode->SetProperty("Surface.Texture", textureProperty); //add to data storage renderingHelper.AddNodeToStorage(surfaceNode); //######## Exmaple code end ######## //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { renderingHelper.SaveReferenceScreenShot("/home/kilgus/Pictures/RenderingTestData/output.png"); } //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv, 50.0) == true, "CompareRenderWindowAgainstReference test result positive?" ); MITK_TEST_END(); } diff --git a/Modules/Simulation/Testing/mitkSimulationDrawToolTest.cpp b/Modules/Simulation/Testing/mitkSimulationDrawToolTest.cpp index f6a197b2c9..93fd18e5f5 100644 --- a/Modules/Simulation/Testing/mitkSimulationDrawToolTest.cpp +++ b/Modules/Simulation/Testing/mitkSimulationDrawToolTest.cpp @@ -1,80 +1,80 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include #include int mitkSimulationDrawToolTest(int argc, char* argv[]) { MITK_TEST_BEGIN("mitkSimulationDrawToolTest") MITK_TEST_CONDITION_REQUIRED(argc == 4, "Check if command line has correct number of arguments.") MITK_TEST_OUTPUT(<< "Register SimulationObjectFactory.") mitk::RegisterSimulationObjectFactory(); MITK_TEST_OUTPUT(<< "Create RenderingTestHelper.") - mitkRenderingTestHelper renderingTestHelper(1024, 768, argc, argv); + mitk::RenderingTestHelper renderingTestHelper(1024, 768, argc, argv); renderingTestHelper.SetMapperIDToRender3D(); mitk::DataNode* simulationNode = renderingTestHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Simulation")); MITK_TEST_CONDITION_REQUIRED(simulationNode != NULL, "Check if simulation scene was loaded correctly."); MITK_TEST_OUTPUT(<< "Initialize simulation.") mitk::Simulation::Pointer simulation = dynamic_cast(simulationNode->GetData()); simulation->SetAsActiveSimulation(); simulation->GetRootNode()->execute(sofa::core::ExecParams::defaultInstance()); MITK_TEST_OUTPUT(<< "Set camera.") renderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Frontal); renderingTestHelper.GetVtkRenderer()->ResetCamera(); simulationNode->SetBoolProperty("Simulation.Visual.Visual Models", false); simulationNode->SetBoolProperty("Simulation.Behavior.Behavior Models", true); // renderingTestHelper.SaveReferenceScreenShot(".../CMakeExternals/Source/MITK-Data/Simulation/drawTool1024x768REF.png"); MITK_TEST_CONDITION(renderingTestHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "Compare behavior models with reference image.") simulationNode->SetBoolProperty("Simulation.Behavior.Behavior Models", false); simulationNode->SetBoolProperty("Simulation.Behavior.Force Fields", true); // renderingTestHelper.SaveReferenceScreenShot(".../CMakeExternals/Source/MITK-Data/Simulation/drawTool1024x768REF_1.png"); MITK_TEST_CONDITION(renderingTestHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "Compare force fields with reference image.") simulationNode->SetBoolProperty("Simulation.Behavior.Force Fields", false); simulationNode->SetBoolProperty("Simulation.Collision.Collision Models", true); // renderingTestHelper.SaveReferenceScreenShot(".../CMakeExternals/Source/MITK-Data/Simulation/drawTool1024x768REF_2.png"); MITK_TEST_CONDITION(renderingTestHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "Compare collision models with reference image.") simulationNode->SetBoolProperty("Simulation.Options.Wire Frame", true); // renderingTestHelper.SaveReferenceScreenShot(".../CMakeExternals/Source/MITK-Data/Simulation/drawTool1024x768REF_3.png"); MITK_TEST_CONDITION(renderingTestHelper.CompareRenderWindowAgainstReference(argc, argv, 336.0) == true, "Compare collision models (wire frame) with reference image.") simulationNode->SetBoolProperty("Simulation.Collision.Collision Models", false); simulationNode->SetBoolProperty("Simulation.Mapping.Visual Mappings", true); simulationNode->SetBoolProperty("Simulation.Options.Wire Frame", false); // renderingTestHelper.SaveReferenceScreenShot(".../CMakeExternals/Source/MITK-Data/Simulation/drawTool1024x768REF_4.png"); MITK_TEST_CONDITION(renderingTestHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "Compare visual mappings with reference image.") MITK_TEST_END() } diff --git a/Modules/Simulation/Testing/mitkSimulationMapper3DTest.cpp b/Modules/Simulation/Testing/mitkSimulationMapper3DTest.cpp index f4a78d0d83..ff48ee627e 100644 --- a/Modules/Simulation/Testing/mitkSimulationMapper3DTest.cpp +++ b/Modules/Simulation/Testing/mitkSimulationMapper3DTest.cpp @@ -1,64 +1,64 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ #include #include #include #include #include #include int mitkSimulationMapper3DTest(int argc, char* argv[]) { MITK_TEST_BEGIN("mitkSimulationMapper3DTest") MITK_TEST_CONDITION_REQUIRED(argc == 4, "Check if command line has correct number of arguments.") MITK_TEST_OUTPUT(<< "Register SimulationObjectFactory.") mitk::RegisterSimulationObjectFactory(); MITK_TEST_OUTPUT(<< "Create RenderingTestHelper.") - mitkRenderingTestHelper renderingTestHelper(1024, 768, argc, argv); + mitk::RenderingTestHelper renderingTestHelper(1024, 768, argc, argv); renderingTestHelper.SetMapperIDToRender3D(); mitk::DataNode* simulationNode = renderingTestHelper.GetDataStorage()->GetNode(mitk::NodePredicateDataType::New("Simulation")); MITK_TEST_CONDITION_REQUIRED(simulationNode != NULL, "Check if simulation scene was loaded correctly."); MITK_TEST_OUTPUT(<< "Initialize simulation.") mitk::Simulation::Pointer simulation = dynamic_cast(simulationNode->GetData()); simulation->SetAsActiveSimulation(); simulation->GetRootNode()->execute(sofa::core::ExecParams::defaultInstance()); MITK_TEST_OUTPUT(<< "Set camera.") renderingTestHelper.SetViewDirection(mitk::SliceNavigationController::Frontal); renderingTestHelper.GetVtkRenderer()->ResetCamera(); // renderingTestHelper.SaveReferenceScreenShot(".../CMakeExternals/Source/MITK-Data/Simulation/mapper1024x768REF.png"); MITK_TEST_CONDITION(renderingTestHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "Compare visual models with reference image.") simulationNode->SetBoolProperty("Simulation.Options.Normals", true); // renderingTestHelper.SaveReferenceScreenShot(".../CMakeExternals/Source/MITK-Data/Simulation/mapper1024x768REF_1.png"); MITK_TEST_CONDITION(renderingTestHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "Compare visual model (normals) with reference image.") simulationNode->SetBoolProperty("Simulation.Options.Normals", false); simulationNode->SetBoolProperty("Simulation.Options.Wire Frame", true); // renderingTestHelper.SaveReferenceScreenShot(".../CMakeExternals/Source/MITK-Data/Simulation/mapper1024x768REF_2.png"); MITK_TEST_CONDITION(renderingTestHelper.CompareRenderWindowAgainstReference(argc, argv, 531.0) == true, "Compare visual model (wire frame) with reference image.") MITK_TEST_END() } diff --git a/Modules/ToFHardware/Testing/mitkPlayerLoadAndRenderDepthDataTest.cpp b/Modules/ToFHardware/Testing/mitkPlayerLoadAndRenderDepthDataTest.cpp index 0790a6e519..428b208843 100644 --- a/Modules/ToFHardware/Testing/mitkPlayerLoadAndRenderDepthDataTest.cpp +++ b/Modules/ToFHardware/Testing/mitkPlayerLoadAndRenderDepthDataTest.cpp @@ -1,106 +1,106 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" #include "mitkToFCameraMITKPlayerDevice.h" //VTK #include #include #include #include int mitkPlayerLoadAndRenderDepthDataTest(int argc, char* argv[]) { MITK_TEST_BEGIN("mitkPlayerLoadAndRenderDepthDataTest"); try { mitk::ToFCameraMITKPlayerDevice::Pointer playerDevice = mitk::ToFCameraMITKPlayerDevice::New(); MITK_TEST_CONDITION_REQUIRED(argc >=2, "Testing if enough input parameters are set. Usage: Testname, ImageName (must be in MITK_TOF_DATA_DIR), -V /path/to/reference/screenshot"); std::string dirname = MITK_TOF_DATA_DIR; std::string distanceFileName = dirname + "/" + argv[1]; playerDevice->SetProperty("DistanceImageFileName",mitk::StringProperty::New(distanceFileName)); MITK_TEST_CONDITION_REQUIRED(playerDevice->IsCameraActive()==false,"The device (player) should not be active before starting."); MITK_TEST_CONDITION_REQUIRED(playerDevice->ConnectCamera()==true,"ConnectCamera() should return true in case of success."); MITK_TEST_OUTPUT(<< "Device connected"); playerDevice->StartCamera(); MITK_TEST_OUTPUT(<< "Device started"); MITK_TEST_CONDITION_REQUIRED(playerDevice->IsCameraActive()==true,"After starting the device, the device should be active."); //initialize an array with the correct size unsigned int captureWidth = playerDevice->GetCaptureWidth(); unsigned int captureHeight = playerDevice->GetCaptureHeight(); unsigned int numberOfPixels = captureWidth*captureHeight; float* distances = new float[numberOfPixels]; int imageSequence = 0; //fill the array with the device output playerDevice->GetDistances(distances,imageSequence); //initialize an image and fill it with the array unsigned int dimension[2]; dimension[0] = captureWidth; dimension[1] = captureHeight; mitk::Image::Pointer mitkDepthImage = mitk::Image::New(); mitkDepthImage->Initialize(mitk::PixelType(mitk::MakeScalarPixelType()), 2, dimension,1); mitkDepthImage->SetSlice(distances); //create a node to pass it to the mitkRenderingTestHelper mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(mitkDepthImage); // 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 - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //Set the opacity for all images //for now this test renders in sagittal view direction renderingHelper.AddNodeToStorage(node); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { renderingHelper.SaveReferenceScreenShot("/home/kilgus/Pictures/output.png"); } //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); //Wait some time to avoid threading issues. itksys::SystemTools::Delay(1000); playerDevice->StopCamera(); MITK_TEST_OUTPUT(<< "Device stopped"); MITK_TEST_CONDITION_REQUIRED(playerDevice->IsCameraActive()==false,"After stopping the device, the device should be inactive."); MITK_TEST_CONDITION_REQUIRED(playerDevice->DisconnectCamera()==true, "DisconnectCamera() should return true in case of success."); MITK_TEST_OUTPUT(<< "Device disconnected"); delete[] distances; } catch(std::exception &e) { MITK_ERROR << "Unknown exception occured: " << e.what(); } MITK_TEST_END(); } diff --git a/Modules/ToFHardware/Testing/mitkPlayerLoadAndRenderRGBDataTest.cpp b/Modules/ToFHardware/Testing/mitkPlayerLoadAndRenderRGBDataTest.cpp index 0cce6d864f..69757d567a 100644 --- a/Modules/ToFHardware/Testing/mitkPlayerLoadAndRenderRGBDataTest.cpp +++ b/Modules/ToFHardware/Testing/mitkPlayerLoadAndRenderRGBDataTest.cpp @@ -1,107 +1,107 @@ /*=================================================================== The Medical Imaging Interaction Toolkit (MITK) Copyright (c) German Cancer Research Center, Division of Medical and Biological Informatics. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See LICENSE.txt or http://www.mitk.org for details. ===================================================================*/ //MITK #include "mitkTestingMacros.h" #include "mitkRenderingTestHelper.h" #include "mitkToFCameraMITKPlayerDevice.h" //VTK #include #include #include #include int mitkPlayerLoadAndRenderRGBDataTest(int argc, char* argv[]) { MITK_TEST_BEGIN("mitkPlayerLoadAndRenderRGBDataTest"); try { mitk::ToFCameraMITKPlayerDevice::Pointer playerDevice = mitk::ToFCameraMITKPlayerDevice::New(); MITK_TEST_CONDITION_REQUIRED(argc >=2, "Testing if enough input parameters are set. Usage: Testname, ImageName (must be in MITK_TOF_DATA_DIR), -V /path/to/reference/screenshot"); std::string dirname = MITK_TOF_DATA_DIR; std::string rgbFileName = dirname + "/" + argv[1]; playerDevice->SetProperty("RGBImageFileName",mitk::StringProperty::New(rgbFileName)); MITK_TEST_CONDITION_REQUIRED(playerDevice->IsCameraActive()==false,"The device (player) should not be active before starting."); MITK_TEST_CONDITION_REQUIRED(playerDevice->ConnectCamera()==true,"ConnectCamera() should return true in case of success."); MITK_TEST_OUTPUT(<< "Device connected"); playerDevice->StartCamera(); MITK_TEST_OUTPUT(<< "Device started"); MITK_TEST_CONDITION_REQUIRED(playerDevice->IsCameraActive()==true,"After starting the device, the device should be active."); //initialize an array with the correct size unsigned int captureWidth = playerDevice->GetCaptureWidth(); unsigned int captureHeight = playerDevice->GetCaptureHeight(); unsigned int numberOfPixels = captureWidth*captureHeight; unsigned char* rgbDataArray = new unsigned char[numberOfPixels*3]; int imageSequence = 0; //fill the array with the device output playerDevice->GetRgb(rgbDataArray, imageSequence); //initialize an image and fill it with the array unsigned int dimension[2]; dimension[0] = captureWidth; dimension[1] = captureHeight; mitk::Image::Pointer rgbImage = mitk::Image::New(); rgbImage->Initialize(mitk::PixelType(mitk::MakePixelType, 3>()), 2, dimension,1); rgbImage->SetSlice(rgbDataArray); //create a node to pass it to the mitkRenderingTestHelper mitk::DataNode::Pointer node = mitk::DataNode::New(); node->SetData(rgbImage); // 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 - mitkRenderingTestHelper renderingHelper(640, 480, argc, argv); + mitk::RenderingTestHelper renderingHelper(640, 480, argc, argv); //Set the opacity for all images //for now this test renders in sagittal view direction renderingHelper.AddNodeToStorage(node); renderingHelper.Render(); //use this to generate a reference screenshot or save the file: bool generateReferenceScreenshot = false; if(generateReferenceScreenshot) { renderingHelper.SaveReferenceScreenShot("/home/kilgus/Pictures/output.png"); } //### Usage of CompareRenderWindowAgainstReference: See docu of mitkRrenderingTestHelper MITK_TEST_CONDITION( renderingHelper.CompareRenderWindowAgainstReference(argc, argv) == true, "CompareRenderWindowAgainstReference test result positive?" ); //Wait some time to avoid threading issues. itksys::SystemTools::Delay(1000); playerDevice->StopCamera(); MITK_TEST_OUTPUT(<< "Device stopped"); MITK_TEST_CONDITION_REQUIRED(playerDevice->IsCameraActive()==false,"After stopping the device, the device should be inactive."); MITK_TEST_CONDITION_REQUIRED(playerDevice->DisconnectCamera()==true, "DisconnectCamera() should return true in case of success."); MITK_TEST_OUTPUT(<< "Device disconnected"); delete[] rgbDataArray; } catch(std::exception &e) { MITK_ERROR << "Unknown exception occured: " << e.what(); } MITK_TEST_END(); }