Commit 870dd114 authored by David C. Lonie's avatar David C. Lonie

Add new GL2PS testing system using ghostscript.

This commit replaces the md5sum based GL2PS tests, which were
unreliable across GL implementations and difficult to maintain,
with a ghost script based approach.

Testing is performed as follows:
1) The unit tests generate a post script file
2) A CMake script, CMake/RasterizePostScript.cmake is called, which
   runs ghostscript to rasterize the postscript file into a png image.
3) A PNGCompare test is called, which uses new API in vtkTesting to
   read the png file back in and perform a fuzzy image diff. PNGCompare
   lives in the Rendering/GL2PS module.

Change-Id: I0e99b903512166741fe572ce417c1d0d480c34cd
parent 8a2e41cc
#
# Simple CMake -P script to compare the MD5 hash of files. Usage:
#
# cmake -DTESTFILE=<filespec> -DGLOBEXP=<glob expression> -DCLEANTESTFILE=<bool> -P CompareFileMD5.cmake
#
# TESTFILE is the test file, GLOB expression referring to a collection of
# reference files. This can be used to compare file produced by a test
# (TESTFILE) to one or more baselines (glob expression GLOBEXP). If
# CLEANTESTFILE is set to some true value, the test file will be deleted if a
# matching hash is found.
#
# The script will exit silently if the test file's hash matches the hash
# of any reference file (success), or print a line starting with MATCH_FAIL
# and several lines of supplemental information otherwise.
#
macro(dumpoutput lines)
foreach(line ${lines})
message("MATCH_FAIL: ${line}")
endforeach()
endmacro()
set(HASH_FOUND FALSE)
set(output "Comparing MD5 sum of; \"${TESTFILE}\"; to glob; \"${GLOBEXP}\"")
file(GLOB REFFILES ${GLOBEXP})
if(NOT REFFILES)
list(APPEND output "glob expression '${GLOBEXP}' does not refer to any files.")
else()
file(MD5 ${TESTFILE} TESTHASH)
set(output ${output} "Testfile:;${TESTHASH} - ${TESTFILE};Baselines:")
foreach(FILEN ${REFFILES})
file(MD5 ${FILEN} HASHN)
set(output ${output} "${HASHN} - ${FILEN}")
if(${TESTHASH} STREQUAL ${HASHN})
set(HASH_FOUND TRUE)
endif()
endforeach()
endif()
if(NOT HASH_FOUND)
set(output ${output} "Matching hash not found!")
dumpoutput("${output}")
else()
if(${CLEANTESTFILE})
file(REMOVE ${TESTFILE})
endif()
endif()
#
# Simple CMake -P script to rasterize a postscript file to a png image.
#
# Usage:
#
# cmake -DPSFILE=<postscript file>
# [ -DPNGFILE=<png file> ]
# -DGS_EXECUTABLE=<ghostscript executable>
# -DREMOVEPS=<bool>
# -P RasterizePostScript.cmake
#
# PSFILE is the input postscript file, PNGFILE is the output png file path. If
# PNGFILE is not specified, it will have the same basename as PSFILE, but with
# a .png extension.
#
# The script simple calls ghostscript with the relevant parameters to produce
# a 500x500 png. The path to the ghostscript executable for your system must be
# specified in GS_EXECUTABLE.
#
# If REMOVEPS is true, the postscript file will be removed upon successful
# conversion.
if(NOT PSFILE)
message(FATAL_ERROR "PSFILE is not specified!")
endif()
if(NOT GS_EXECUTABLE)
message(FATAL_ERROR "GS_EXECUTABLE is not specified!")
endif()
if(NOT PNGFILE)
get_filename_component(BASENAME "${PSFILE}" NAME_WE)
get_filename_component(PSPATH "${PSFILE}" PATH)
set(PNGFILE "${PSPATH}/${BASENAME}.png")
endif()
# Remove any old output (in case conversion fails)
file(REMOVE "${PNGFILE}")
# Get the bounding box
execute_process(COMMAND "${GS_EXECUTABLE}" -sSAFER -sBATCH -sNOPAUSE -sDEVICE=bbox "${PSFILE}"
RESULT_VARIABLE EXITCODE ERROR_VARIABLE BBOXOUT)
if(NOT ${EXITCODE} EQUAL 0)
message(FATAL_ERROR "GhostScript exited with status ${EXITCODE}:\n${BBOXOUT}")
endif()
string(REGEX MATCH "^%%BoundingBox:[ ]+[0-9-]+[ ]+[0-9-]+[ ]+[0-9]+[ ]+[0-9]+"
BBOX ${BBOXOUT})
string(REGEX REPLACE
"^%%BoundingBox:[ ]+[0-9-]+[ ]+[0-9-]+[ ]+([0-9]+)[ ]+([0-9]+)"
"\\1x\\2" BBOX ${BBOX})
execute_process(COMMAND "${GS_EXECUTABLE}" -sSAFER -sBATCH -sNOPAUSE -sDEVICE=png16m "-sOutputFile=${PNGFILE}" -g${BBOX} "${PSFILE}"
RESULT_VARIABLE EXITCODE OUTPUT_VARIABLE ERRORSTR)
if(NOT ${EXITCODE} EQUAL 0)
message(FATAL_ERROR "GhostScript exited with status ${EXITCODE}:\n${ERRORSTR}")
endif()
if(REMOVEPS)
file(REMOVE "${PSFILE}")
endif()
......@@ -338,6 +338,11 @@ endif()
option(VTK_MAKE_INSTANTIATORS "Should all modules build instantiators" OFF)
mark_as_advanced(VTK_MAKE_INSTANTIATORS)
#----------------------------------------------------------------------
# Find the GhostScript executable for GL2PS tests.
find_program(VTK_GHOSTSCRIPT_EXECUTABLE gs gswin32c gsos2)
mark_as_advanced(VTK_GHOSTSCRIPT_EXECUTABLE)
#----------------------------------------------------------------------
# Load the module DAG.
include(vtkModuleTop)
......
set(GL2PSTests
TestContextGL2PS.cxx
TestGL2PSExporterMultipleRenderers.cxx
TestGL2PSExporterRaster.cxx
TestGL2PSExporterRasterExclusion.cxx
TestGL2PSExporterVector.cxx
TestGL2PSExporterVolumeRaster.cxx
TestGL2PSTextActor3D.cxx
TestStackedPlotGL2PS.cxx
)
# Only run GL2PS tests if GhostScript is available if VTK_DATA_ROOT is set
if(VTK_GHOSTSCRIPT_EXECUTABLE AND VTK_DATA_ROOT)
set(GL2PSTests
TestContextGL2PS.cxx
TestGL2PSExporterMultipleRenderers.cxx
TestGL2PSExporterRaster.cxx
TestGL2PSExporterRasterExclusion.cxx
TestGL2PSExporterVector.cxx
TestGL2PSExporterVolumeRaster.cxx
TestGL2PSTextActor3D.cxx
TestStackedPlotGL2PS.cxx
)
endif()
set(MyTests
X3DTest.cxx
......@@ -43,30 +46,42 @@ foreach(test ${TestsToRun})
endforeach()
# The GL2PS tests produce postscript output, which cannot be compared using
# the built-in image regression framework. Instead, calculate and compare
# md5 sums using a CMake script.
# The file(MD5 ...) subcommand is not available in CMake < 2.8.7
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.8 OR
("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" EQUAL 2.8 AND
"${CMAKE_PATCH_VERSION}" GREATER 7))
set(CMAKE_HAS_FILE_MD5_SUBCOMMAND TRUE)
endif()
if(CMAKE_HAS_FILE_MD5_SUBCOMMAND AND GL2PSTests AND VTK_DATA_ROOT)
# the built-in image regression framework. The tests added above will create the
# postscript, while the following tests will convert the postscript to a PNG and
# run the PNGCompare test target to do an image diff on the output against a
# baseline.
if(GL2PSTests)
foreach(test ${GL2PSTests})
# Convert ps to png
get_filename_component(TName ${test} NAME_WE)
add_test(NAME ${vtk-module}Cxx-${TName}-CheckMD5sum
add_test(NAME ${vtk-module}Cxx-${TName}-RasterizePNG
COMMAND ${CMAKE_COMMAND}
-DTESTFILE=${VTK_TEST_OUTPUT_DIR}/${TName}.ps
-DGLOBEXP=${VTK_DATA_ROOT}/Baseline/Hybrid/${TName}*.ps
-DCLEANTESTFILE=1
-P ${CMAKE_CURRENT_SOURCE_DIR}/../../../../CMake/CompareFileMD5.cmake
-DPSFILE=${VTK_TEST_OUTPUT_DIR}/${TName}.ps
-DPNGFILE=${VTK_TEST_OUTPUT_DIR}/${TName}-raster.png
-DGS_EXECUTABLE=${VTK_GHOSTSCRIPT_EXECUTABLE}
-DREMOVEPS=1
-P ${CMAKE_CURRENT_SOURCE_DIR}/../../../../CMake/RasterizePostScript.cmake
)
set_tests_properties("${vtk-module}Cxx-${TName}-CheckMD5sum"
set_tests_properties("${vtk-module}Cxx-${TName}-RasterizePNG"
PROPERTIES
DEPENDS "${vtk-module}Cxx-${TName}"
REQUIRED_FILES
"${VTK_DATA_ROOT}/Baseline/Hybrid/${TName}.ps;${VTK_TEST_OUTPUT_DIR}/${TName}.ps"
FAIL_REGULAR_EXPRESSION "MATCH_FAIL"
"${VTK_TEST_OUTPUT_DIR}/${TName}.ps"
)
# Image diff rasterized png with baseline
add_test(NAME ${vtk-module}Cxx-${TName}-VerifyRasterizedPNG
COMMAND vtkRenderingGL2PSCxxTests PNGCompare
-D ${VTK_DATA_ROOT}
-T ${VTK_TEST_OUTPUT_DIR}
-V Baseline/Hybrid/${TName}-rasterRef.png
--test-file ${VTK_TEST_OUTPUT_DIR}/${TName}-raster.png
)
set_tests_properties("${vtk-module}Cxx-${TName}-VerifyRasterizedPNG"
PROPERTIES
DEPENDS "${vtk-module}Cxx-${TName}-RasterizePNG"
REQUIRED_FILES
"${VTK_TEST_OUTPUT_DIR}/${TName}-raster.png"
)
endforeach()
endif()
# Compile the PNGCompare test, which is used to validate PNG images (read from
# disk, not generated in VTK). The CMake/RasterizePostScript script can be used
# to create a png image from GL2PS output.
set(MyTests PNGCompare.cxx)
# Use the testing object factory, to reduce boilerplate code in tests.
include("${vtkTestingRendering_SOURCE_DIR}/vtkTestingObjectFactory.cmake")
vtk_module_test_executable(${vtk-module}CxxTests ${Tests})
/*=========================================================================
Program: Visualization Toolkit
Module: PNGCompare.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkNew.h"
#include "vtkTesting.h"
#include "vtkTestingInteractor.h"
#include <string>
#include <cstdio> // For remove
int PNGCompare(int argc, char *argv[])
{
// Grab the test image
std::string testImageFileName;
for (int i = 0; i < argc; ++i)
{
if ( strcmp(argv[i],"--test-file") == 0 && i < argc-1)
{
testImageFileName = std::string(argv[i+1]);
break;
}
}
if (testImageFileName.empty())
{
cout << "Error: No reference image specified (use --test-file <png file>)"
<< endl;
return EXIT_FAILURE;
}
// Set up testing object (modeled after vtkTestingInteractor::Start())
vtkNew<vtkTesting> testing;
// Location of the temp directory for testing
testing->AddArgument("-T");
testing->AddArgument(vtkTestingInteractor::TempDirectory.c_str());
// Location of the Data directory
testing->AddArgument("-D");
testing->AddArgument(vtkTestingInteractor::DataDirectory.c_str());
// The name of the valid baseline image
testing->AddArgument("-V");
testing->AddArgument(vtkTestingInteractor::ValidBaseline.c_str());
// Regression test the image
int result = testing->RegressionTest(testImageFileName,
vtkTestingInteractor::ErrorThreshold);
vtkTestingInteractor::TestReturnStatus = result;
if (result == vtkTesting::PASSED)
{
remove(testImageFileName.c_str());
return EXIT_SUCCESS;
}
else
{
return EXIT_FAILURE;
}
}
......@@ -4,4 +4,6 @@ vtk_module(vtkRenderingGL2PS
vtkRenderingContext2D
vtkRenderingMathText
vtkgl2ps
TEST_DEPENDS
vtkTestingRendering
)
set(GL2PSTests
TestGL2PSMathTextOutput.cxx
TestGL2PSMathTextScaling.cxx
TestMathTextActor.cxx
TestMathTextActor3D.cxx
)
if(VTK_GHOSTSCRIPT_EXECUTABLE AND VTK_DATA_ROOT)
set(GL2PSTests
TestGL2PSMathTextActor.cxx
TestGL2PSMathTextActor3D.cxx
TestGL2PSMathTextOutput.cxx
TestGL2PSMathTextScaling.cxx
)
endif()
if(VTK_DATA_ROOT)
# add tests that require data
set(MyTests
TestContextMathTextImage.cxx
TestMathTextActor.cxx
TestMathTextActor3D.cxx
TestRenderString.cxx
TestStringToPath.cxx
TestIndexedLookupScalarBar.cxx
${GL2PSTests}
${MixedTests}
)
endif()
......@@ -45,30 +50,41 @@ foreach(test ${TestsToRun})
endforeach()
# The GL2PS tests produce postscript output, which cannot be compared using
# the built-in image regression framework. Instead, calculate and compare
# md5 sums using a CMake script.
# The file(MD5 ...) subcommand is not available in CMake < 2.8.7
if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" GREATER 2.8 OR
("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" EQUAL 2.8 AND
"${CMAKE_PATCH_VERSION}" GREATER 7))
set(CMAKE_HAS_FILE_MD5_SUBCOMMAND TRUE)
endif()
if(CMAKE_HAS_FILE_MD5_SUBCOMMAND AND GL2PSTests AND VTK_DATA_ROOT)
foreach(test ${GL2PSTests})
# the built-in image regression framework. The tests added above will create the
# postscript, while the following tests will convert the postscript to a PNG and
# run the PNGCompare test target to do an image diff on the output against a
# baseline.
if(GL2PSTests)
foreach(test ${GL2PSTests} ${MixedTests})
# Convert ps to png
get_filename_component(TName ${test} NAME_WE)
add_test(NAME ${vtk-module}Cxx-${TName}-CheckMD5sum
add_test(NAME ${vtk-module}Cxx-${TName}-RasterizePNG
COMMAND ${CMAKE_COMMAND}
-DTESTFILE=${VTK_TEST_OUTPUT_DIR}/${TName}.ps
-DGLOBEXP=${VTK_DATA_ROOT}/Baseline/Rendering/${TName}*.ps
-DCLEANTESTFILE=1
-P ${CMAKE_CURRENT_SOURCE_DIR}/../../../../CMake/CompareFileMD5.cmake
-DPSFILE=${VTK_TEST_OUTPUT_DIR}/${TName}.ps
-DPNGFILE=${VTK_TEST_OUTPUT_DIR}/${TName}-raster.png
-DGS_EXECUTABLE=${VTK_GHOSTSCRIPT_EXECUTABLE}
-DREMOVEPS=1
-P ${CMAKE_CURRENT_SOURCE_DIR}/../../../../CMake/RasterizePostScript.cmake
)
set_tests_properties("${vtk-module}Cxx-${TName}-CheckMD5sum"
set_tests_properties("${vtk-module}Cxx-${TName}-RasterizePNG"
PROPERTIES
DEPENDS "${vtk-module}Cxx-${TName}"
REQUIRED_FILES
"${VTK_DATA_ROOT}/Baseline/Rendering/${TName}.ps;${VTK_TEST_OUTPUT_DIR}/${TName}.ps"
FAIL_REGULAR_EXPRESSION "MATCH_FAIL"
"${VTK_TEST_OUTPUT_DIR}/${TName}.ps"
)
# Image diff rasterized png with baseline
add_test(NAME ${vtk-module}Cxx-${TName}-VerifyRasterizedPNG
COMMAND vtkRenderingGL2PSCxxTests PNGCompare
-D ${VTK_DATA_ROOT}
-T ${VTK_TEST_OUTPUT_DIR}
-V Baseline/Rendering/${TName}-rasterRef.png
--test-file ${VTK_TEST_OUTPUT_DIR}/${TName}-raster.png
)
set_tests_properties("${vtk-module}Cxx-${TName}-VerifyRasterizedPNG"
PROPERTIES
DEPENDS "${vtk-module}Cxx-${TName}-RasterizePNG"
REQUIRED_FILES
"${VTK_TEST_OUTPUT_DIR}/${TName}-raster.png"
)
endforeach()
endif()
/*=========================================================================
Program: Visualization Toolkit
Module: TestStringToPath.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkMathTextActor.h"
#include "vtkCamera.h"
#include "vtkGL2PSExporter.h"
#include "vtkNew.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestingInteractor.h"
#include "vtkTextProperty.h"
//----------------------------------------------------------------------------
int TestGL2PSMathTextActor(int, char *[])
{
vtkNew<vtkMathTextActor> actor1;
actor1->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor1->GetTextProperty()->SetFontSize(36);
actor1->GetTextProperty()->SetOrientation(0.0);
actor1->GetTextProperty()->SetColor(0.8, 0.8, 0.6);
actor1->SetPosition(0, 0);
actor1->GetTextProperty()->SetVerticalJustificationToBottom();
actor1->GetTextProperty()->SetJustificationToLeft();
vtkNew<vtkMathTextActor> actor2;
actor2->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor2->GetTextProperty()->SetFontSize(36);
actor2->SetPosition(300, 300);
actor2->GetTextProperty()->SetColor(0.7, 0.3, 0.2);
actor2->GetTextProperty()->SetVerticalJustificationToCentered();
actor2->GetTextProperty()->SetJustificationToCentered();
actor2->GetTextProperty()->SetOrientation(90.0);
vtkNew<vtkMathTextActor> actor3;
actor3->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor3->GetTextProperty()->SetFontSize(36);
actor3->SetPosition(600, 600);
actor3->GetTextProperty()->SetColor(0.6, 0.5, 0.8);
actor3->GetTextProperty()->SetVerticalJustificationToTop();
actor3->GetTextProperty()->SetJustificationToRight();
vtkNew<vtkMathTextActor> actor4;
actor4->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor4->GetTextProperty()->SetFontSize(22);
actor4->SetPosition(150, 300);
actor4->GetTextProperty()->SetColor(0.2, 0.6, 0.4);
actor4->GetTextProperty()->SetVerticalJustificationToCentered();
actor4->GetTextProperty()->SetJustificationToCentered();
actor4->GetTextProperty()->SetOrientation(45.0);
vtkNew<vtkMathTextActor> actor5;
actor5->ShallowCopy(actor4.GetPointer());
actor5->SetPosition(450, 300);
vtkNew<vtkRenderer> ren;
vtkNew<vtkRenderWindow> win;
win->AddRenderer(ren.GetPointer());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(win.GetPointer());
ren->AddActor(actor1.GetPointer());
ren->AddActor(actor2.GetPointer());
ren->AddActor(actor3.GetPointer());
ren->AddActor(actor4.GetPointer());
ren->AddActor(actor5.GetPointer());
ren->SetBackground(0.0, 0.0, 0.0);
win->SetSize(600, 600);
win->Render();
vtkNew<vtkGL2PSExporter> exp;
exp->SetRenderWindow(win.GetPointer());
exp->SetFileFormatToPS();
exp->CompressOff();
exp->SetSortToSimple();
exp->DrawBackgroundOn();
std::string fileprefix = vtkTestingInteractor::TempDirectory +
std::string("/TestGL2PSMathTextActor");
exp->SetFilePrefix(fileprefix.c_str());
exp->WriteTimeStampOff(); // Otherwise hashes won't match
exp->Write();
// Finally render the scene and compare the image to a reference image
win->SetMultiSamples(0);
win->GetInteractor()->Initialize();
win->GetInteractor()->Start();
return EXIT_SUCCESS;
}
/*=========================================================================
Program: Visualization Toolkit
Module: TestStringToPath.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkMathTextActor3D.h"
#include "vtkCamera.h"
#include "vtkGL2PSExporter.h"
#include "vtkNew.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkRenderer.h"
#include "vtkTestingInteractor.h"
#include "vtkTextProperty.h"
//----------------------------------------------------------------------------
int TestGL2PSMathTextActor3D(int, char *[])
{
vtkNew<vtkMathTextActor3D> actor1;
actor1->SetInput("$\\int\\frac{1}{\\left(x+a\\right)^2}dx = -\\frac{1}{x+a}$");
actor1->GetTextProperty()->SetFontSize(36);
actor1->GetTextProperty()->SetColor(0.8, 0.8, 0.6);
actor1->SetPosition(-100, -25, 0);
actor1->RotateWXYZ(70, 0, 1, 0);
vtkNew<vtkMathTextActor3D> actor2;
actor2->SetInput("$\\langle\\psi_i\\mid\\psi_j\\rangle = \\delta_{ij}$");
actor2->GetTextProperty()->SetFontSize(40);
actor2->SetPosition(20, 0, -200);
actor2->RotateWXYZ(-70, 0, 1, 0);
actor2->GetTextProperty()->SetColor(0.7, 0.3, 0.2);
vtkNew<vtkMathTextActor3D> actor3;
actor3->SetInput("$\\frac{d}{dx}\\left(\\frac{u(x)}{v(x)}\\right) = "
"\\frac{v\\frac{du}{dx} + u\\frac{dv}{dx}}{v^2}$");
actor3->GetTextProperty()->SetFontSize(36);
actor3->SetPosition(-125, 75, -100);
actor3->RotateWXYZ(50, 1, .5, -.2);
actor3->GetTextProperty()->SetColor(0.6, 0.5, 0.8);
vtkNew<vtkMathTextActor3D> actor4;
actor4->SetInput("$\\hat{H}\\psi = \\left(-\\frac{\\hbar}{2m}\\nabla^2"
" + V(r)\\right) \\psi = \\psi\\cdot E $");
actor4->GetTextProperty()->SetFontSize(22);
actor4->SetPosition(-75, -100, 25);
actor4->RotateWXYZ(40, -.2, 1, .3);
actor4->GetTextProperty()->SetColor(0.2, 0.6, 0.4);
vtkNew<vtkMathTextActor3D> actor5;
actor5->SetInput("$\\frac{d}{dx}\\left(f(x_0)\\right) = \\lim_{h \\to 0}"
"\\frac{f(x_0 + h) - f(x_0)}{h}$");
actor5->GetTextProperty()->SetFontSize(40);
actor5->GetTextProperty()->SetColor(1, 1, 1);
actor5->SetPosition(-240, -110, -500);
actor5->RotateWXYZ(-25, 1, 0, 1);
vtkNew<vtkRenderer> ren;
vtkNew<vtkRenderWindow> win;
win->AddRenderer(ren.GetPointer());
vtkNew<vtkRenderWindowInteractor> iren;
iren->SetRenderWindow(win.GetPointer());
ren->AddActor(actor1.GetPointer());
ren->AddActor(actor2.GetPointer());
ren->AddActor(actor3.GetPointer());
ren->AddActor(actor4.GetPointer());
ren->AddActor(actor5.GetPointer());
ren->SetBackground(0.0, 0.0, 0.0);
ren->GetActiveCamera()->SetPosition(0, 0, 400);
ren->GetActiveCamera()->SetFocalPoint(0, 0, 0);
ren->GetActiveCamera()->SetViewUp(0, 1, 0);
win->SetSize(600, 600);
win->Render();
vtkNew<vtkGL2PSExporter> exp;
exp->SetRenderWindow(win.GetPointer());
exp->SetFileFormatToPS();
exp->CompressOff();
exp->SetSortToSimple();
exp->DrawBackgroundOn();
std::string fileprefix = vtkTestingInteractor::TempDirectory +
std::string("/TestGL2PSMathTextActor3D");
exp->SetFilePrefix(fileprefix.c_str());
exp->WriteTimeStampOff(); // Otherwise hashes won't match
exp->Write();
// Finally render the scene and compare the image to a reference image
win->SetMultiSamples(0);
win->GetInteractor()->Initialize();
win->GetInteractor()->Start();
return EXIT_SUCCESS;
}
......@@ -16,7 +16,6 @@
#include "vtkMathTextActor.h"
#include "vtkCamera.h"
#include "vtkGL2PSExporter.h"
#include "vtkNew.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
......@@ -80,23 +79,7 @@ int TestMathTextActor(int, char *[])
ren->SetBackground(0.0, 0.0, 0.0);
win->SetSize(600, 600);
win->Render();
vtkNew<vtkGL2PSExporter> exp;
exp->SetRenderWindow(win.GetPointer());
exp->SetFileFormatToPS();
exp->CompressOff();
exp->SetSortToSimple();
exp->DrawBackgroundOn();
std::string fileprefix = vtkTestingInteractor::TempDirectory +
std::string("/TestMathTextActor");
exp->SetFilePrefix(fileprefix.c_str());
exp->WriteTimeStampOff(); // Otherwise hashes won't match
exp->Write();
// Finally render the scene and compare the image to a reference image
win->SetMultiSamples(0);
win->GetInteractor()->Initialize();
win->GetInteractor()->Start();
......
......@@ -16,7 +16,6 @@
#include "vtkMathTextActor3D.h"
#include "vtkCamera.h"
#include "vtkGL2PSExporter.h"
#include "vtkNew.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
......@@ -79,27 +78,11 @@ int TestMathTextActor3D(int, char *[])
ren->AddActor(actor5.GetPointer());
ren->SetBackground(0.0, 0.0, 0.0);
win->SetSize(600, 600);
ren->GetActiveCamera()->SetPosition(0, 0, 400);
ren->GetActiveCamera()->SetFocalPoint(0, 0, 0);
ren->GetActiveCamera()->SetViewUp(0, 1, 0);
win->SetSize(600, 600);
win->Render();
vtkNew<vtkGL2PSExporter> exp;
exp->SetRenderWindow(win.GetPointer());
exp->SetFileFormatToPS();
exp->CompressOff();
exp->SetSortToSimple();
exp->DrawBackgroundOn();
std::string fileprefix = vtkTestingInteractor::TempDirectory +
std::string("/TestMathTextActor3D");
exp->SetFilePrefix(fileprefix.c_str());
exp->WriteTimeStampOff(); // Otherwise hashes won't match
exp->Write();
// Finally render the scene and compare the image to a reference image
win->SetMultiSamples(0);
win->GetInteractor()->Initialize();
win->GetInteractor()->Start();
......
......@@ -24,6 +24,7 @@
#include "vtkImageData.h"
#include "vtkTimerLog.h"
#include "vtkSmartPointer.h"
#include "vtkNew.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkInteractorEventRecorder.h"
#include "vtkImageClip.h"
......@@ -392,6 +393,20 @@ int vtkTesting::RegressionTest(double thresh, ostream &os)
return res;
}
//-----------------------------------------------------------------------------
int vtkTesting::RegressionTest(const std::string &pngFileName, double thresh)
{
return this->RegressionTest(pngFileName, thresh, cout);
}
//-----------------------------------------------------------------------------
int vtkTesting::RegressionTest(const std::string &pngFileName, double thresh,