3#ifndef TestMotionFXCFGReaderCommon_h
4#define TestMotionFXCFGReaderCommon_h
17#include <vtkTestUtilities.h>
18#include <vtkTesting.h>
37 cout <<
"Go to next" << endl;
39 std::min(
static_cast<int>(this->TimeSteps.size()) - 1, this->CurrentIndex + 1);
45 cout <<
"Go to prev" << endl;
46 this->CurrentIndex = std::max(0, this->CurrentIndex - 1);
53 for (
size_t cc = 0; cc < this->TimeSteps.size(); ++cc)
57 this->CurrentIndex =
static_cast<int>(cc);
66 this->CurrentIndex >= 0 && this->CurrentIndex <
static_cast<int>(this->TimeSteps.size()));
67 this->Reader->UpdateTimeStep(this->TimeSteps[this->CurrentIndex]);
68 this->Mapper->SetInputDataObject(this->Reader->GetOutputDataObject(0));
69 this->Window->Render();
77 switch (iren->GetKeyCode())
96template <
typename InitializationCallback>
97int Test(
int argc,
char* argv[],
const char* dfile,
const InitializationCallback& initCallback)
100 char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, dfile);
101 reader->SetFileName(fname);
104 reader->SetTimeResolution(100);
105 reader->UpdateInformation();
109 const int numTimeSteps = outInfo->
Length(SDDP::TIME_STEPS());
111 if (numTimeSteps != 100)
113 cerr <<
"ERROR: missing timesteps. Potential issue reading the CFG file." << endl;
120 renWin->AddRenderer(renderer);
123 iren->SetRenderWindow(renWin);
126 mapper->SetInputConnection(reader->GetOutputPort());
129 actor->SetMapper(mapper);
130 renderer->AddActor(actor);
132 initCallback(renWin, renderer, reader);
134 std::vector<double> ts(numTimeSteps);
135 outInfo->
Get(SDDP::TIME_STEPS(), ts.data());
139 reader->UpdateTimeStep(ts[numTimeSteps / 2]);
140 mapper->SetInputDataObject(reader->GetOutputDataObject(0));
143 const int retVal = vtkTesting::Test(argc, argv, renWin, 10);
144 if (retVal == vtkTesting::DO_INTERACTOR)
147 data.Window = renWin;
148 data.Reader = reader;
149 data.Mapper = mapper;
151 data.CurrentIndex = numTimeSteps / 2;
154 observer->SetClientData(&data);
158 cout <<
"Entering interactive mode......" << endl
159 <<
"Supported operations:" << endl
160 <<
" 'z' or 'Z' : go to next time step" << endl
161 <<
" 'x' or 'X' : go to previous time step" << endl
162 <<
" 'c' or 'C' : play animation from start to end" << endl
163 <<
" 'q' or 'Q' : quit" << endl;
167 else if (retVal == vtkTesting::NOT_RUN)
169 return VTK_SKIP_RETURN_CODE;
171 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