Even though programming animatins myself, I am still lost regarding the understanding of “time” in ParaView! But anyway, as long as things are running like I want, I can live with this ignorance… However, they are not!
I have a self-written filter that generates a table as output, one table per timestep. The number of timesteps can be chosen in the properties - let’s assume we make it 6, so the result will be 7 tables, corresponding to 0-1-2-3-4-5-6. For some reason, ParaView wants this to be in a range from 0 to 1, which makes it 0 - 0.16667 - 0.33333 etc. Not a problem, as long as I am getting my 7 tables!
Now I want to write them into a series of 7 CSV files - which looks like a good job for the CSV extractor - right?
And it works indeed - except for the fact that the extractor insists on generating 10 CSV files, no matter what I enter in “Start Time Step”, “End Time Step” and “Frequency”. These would correspond to time steps 0 - 0.11111 - 0.22222 - 0.33333 etc., and my required 7 tables are indeed among the 10 output tables, plus 3 that are duplicates.
My question is now: How can I convince the extractor to extract exactly the 7 tables that I want to generate? Or any other number - whatever is generated by the “table generating filter”?
As I said above: I have no clue what these time figures really do. I entered e.g. StartTimeStep=0, EndTimeStep=1 and Frequency=6 → generates 10 tables. Or I made it StartTimeStep=0, EndTimeStep=6, Frequency=1 → generates 7 tables, but they do not cover the full range… I am indeed a bit lost now!
What I found to be working for a “source” that generates a sequence of output was to do the following within the RequestInformation function:
for(int n = 0; n < GetNumberOfOutputPorts(); ++n)
{
vtkInformation* info = outputVector->GetInformationObject(n);
info->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), tRange, 2);
info->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), Steps.data(), Steps.size());
info->Set(CAN_HANDLE_PIECE_REQUEST(), 1);
}
tRange and Steps are both double vectors: tRange is always 0. and 1., and Steps would be something like 0., 0.1666, 0.3333, 0.5 etc. if I actually want it to be 0-1-2- etc. With this I am getting the desired result, but in the animation controls I see these values that I entered in the Steps array.
However, I found now that I could also write a CSV reader that does not even have a RequestInformation function and also in RequestData it does not fiddle around with anything like UPDATE_TIME_STEP() - and there exactly the thing is happening that I would like to achieve: if I have 7 input files, they will be shown as 0-1-2- etc.!
So it looks like I have to “spy” now a little bit how that latter “source” (reader) does the trick indeed.
From what I understand, ParaView actually wants to handle the two possible concepts of “time”: one being a series of objects corresponding to floating point values along a time axis (maybe even if they are not evenly spaced, like 0.0 - 0.1 - 0.25 - 0.3 etc.??) and maybe even interpolate between them if required. The other would be a sequence of objects that are simply numbered: 0 - 1 - 2 etc.
The latter is what best describes my use case, even if the “time objects” are corresponding to time indeed: mining period 1, mining period 2, etc. Even of they are a time sequence, it would not make sense to e.g. interpolate something like “mining period 1.5”.
In other words: neither TIME_RANGE() nor TIME_STEP() are specified, but rather a FILE_SERIES_NUMBER_OF_FILES key that basically tells us the number of “steps” that we want to achieve.
Within RequestData, this is what we receive - for the first step (from the output vector information object):
Hmm - well: This I was doing, and this turns out to give me not the result that I always wanted to achieve! Which would be: Having timesteps counted like 0 - 1 - 2 etc…
Strange indeed! But…
…now I realized that I was in RequestData actually shooting into my own foot!
Some years ago I had written some code where I thought that this counting in integer numbers did not work, so I made it always fractions within a range from 0 to 1. Right now I simply copied that code, assuming that this is a must within ParaView: “time ranges have to be 0 to 1”.
Now, in order to check whether it would still work otherwise, I changed my code: In RequestInformation I made TIME_RANGE 0 4 and TIME_STEPS 0 1 2 3 4. Then in RequestData, I obtained an UPDATE_TIME_STEP that was indeed correctly giving me the required sequence: 0 1 2 3 4.
But then I had overlooked a line of code that I had put in “just to play safe”:
reqTime = std::min(std::max(reqTime, 0.), 1.);
And THIS was then actually the very obvious reason why I could never get beyond 1!
(PS: From you I learned once what “rubber ducking” means - here was another example though… Anyway many thanks for playing the “rubber duck” for me again!)