3#ifndef TestMotionFXCFGReaderCommon_h
4#define TestMotionFXCFGReaderCommon_h
17#include <vtkTestUtilities.h>
18#include <vtkTesting.h>
38 std::cout <<
"Go to next" << std::endl;
40 std::min(
static_cast<int>(this->TimeSteps.size()) - 1, this->CurrentIndex + 1);
46 std::cout <<
"Go to prev" << std::endl;
47 this->CurrentIndex = std::max(0, this->CurrentIndex - 1);
53 std::cout <<
"Playing";
54 for (
size_t cc = 0; cc < this->TimeSteps.size(); ++cc)
58 this->CurrentIndex =
static_cast<int>(cc);
61 std::cout << std::endl;
67 this->CurrentIndex >= 0 && this->CurrentIndex <
static_cast<int>(this->TimeSteps.size()));
68 this->Reader->UpdateTimeStep(this->TimeSteps[this->CurrentIndex]);
69 this->Mapper->SetInputDataObject(this->Reader->GetOutputDataObject(0));
70 this->Window->Render();
78 switch (iren->GetKeyCode())
97template <
typename InitializationCallback>
98int Test(
int argc,
char* argv[],
const char* dfile,
const InitializationCallback& initCallback)
101 char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, dfile);
102 reader->SetFileName(fname);
105 reader->SetTimeResolution(100);
106 reader->UpdateInformation();
110 const int numTimeSteps = outInfo->
Length(SDDP::TIME_STEPS());
112 if (numTimeSteps != 100)
114 std::cerr <<
"ERROR: missing timesteps. Potential issue reading the CFG file." << std::endl;
121 renWin->AddRenderer(renderer);
124 iren->SetRenderWindow(renWin);
127 mapper->SetInputConnection(reader->GetOutputPort());
130 actor->SetMapper(mapper);
131 renderer->AddActor(actor);
133 initCallback(renWin, renderer, reader);
135 std::vector<double> ts(numTimeSteps);
136 outInfo->
Get(SDDP::TIME_STEPS(), ts.data());
140 reader->UpdateTimeStep(ts[numTimeSteps / 2]);
141 mapper->SetInputDataObject(reader->GetOutputDataObject(0));
144 const int retVal = vtkTesting::Test(argc, argv, renWin, 10);
145 if (retVal == vtkTesting::DO_INTERACTOR)
148 data.Window = renWin;
149 data.Reader = reader;
150 data.Mapper = mapper;
152 data.CurrentIndex = numTimeSteps / 2;
155 observer->SetClientData(&data);
159 std::cout <<
"Entering interactive mode......" << std::endl
160 <<
"Supported operations:" << std::endl
161 <<
" 'z' or 'Z' : go to next time step" << std::endl
162 <<
" 'x' or 'X' : go to previous time step" << std::endl
163 <<
" 'c' or 'C' : play animation from start to end" << std::endl
164 <<
" 'q' or 'Q' : quit" << std::endl;
168 else if (retVal == vtkTesting::NOT_RUN)
170 return VTK_SKIP_RETURN_CODE;
172 else if (retVal == vtkTesting::PASSED)
Allocate and hold a VTK object.
abstract base class for most VTK objects
static vtkRenderWindowInteractor * SafeDownCast(vtkObjectBase *o)
Hold a reference to a vtkObjectBase instance.
Executive supporting partial updates.
static void CharEventCallback(vtkObject *caller, unsigned long, void *clientdata, void *)
int Test(int argc, char *argv[], const char *dfile, const InitializationCallback &initCallback)
std::vector< double > TimeSteps
vtkSmartPointer< vtkMotionFXCFGReader > Reader
vtkSmartPointer< vtkRenderWindow > Window
vtkSmartPointer< vtkCompositePolyDataMapper > Mapper