15#ifndef TestMotionFXCFGReaderCommon_h
16#define TestMotionFXCFGReaderCommon_h
29#include <vtkTestUtilities.h>
30#include <vtkTesting.h>
49 cout <<
"Go to next" << endl;
51 std::min(
static_cast<int>(this->TimeSteps.size()) - 1, this->CurrentIndex + 1);
57 cout <<
"Go to prev" << endl;
58 this->CurrentIndex =
std::max(0, this->CurrentIndex - 1);
65 for (
size_t cc = 0; cc < this->TimeSteps.size(); ++cc)
69 this->CurrentIndex =
static_cast<int>(cc);
78 this->CurrentIndex >= 0 && this->CurrentIndex <
static_cast<int>(this->TimeSteps.size()));
89 switch (iren->GetKeyCode())
108template <
typename InitializationCallback>
109int Test(
int argc,
char* argv[],
const char* dfile,
const InitializationCallback& initCallback)
112 char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, dfile);
113 reader->SetFileName(fname);
116 reader->SetTimeResolution(100);
117 reader->UpdateInformation();
121 const int numTimeSteps = outInfo->
Length(SDDP::TIME_STEPS());
123 if (numTimeSteps != 100)
125 cerr <<
"ERROR: missing timesteps. Potential issue reading the CFG file." << endl;
132 renWin->AddRenderer(renderer);
135 iren->SetRenderWindow(renWin);
138 mapper->SetInputConnection(reader->GetOutputPort());
144 initCallback(renWin, renderer, reader);
146 std::vector<double> ts(numTimeSteps);
147 outInfo->
Get(SDDP::TIME_STEPS(), &ts[0]);
151 reader->UpdateTimeStep(ts[numTimeSteps / 2]);
152 mapper->SetInputDataObject(reader->GetOutputDataObject(0));
156 if (retVal == vtkTesting::DO_INTERACTOR)
159 data.Window = renWin;
160 data.Reader = reader;
161 data.Mapper = mapper;
163 data.CurrentIndex = numTimeSteps / 2;
170 cout <<
"Entering interactive mode......" << endl
171 <<
"Supported operations:" << endl
172 <<
" 'z' or 'Z' : go to next time step" << endl
173 <<
" 'x' or 'X' : go to previous time step" << endl
174 <<
" 'c' or 'C' : play animation from start to end" << endl
175 <<
" 'q' or 'Q' : quit" << endl;
179 else if (retVal == vtkTesting::NOT_RUN)
181 return VTK_SKIP_RETURN_CODE;
183 else if (retVal == vtkTesting::PASSED)
virtual void SetMapper(vtkMapper *)
This is the method that is used to connect an actor to the end of a visualization pipeline,...
vtkDataObject * GetOutputDataObject(int port)
Get the data object that will contain the algorithm output for the given port.
virtual void SetInputDataObject(int port, vtkDataObject *data)
Sets the data-object as an input on the given port index.
virtual int UpdateTimeStep(double time, int piece=-1, int numPieces=1, int ghostLevels=0, const int extents[6]=nullptr)
Convenience method to update an algorithm after passing requests to its first output port.
virtual void SetCallback(void(*f)(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata))
virtual void SetClientData(void *cd)
Methods to set and get client and callback information, and the callback function.
Allocate and hold a VTK object.
abstract base class for most VTK objects
static vtkRenderWindowInteractor * SafeDownCast(vtkObjectBase *o)
void Render() override
Ask each renderer owned by this RenderWindow to render its image and synchronize this process.
void AddActor(vtkProp *p)
Add/Remove different types of props to the renderer.
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< vtkCompositePolyDataMapper2 > Mapper