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()));
77 switch (iren->GetKeyCode())
96 template <
typename InitializationCallback>
97 int 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());
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));
144 if (retVal == vtkTesting::DO_INTERACTOR)
147 data.Window = renWin;
148 data.Reader = reader;
149 data.Mapper = mapper;
151 data.CurrentIndex = numTimeSteps / 2;
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)
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< vtkCompositePolyDataMapper > Mapper