Commit 84892990 authored by Utkarsh Ayachit's avatar Utkarsh Ayachit

Added test to test vtkSynchronizedRenderers.

Adding test to test use of vtkSynchronizedRenderers in client-server mode. Also
fixed vtkTestDriver to respect exit code from processes so that it catches
errors.

Change-Id: I2cf888bbb3aadf5a534a7e683106bc86cfba984b
parent 3afa8879
......@@ -33,3 +33,9 @@ for cmdlist in command_lists:
# terminated anyways, so we don't need to handle timeout specially.
for proc in procs:
proc.wait()
for proc in procs:
if proc.returncode != 0:
print "ERROR: A process exited with error. Test will fail."
sys.exit(1) # error
print "All's well!"
......@@ -2,7 +2,7 @@ include(vtkMPI)
vtk_add_test_cxx(PrmMagnify.cxx)
vtk_test_cxx_executable(${vtk-module}CxxTests)
vtk_module_test_executable(TestClientServerRendering TestClientServerRendering.cxx)
vtk_add_test_mpi(TestDistributedDataCompositeZPass.cxx TESTING_DATA)
vtk_add_test_mpi(TestPCompositeZPass.cxx TESTING_DATA)
vtk_add_test_mpi(TestPShadowMapPass.cxx TESTING_DATA)
......@@ -12,3 +12,25 @@ vtk_mpi_link(TestDistributedDataCompositeZPass)
vtk_mpi_link(TestPCompositeZPass)
vtk_mpi_link(TestPShadowMapPass)
vtk_mpi_link(TestParallelRendering)
if (PYTHON_EXECUTABLE)
vtk_module_test_executable(
${vtk-module}-TestClientServerRendering TestClientServerRendering.cxx)
ExternalData_add_test(VTKData
NAME ${vtk-module}-TestClientServerRendering
COMMAND ${PYTHON_EXECUTABLE}
${VTK_CMAKE_DIR}/vtkTestDriver.py
--process
$<TARGET_FILE:${vtk-module}-TestClientServerRendering>
--port 12367
--server
-D ${VTK_TEST_DATA_DIR}
--process
$<TARGET_FILE:${vtk-module}-TestClientServerRendering>
--port 12367
-D ${VTK_TEST_DATA_DIR}
-T ${VTK_TEST_OUTPUT_DIR}
-V "DATA{${${vtk-module}_SOURCE_DIR}/Testing/Data/Baseline/TestClientServerRendering.png,:}"
)
endif()
......@@ -33,7 +33,6 @@
#include "vtkPieceScalars.h"
#include "vtkPKdTree.h"
#include "vtkPolyDataMapper.h"
#include "vtkProcess.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkOpenGLRenderer.h"
......@@ -51,19 +50,25 @@
#include "vtkTranslucentPass.h"
#include "vtkUnstructuredGrid.h"
#include "vtkVolumetricPass.h"
#include "vtkNew.h"
#include "vtkTesting.h"
#include <vtksys/CommandLineArguments.hxx>
class MyProcess : public vtkProcess
class MyProcess : public vtkObject
{
public:
static MyProcess *New();
vtkTypeMacro(MyProcess, vtkProcess);
bool IsServer;
vtkTypeMacro(MyProcess, vtkObject);
vtkSetMacro(ImageReductionFactor, int);
// Returns true on success.
bool Execute(int argc, char** argv);
virtual void Execute();
// Get/Set the controller.
vtkSetObjectMacro(Controller, vtkMultiProcessController);
vtkGetObjectMacro(Controller, vtkMultiProcessController);
bool IsServer;
private:
// Creates the visualization pipeline and adds it to the renderer.
void CreatePipeline(vtkRenderer* renderer);
......@@ -73,7 +78,9 @@ private:
protected:
MyProcess();
~MyProcess();
int ImageReductionFactor;
vtkMultiProcessController* Controller;
};
vtkStandardNewMacro(MyProcess);
......@@ -82,11 +89,20 @@ vtkStandardNewMacro(MyProcess);
MyProcess::MyProcess()
{
this->ImageReductionFactor = 1;
this->Controller = NULL;
}
//-----------------------------------------------------------------------------
MyProcess::~MyProcess()
{
this->SetController(NULL);
}
//-----------------------------------------------------------------------------
void MyProcess::CreatePipeline(vtkRenderer* renderer)
{
double bounds[] = {-0.5, .5, -0.5, .5, -0.5, 0.5};
renderer->ResetCamera(bounds);
if (!this->IsServer)
{
return;
......@@ -165,9 +181,13 @@ void MyProcess::SetupRenderPasses(vtkRenderer* renderer)
}
//-----------------------------------------------------------------------------
void MyProcess::Execute()
bool MyProcess::Execute(int argc, char** argv)
{
vtkRenderWindow* renWin = vtkRenderWindow::New();
renWin->SetWindowName(this->IsServer?
"Server Window" : "Client Window");
// enable alpha bit-planes.
renWin->AlphaBitPlanesOn();
......@@ -177,6 +197,7 @@ void MyProcess::Execute()
// don't waste time swapping buffers unless needed.
renWin->SwapBuffersOff();
vtkRenderer* renderer = vtkRenderer::New();
renWin->AddRenderer(renderer);
......@@ -196,20 +217,28 @@ void MyProcess::Execute()
this->CreatePipeline(renderer);
this->SetupRenderPasses(renderer);
bool success = true;
if (!this->IsServer)
{
// CLIENT
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
renWin->SwapBuffersOn();
renWin->Render();
iren->Start();
// regression test is done on the client since the data is on the server.
int result = vtkTesting::Test(argc, argv, renWin, 15);
success = (result == vtkTesting::PASSED);
if (result == vtkTesting::DO_INTERACTOR)
{
iren->Start();
}
iren->Delete();
this->Controller->TriggerBreakRMIs();
}
else
{
// SERVER
this->Controller->ProcessRMIs();
}
......@@ -217,20 +246,19 @@ void MyProcess::Execute()
renWin->Delete();
syncWindows->Delete();
syncRenderers->Delete();
return success;
}
//-----------------------------------------------------------------------------
int main(int argc, char **argv)
{
int retVal = 1;
int image_reduction_factor = 1;
int is_server = 0;
int port = 11111;
vtksys::CommandLineArguments args;
args.Initialize(argc, argv);
args.StoreUnusedArguments(false);
args.StoreUnusedArguments(true);
args.AddArgument("--image-reduction-factor",
vtksys::CommandLineArguments::SPACE_ARGUMENT,
&image_reduction_factor, "Image reduction factor");
......@@ -253,8 +281,8 @@ int main(int argc, char **argv)
contr->Initialize(&argc, &argv);
if (is_server)
{
cout << "Waiting for client on 11111" << endl;
contr->WaitForConnection(11111);
cout << "Waiting for client on " << port << endl;
contr->WaitForConnection(port);
}
else
{
......@@ -268,12 +296,10 @@ int main(int argc, char **argv)
p->IsServer = is_server != 0;
p->SetImageReductionFactor(image_reduction_factor);
p->SetController(contr);
p->Execute();
retVal=p->GetReturnValue();
bool success = p->Execute(argc, argv);
p->Delete();
contr->Finalize();
contr = 0;
return !retVal;
return success? EXIT_SUCCESS :EXIT_FAILURE;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment