[Paraview] Custom plugin reader with time series

Dominik Szczerba domi at vision.ee.ethz.ch
Sat May 10 12:03:02 EDT 2008


Hi Mike,
Thanks a lot for the detailed hints. I am on my way to try it out.
-- Dominik

Mike Jackson wrote:
> Take a look at <http://titanium.imts.us/viewvc/Task_4/PVDislocation/src/DislocationReaders/vtkPrdsMultiOutDislocationReader.cxx?view=markup>
>  to see how I did a time series reader.
> 
> Basically in RequestInformation  you will need to determine the the
> range of times that your data covers, probably by opening each file or
> some other means. Then set
>     double timeRange[2];
>     timeRange[0] = lowestTimeValue
>     timeRange[1] = highesetTimeValue
>     outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(),
> timeRange, 2);
> 
> Also, you will need to have the following in your header:
> 
>    vtkSetMacro(TimeStep, int);
>    vtkGetMacro(TimeStep, int);
> 
>  int GetNumberOfTimeSteps();
> 
> Now, down in the RequestData() Method you can get the requested time
> step from the
> pipeline and then open and read the data from the proper data file.
> 
> int tsLength = outInfo->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
>   double* steps = outInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
>   // Check if a particular time was requested.
>   if(outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS()))
>   {
>     // Get the requested time step. We only supprt requests of a single time
>     // step in this reader right now
>     double *requestedTimeSteps =
> outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEPS());
>     this->TimeValue = requestedTimeSteps[0];
> 
>     // find the first time value larger than requested time value
>     // this logic could be improved
>     int cnt = 0;
>     while (cnt < tsLength-1 && steps[cnt] < this->TimeValue)
>       {
>       cnt++;
>       }
>     this->ActualTimeStep = cnt;
>   }
> 
>   if (this->TimeStep > -1)
>   {
>     this->ActualTimeStep = this->TimeStep;
>   }
> 
>   if (this->ActualTimeStep >= this->TimeStepRange[0] &&
> this->ActualTimeStep <= this->TimeStepRange[1]) {
>     vtkSmartPointer<DislocationReader> reader =
> vtkSmartPointer<DislocationReader>::New();
>     reader->SetFileName(this->FileName);
>     reader->SetTimeStep(this->ActualTimeStep);
>     //reader->SetInformationVector(outputVector);
>     reader->SetFileOffsets(this->FileOffsets);
>     reader->read();
>     vtkUnstructuredGrid* grid;
>     grid = reader->GetDislocations();
>     dislocations->ShallowCopy(grid);
> 
>    // dislocations->SetBlock(0, grid);    // Block 0 is the Dislocation Data
>     grid = reader->GetSimulationBox();
>     simBox->ShallowCopy(grid);
>     //dislocations->SetBlock(1, grid); // Block 1 is the Simulation Limits
>   } else {
>       std::cout << "vtkPrdsMultiOutDislocationReader: Timestep was out
> of Range: " << this->ActualTimeStep << std::endl;
>       std::cout << "vtkPrdsMultiOutDislocationReader: Timestep Range:"
> << this->TimeStepRange[0] << " -> " << this->TimeStepRange[1] <<
> std::endl;
>       return 0;
>   }
> 
> 
> This code is specific to my case where I have a whole separate reader
> for my data where I feed it the name of the file to read and then tell
> it to read the file and get the output. This may also be the case for
> you also.
> 
> Hope some of the helps.
> 
> Mike
> 
> On Sat, May 10, 2008 at 6:03 AM, Dominik Szczerba
> <domi at vision.ee.ethz.ch> wrote:
>> Hi,
>> I have successfully implemented a reader for my data as a PV plugin. It
>> loads separate files correctly, refuses, however, to read the whole series
>> (file_01.h5, file_02.h5, etc.). How do I go about achieving the same effect
>> as the native readers to have a series as transient data?
>> Thanks for any hints.
>> --
>> Dominik Szczerba, Ph.D.
>> Computer Vision Lab CH-8092 Zurich
>> http://www.vision.ee.ethz.ch/~domi
>> _______________________________________________

-- 
Dominik Szczerba, Ph.D.
Computer Vision Lab CH-8092 Zurich
http://www.vision.ee.ethz.ch/~domi


More information about the ParaView mailing list