Medical Imaging Interaction Toolkit  2024.06.00
Medical Imaging Interaction Toolkit
mitk::RenderingTestHelper Class Reference

#include <mitkRenderingTestHelper.h>

Collaboration diagram for mitk::RenderingTestHelper:

Classes

class  ArgcHelperClass
 The ArgcHelperClass class is a convenience class to convert a vector of strings to the standard c++ argv and argc arguments. This is necessary for the vtkTesting::Test, since is requires the reference image (and other optional parameters) via command line. More...
 

Public Member Functions

 RenderingTestHelper (int width, int height, int argc, char *argv[], AntiAliasing antiAliasing=AntiAliasing::None)
 Generate a rendering test helper object including a render window of the size width * height (in pixel). More...
 
 RenderingTestHelper (int width, int height, AntiAliasing antiAliasing=AntiAliasing::None)
 Generate a rendering test helper object including a render window of the size width * height (in pixel). More...
 
 ~RenderingTestHelper ()
 
vtkRenderer * GetVtkRenderer ()
 Getter for the vtkRenderer. More...
 
vtkRenderWindow * GetVtkRenderWindow ()
 Getter for the vtkRenderWindow which should be used to call vtkRegressionTestImage. More...
 
void SaveAsPNG (std::string fileName)
 Method can be used to save a screenshot (e.g. reference screenshot as a .png file. More...
 
void SetAutomaticallyCloseRenderWindow (bool automaticallyCloseRenderWindow)
 SetStopRenderWindow Convenience method to make the renderwindow hold after rendering. Useful for debugging. More...
 
void SetImageProperty (const char *propertyKey, mitk::BaseProperty *property)
 This method set the property of the member datastorage. More...
 
void SetViewDirection (mitk::AnatomicalPlane viewDirection)
 Set the view direction of the renderwindow (e.g. sagittal, coronal, axial) More...
 
void ReorientSlices (mitk::Point3D origin, mitk::Vector3D rotation)
 Reorient the slice (e.g. rotation and translation like the swivel mode). More...
 
void Render ()
 Render everything into an mitkRenderWindow. Call SetViewDirection() and SetProperty() before this method. More...
 
mitk::DataStorage::Pointer GetDataStorage ()
 Returns the datastorage, in order to modify the data inside a rendering test. More...
 
void SetMapperID (mitk::BaseRenderer::StandardMapperSlot id)
 SetMapperID Change between Standard2D and 3D mappers. More...
 
void AddNodeToStorage (mitk::DataNode::Pointer node)
 AddNodeToStorage Add a node to the datastorage and perform a reinit which is necessary for rendering. More...
 
void SetMapperIDToRender3D ()
 SetMapperIDToRender3D Convenience method to render in a 3D renderwindow. More...
 
void SetMapperIDToRender2D ()
 SetMapperIDToRender2D Convenience method to render in a 2D renderwindow. More...
 
void SaveReferenceScreenShot (std::string fileName)
 SaveReferenceScreenShot Convenience method to save a reference screen shot. More...
 
bool CompareRenderWindowAgainstReference (int argc, char *argv[], double threshold=10.0)
 CompareRenderWindowAgainstReference Convenience method to compare the image rendered in the internal renderwindow against a reference screen shot. More...
 

Protected Member Functions

void Initialize (int width, int height, AntiAliasing antiAliasing=AntiAliasing::None)
 Initialize Internal method to initialize the renderwindow and set the datastorage. More...
 
void AddToStorage (const std::string &filename)
 This method tries to load the given file into a member datastorage, in order to render it. More...
 
void SetInputFileNames (int argc, char *argv[])
 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. More...
 

Protected Attributes

mitk::RenderWindow::Pointer m_RenderWindow
 
mitk::DataStorage::Pointer m_DataStorage
 
bool m_AutomaticallyCloseRenderWindow
 

Detailed Description

Definition at line 28 of file mitkRenderingTestHelper.h.

Constructor & Destructor Documentation

◆ RenderingTestHelper() [1/2]

mitk::RenderingTestHelper::RenderingTestHelper ( int  width,
int  height,
int  argc,
char *  argv[],
AntiAliasing  antiAliasing = AntiAliasing::None 
)

Generate a rendering test helper object including a render window of the size width * height (in pixel).

Parameters
width
height
argcNumber of parameters. (here: Images) "Usage: [filename1 filenam2 -V referenceScreenshot (optional -T /directory/to/save/differenceImage)]
argvGiven parameters. If no data is inserted via commandline, you can add data later via AddNodeToDataStorage().
antiAliasingThe anti-aliasing mode.

◆ RenderingTestHelper() [2/2]

mitk::RenderingTestHelper::RenderingTestHelper ( int  width,
int  height,
AntiAliasing  antiAliasing = AntiAliasing::None 
)

Generate a rendering test helper object including a render window of the size width * height (in pixel).

◆ ~RenderingTestHelper()

mitk::RenderingTestHelper::~RenderingTestHelper ( )

Default destructor

Member Function Documentation

◆ AddNodeToStorage()

void mitk::RenderingTestHelper::AddNodeToStorage ( mitk::DataNode::Pointer  node)

AddNodeToStorage Add a node to the datastorage and perform a reinit which is necessary for rendering.

Parameters
nodeThe data you want to add.

◆ AddToStorage()

void mitk::RenderingTestHelper::AddToStorage ( const std::string &  filename)
protected

This method tries to load the given file into a member datastorage, in order to render it.

Parameters
filenameThe filename of the file to be loaded (including path).

◆ CompareRenderWindowAgainstReference()

bool mitk::RenderingTestHelper::CompareRenderWindowAgainstReference ( int  argc,
char *  argv[],
double  threshold = 10.0 
)

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.

Parameters
argcNumber of arguments.
argvArguments must(!) contain the term "-V Path/To/Valid/Image.png"
thresholdAllowed difference between two images. Default = 10.0 and was taken from VTK.
Returns
True if the images are equal regarding the threshold. False in all other cases.

◆ GetDataStorage()

mitk::DataStorage::Pointer mitk::RenderingTestHelper::GetDataStorage ( )

Returns the datastorage, in order to modify the data inside a rendering test.

◆ GetVtkRenderer()

vtkRenderer* mitk::RenderingTestHelper::GetVtkRenderer ( )

Getter for the vtkRenderer.

◆ GetVtkRenderWindow()

vtkRenderWindow* mitk::RenderingTestHelper::GetVtkRenderWindow ( )

Getter for the vtkRenderWindow which should be used to call vtkRegressionTestImage.

◆ Initialize()

void mitk::RenderingTestHelper::Initialize ( int  width,
int  height,
AntiAliasing  antiAliasing = AntiAliasing::None 
)
protected

Initialize Internal method to initialize the renderwindow and set the datastorage.

Parameters
widthHeight of renderwindow.
heightWidth of renderwindow.
antiAliasingThe anti-aliasing mode.

◆ Render()

void mitk::RenderingTestHelper::Render ( )

Render everything into an mitkRenderWindow. Call SetViewDirection() and SetProperty() before this method.

◆ ReorientSlices()

void mitk::RenderingTestHelper::ReorientSlices ( mitk::Point3D  origin,
mitk::Vector3D  rotation 
)

Reorient the slice (e.g. rotation and translation like the swivel mode).

◆ SaveAsPNG()

void mitk::RenderingTestHelper::SaveAsPNG ( std::string  fileName)

Method can be used to save a screenshot (e.g. reference screenshot as a .png file.

Parameters
fileNameThe filename of the new screenshot (including path).

◆ SaveReferenceScreenShot()

void mitk::RenderingTestHelper::SaveReferenceScreenShot ( std::string  fileName)

SaveReferenceScreenShot Convenience method to save a reference screen shot.

Parameters
fileNamePath/to/save/the/png/file.

◆ SetAutomaticallyCloseRenderWindow()

void mitk::RenderingTestHelper::SetAutomaticallyCloseRenderWindow ( bool  automaticallyCloseRenderWindow)

SetStopRenderWindow Convenience method to make the renderwindow hold after rendering. Useful for debugging.

Parameters
automaticallyCloseRenderWindowFlag indicating whether the renderwindow should automatically close (false, default) or stay open (true). Useful for debugging.

◆ SetImageProperty()

void mitk::RenderingTestHelper::SetImageProperty ( const char *  propertyKey,
mitk::BaseProperty property 
)

This method set the property of the member datastorage.

Parameters
propertyKey
propertySet 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.

◆ SetInputFileNames()

void mitk::RenderingTestHelper::SetInputFileNames ( int  argc,
char *  argv[] 
)
protected

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.

Parameters
argcNumber of parameters.
argvGiven parameters.

◆ SetMapperID()

void mitk::RenderingTestHelper::SetMapperID ( mitk::BaseRenderer::StandardMapperSlot  id)

SetMapperID Change between Standard2D and 3D mappers.

Parameters
idEnum mitk::BaseRenderer::StandardMapperSlot which defines the mapper.

◆ SetMapperIDToRender2D()

void mitk::RenderingTestHelper::SetMapperIDToRender2D ( )

SetMapperIDToRender2D Convenience method to render in a 2D renderwindow.

◆ SetMapperIDToRender3D()

void mitk::RenderingTestHelper::SetMapperIDToRender3D ( )

SetMapperIDToRender3D Convenience method to render in a 3D renderwindow.

Warning
Does not add helper objects like the image planes to render images in 3D.

◆ SetViewDirection()

void mitk::RenderingTestHelper::SetViewDirection ( mitk::AnatomicalPlane  viewDirection)

Set the view direction of the renderwindow (e.g. sagittal, coronal, axial)

Member Data Documentation

◆ m_AutomaticallyCloseRenderWindow

bool mitk::RenderingTestHelper::m_AutomaticallyCloseRenderWindow
protected

Definition at line 211 of file mitkRenderingTestHelper.h.

◆ m_DataStorage

mitk::DataStorage::Pointer mitk::RenderingTestHelper::m_DataStorage
protected

Definition at line 209 of file mitkRenderingTestHelper.h.

◆ m_RenderWindow

mitk::RenderWindow::Pointer mitk::RenderingTestHelper::m_RenderWindow
protected

Definition at line 208 of file mitkRenderingTestHelper.h.


The documentation for this class was generated from the following file: