Page MenuHomePhabricator

Implement automatic tests for rendering classes
Closed, ResolvedPublic


This is a discussion bug. We need automatic tests to verify changes in rendering (e.g. in the imageVtkMapper2D).

Currentyl, a testprotocol ( is applied manually to verify the functions of the mappers and other involved classes. This is very time consuming.

VTK offers some methods to test rendering automatically. Markus Engel already used them to test the levelwindow. See the attached file for an example.

Event Timeline

kilgus added a subscriber: kilgus.

example of VTK testing methods

I just talked to Markus E.. The attachment is NOT an example of a VTK testing method.

I will push an example, as soon as possible.

I pushed an example to bug-10161-AutomaticRenderingTests and started writing documentation.

I wrote a core change request and pushed a last small fixed to:

I will write some more documentation now.

[f0333e]: Merge branch 'bug-10161-automaticRenderingTests'

Merged commits:

2012-01-18 14:31:34 Thomas Kilgus [996d64]
Improved docu.

2012-01-18 13:44:45 Thomas Kilgus [f5780a]
Run test only if MITK_ENABLE_GUI_TESTING is set.

2012-01-11 17:33:08 Thomas Kilgus [a425f9]
Renamed RenderingTest to ImageVtkMapper2DTest

2012-01-11 16:51:09 Thomas Kilgus [efa766]
Added boolean variable to save the reference screenshot

2012-01-11 16:50:50 Thomas Kilgus [5d6902]
Improved docu.

2012-01-11 16:38:37 Marco Nolden [4fd1b3]
Moved mitkRenderingTestHelper from Core to Testing

2012-01-11 15:54:12 Thomas Kilgus [bce6a3]
Added first empty documentation.

2012-01-11 15:53:59 Thomas Kilgus [55c520]
Added custom test to cmake

2012-01-02 15:44:03 Thomas Kilgus [a2ae77]
Some minor changes.

2012-01-02 11:45:06 Thomas Kilgus [eb5eff]
Test finally working.

2012-01-02 11:16:00 Thomas Kilgus [91c881]
Removed warnings, removed unused code. Using force update to render now.

2011-12-14 17:38:13 Thomas Kilgus [3706a8]
Added the original test by Markus Engel including the RenderingTestHelper class. Reworked the helper class to use an mitkRenderWindow instead a QmitkRenderWindow. Currently, the test is saving the image as a screenshot, however, the screen is not correct yet.

The following warnings occured on the windows dartclient:

1>mitkImageVtkMapper2DTest.obj : warning LNK4217: locally defined symbol ??1mitkRenderingTestHelper@@QAE@XZ (public: thiscall mitkRenderingTestHelper::~mitkRenderingTestHelper(void)) imported in function "int cdecl mitkImageVtkMapper2DTest(int,char * * const)" (?mitkImageVtkMapper2DTest@@YAHHQAPAD@Z)

I will fix this in the next bugsquashing.

The test is currently running on 4 nightly dartclients. Unfortunately, two (out of 4) randomly failed sometimes.

TODO: Ask Caspar if he changed anything on his DartClient on Monday to figure out if the test depends on the desktop configuration.

The test image has a resolution of 5x5 pixels. We think that VTK scales this resolution to the next power of two which is 8, because there are no graphic resources available.

Summary of the test on different DartClient results:

Raluca's DartClient failed 4 times and she used VPN connection a lot.
Anja's DartClient passed all the time and she never used VPN.
Caspar's DartClient failed twice and he also used VPN. I asked him to not use VPN today => The test passed!!!
Basti's DartClient passed all the time except today and asked him to use VPN!!!

> We have a strong evidence that VPN connections make the test fail!

The test also passed today on Tobias DartClient (no VPN involved).

Today we tried to make the off screen rendering work. You have to install the mesa library and to enable VTK_OPENGL_HAS_OSMESA in VTK.

We successfully applied the following VTK example:

We tried to adapt MITK using the changes in the example. It should be just very few code changes in mitkRenderWindow.cpp:
vtkGraphicsFactory::SetOffScreenOnlyMode( 1 );
vtkGraphicsFactory::SetUseMesaClasses( 1 );
vtkImagingFactory::SetUseMesaClasses( 1 );

m_vtkRenderWindow->SetOffScreenRendering( 1 );

However, the test crashes in:
vtkOpenGLExtensionManager.cxx l. 513

because the OpenGL context is not initialized for some reason. We checked that the VTK example also passes that line, and that there the context is initialized.

There musst be a site effect somewhere inside MITK influencing the context. In the VTK example no interaction is used, but according to the VTK documentation, the off screen rendering should work even with interaction.

We figured out that the VTK example does not work in MITK. However, if we set the as OPENGL_gl_LIBRARY, the example works fine.

We have two problems now:

  1. Link the Mesa Lib: Sascha found corresponding VTK CMake code to link different gl libs and we think that we can adapt this for MITK in the next bugsquashing.
  1. The general rendering test: The VTK example works fine, but the mitkImageVtkMapper2DTest crashes in vtkPixelBufferObject.cxx l. 305 if you add the RGB image to the data storage. If there is no image added, the test is able to save a black screen shot without creating any renderwindow at all. (Everything observed with the linked

With a newer version (8.0.2) of Mesa we were able to run the VTK example inside the console. We had to uninstall the Nvidia driver of the arch linux system.

Version 7.11 of Mesa caused a segmentation fault in the VTK example.

Some good news:
I found someone on the Mesa-dev Mailing list with similar issues. And folled these instructions (see ) to configure VTK and Mesa. In the post Mesa 7.11.2 is used, which sadly didn't work as proposed. However, they use fedora and not ubuntu 12.04.

I tried the same configuration with a self-build Mesa 8.0.2 and finally the VTK example and the enhanced version including vtkTexture worked! Next week I will try to make the mitk test work (which should hopefully be easy now).

Note: VTK does not build completely with the given configuration. TODO: Check if one can set the in order to build the entire VTK.

CMake Instructions for VTK 5.8:

cmake \

-D"OPENGL_INCLUDE_DIR:PATH=/tmp/Mesa-7.11.2/include" \
-D"OPENGL_glu_LIBRARY:FILEPATH=/tmp/Mesa-7.11.2/lib/" \
-D"OSMESA_INCLUDE_DIR:PATH=/tmp/Mesa-7.11.2/include" \
-D"OSMESA_LIBRARY:FILEPATH=/tmp/Mesa-7.11.2/lib/" \


> results in errors

Mesa 8.0.2 configuration:
./configure --enable-osmesa

The imageVtkMapper2DTest is now working correctly on my ubuntu 12.04. with Mesa 8.0.2. However, there are still build issues if i build VTK with Mesa.

[9168f5]: Merge branch 'bug-10161-RefactoringFirstTestAndHelper'

Merged commits:

2012-05-24 10:18:29 Thomas Kilgus [3b9728]
Added rendering tests including parameters to CMakeLists.txt.

2012-05-23 17:32:04 Thomas Kilgus [82e48e]
Set new master of MITK-data including md5sum and git hash.

2012-05-23 16:49:54 Thomas Kilgus [e7eb65]
Added test for color property.

2012-05-23 16:26:30 Thomas Kilgus [fa422d]
Added test for opacity.

2012-05-23 16:15:21 Thomas Kilgus [6c5cf7]
LevelWindow test for now renders sagitall

2012-05-23 16:03:25 Thomas Kilgus [5757a5]
Added new level window test which tests the blood level window.

2012-05-23 16:02:41 Thomas Kilgus [d9f9fb]
Fixed includes.

2012-05-23 15:30:19 Thomas Kilgus [a881c5]
Refactored RenderingTestHelper to perform most steps which are needed for any generic rendering test.

Adapted also the existing mitkImageVtkMapper2D test to make use of the changes.

[5abc91]: Merge branch 'bug-10161-RefactoringFirstTestAndHelper'

Merged commits:

2012-05-25 09:23:36 Thomas Kilgus [8e2e77]
COMP: Added rendering tests including parameters to CMakeLists.txt and replaced old md5sum.

Since the following 3 tests fail on the dartclients where they are activated, Ingmar asked me to remove them until they pass:

mitkImageVtkMapper2D_pic3dColorBlue640x480 Failed 620ms Completed
mitkImageVtkMapper2D_pic3dLevelWindow640x480 Failed 650ms Completed
mitkImageVtkMapper2D_pic3dOpacity640x480 Failed 650ms Completed

I would like to commit a small CMake change (see branch: bug-10161-RemoveFailingTest) now in order to make the nightlies green. Furthermore, I would like to active the rendering tests on all Mac and Windows dartclients. I don't think that this is important for the release, but it's anyway just a very small cmake modification and useful for the dashboard manager.

The status of the failing rendering tests can be seen in T12124.

[542e3e]: Merge branch 'bug-10161-RemoveFailingTests'

Merged commits:

2012-06-11 13:21:50 Thomas Kilgus [5b7eb0]
Now all Mac and Windows DartClients build the rendering tests. Outcommented 3 failing tests.

[01108b]: Merge branch 'bug-10161-RemoveFailingTests'

Merged commits:

2012-06-11 16:17:16 Thomas Kilgus [fe6a67]
removed cmake warning

[b0d14c]: Merge branch 'bug-10161-ResizeFix'

Merged commits:

2012-06-20 17:01:16 Alexandra Derntl [309eb5]
resizing works now correctly and therefore the renderingtests should work now

[c48a6d]: Merge branch 'bug-10161-ResizeFix'

Merged commits:

2012-06-21 15:54:25 Alexandra Derntl [8e12e6]
COMP: added correct Hash-Value

[c48027]: Merge branch 'bug-10161-ResizeFix'

Merged commits:

2012-06-22 10:21:52 Alexandra Derntl [3a70a5]
COMP: bug is very critical and get fixed later

First tests are running daily.