[Paraview] Custom plugin reader with time series

Berk Geveci berk.geveci at kitware.com
Sun May 11 09:54:02 EDT 2008


http://www.vtk.org/Wiki/Animating_legacy_VTK_file_series

Warning: The implementation may change somewhat in the future.

-berk

On Sun, May 11, 2008 at 4:31 AM, Dominik Szczerba
<domi at vision.ee.ethz.ch> wrote:
> OK so this is basically about reading the series myself explicitly. But one
> thing is not clear to me: I am deriving my readers from vtkDataReader, after
> UnstructuredGridReader and StructuredPointsReader, who can read time series
> somehow, so this functionality must be already in somewhere (upstream).
> There is no explicit time series handling in those classes and yet they
> work, so why mine do not? I can see that you do derive your reader from
> vtkUnstructuredGridAlgorithm, and not vtkDataReader, why? I wonder if I
> really have to re-implement it and if there is no simpler way to achieve the
> goal, like taking advantage of some existing functionality.
> Thanks, 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
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview
>


More information about the ParaView mailing list