Commit 6ef50d62 authored by Ken Martin's avatar Ken Martin
Browse files

ENH: added a test for prioritized streaming

parent 261e9c66
......@@ -2,6 +2,7 @@ SET(KIT Rendering)
SET(RenderingTests
otherCoordinate.cxx
TestPriorityStreaming.cxx
)
SET(RenderingTestsWithArguments)
......@@ -31,7 +32,9 @@ REMOVE (TestsToRun ${KIT}CxxTests.cxx)
# Add all the executables
FOREACH (test ${RenderingTests})
GET_FILENAME_COMPONENT(TName ${test} NAME_WE)
ADD_TEST(${TName} ${CXX_TEST_PATH}/${KIT}CxxTests ${TName})
ADD_TEST(${TName} ${CXX_TEST_PATH}/${KIT}CxxTests ${TName}
-T ${VTK_BINARY_DIR}/Testing/Temporary
)
ENDFOREACH (test)
FOREACH (test ${RenderingTestsWithArguments})
......@@ -42,7 +45,9 @@ FOREACH (test ${RenderingTestsWithArguments})
-T ${VTK_BINARY_DIR}/Testing/Temporary
-V Baseline/${KIT}/${TName}.png)
ELSE (VTK_DATA_ROOT)
ADD_TEST(${TName} ${CXX_TEST_PATH}/${KIT}CxxTests ${TName})
ADD_TEST(${TName} ${CXX_TEST_PATH}/${KIT}CxxTests ${TName}
-T ${VTK_BINARY_DIR}/Testing/Temporary
)
ENDIF (VTK_DATA_ROOT)
ENDFOREACH(test)
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestPriorityStreaming.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.
=========================================================================*/
// .NAME Test of the prioity streaming support in VTK
#include "vtkContourFilter.h"
#include "vtkImageMandelbrotSource.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkSmartPointer.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkTesting.h"
#include "vtkXMLImageDataReader.h"
#include "vtkXMLImageDataWriter.h"
#include "vtkXMLPImageDataWriter.h"
//---------------------------------------------------------------------------
int TestPriorityStreaming(int argc, char *argv[])
{
// parse the arguments
vtkSmartPointer<vtkTesting> test =
vtkSmartPointer<vtkTesting>::New();
int cc;
for ( cc = 1; cc < argc; cc ++ )
{
test->AddArgument(argv[cc]);
}
// first create a data file containing many pieces
// first we want to create some data, a 256 cubed Mandelbrot src
vtkSmartPointer<vtkImageMandelbrotSource> Mandelbrot =
vtkSmartPointer<vtkImageMandelbrotSource>::New();
Mandelbrot->SetWholeExtent(0,127,0,127,0,127);
Mandelbrot->SetOriginCX(-1.75,-1.25,-1,0);
Mandelbrot->Update();
// write out the image data file into many pieces
vtkSmartPointer<vtkXMLImageDataWriter> iw =
vtkSmartPointer<vtkXMLImageDataWriter>::New();
iw->SetInputConnection(Mandelbrot->GetOutputPort());
vtkstd::string fname = test->GetTempDirectory();
fname += "/StreamTestFile.vti";
iw->SetFileName(fname.c_str());
iw->SetNumberOfPieces(64);
iw->Write();
// create a reader
vtkSmartPointer<vtkXMLImageDataReader> ir =
vtkSmartPointer<vtkXMLImageDataReader>::New();
ir->SetFileName(fname.c_str());
vtkSmartPointer<vtkContourFilter> contour =
vtkSmartPointer<vtkContourFilter>::New();
contour->SetInputConnection(ir->GetOutputPort());
contour->SetValue(0,50);
// lets get some priorities :-)
vtkInformationVector *outVec =
contour->GetExecutive()->GetOutputInformation();
vtkInformation *outInfo = outVec->GetInformationObject(0);
outInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES(),
iw->GetNumberOfPieces());
// build the UE request
vtkSmartPointer<vtkInformation> UpdateExtentRequest =
vtkSmartPointer<vtkInformation>::New();
UpdateExtentRequest->Set
(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT());
UpdateExtentRequest->Set(vtkExecutive::FORWARD_DIRECTION(),
vtkExecutive::RequestUpstream);
UpdateExtentRequest->Set(vtkExecutive::ALGORITHM_BEFORE_FORWARD(), 1);
UpdateExtentRequest->Set(vtkExecutive::FROM_OUTPUT_PORT(), 0);
// build the UEInfo request
vtkSmartPointer<vtkInformation> UEInfoRequest =
vtkSmartPointer<vtkInformation>::New();
UEInfoRequest->Set
(vtkStreamingDemandDrivenPipeline::REQUEST_UPDATE_EXTENT_INFORMATION());
UEInfoRequest->Set(vtkExecutive::FORWARD_DIRECTION(),
vtkExecutive::RequestUpstream);
UEInfoRequest->Set(vtkExecutive::ALGORITHM_AFTER_FORWARD(), 1);
UEInfoRequest->Set(vtkExecutive::FROM_OUTPUT_PORT(), 0);
// store the in and out info
vtkStreamingDemandDrivenPipeline *sdd =
vtkStreamingDemandDrivenPipeline::SafeDownCast(contour->GetExecutive());
sdd->UpdateInformation();
vtkInformationVector **inVec =
contour->GetExecutive()->GetInputInformation();
int piece;
double *priority = new double [iw->GetNumberOfPieces()];
for (piece = 0; piece < iw->GetNumberOfPieces(); piece++)
{
outInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER(),
piece);
contour->GetExecutive()->
ProcessRequest(UpdateExtentRequest,1,inVec,outVec);
// get the ue info
contour->GetExecutive()->
ProcessRequest(UEInfoRequest,1,inVec,outVec);
// get the priority
priority[piece] =
outVec->GetInformationObject(0)->
Get(vtkStreamingDemandDrivenPipeline::PRIORITY());
}
if (iw->GetNumberOfPieces() != 64 ||
priority[36] != 0.0 ||
priority[37] != 1.0)
{
cerr << "Bad results for prioity streaming test\n";
return 1;
}
return 0;
}
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