[Paraview] Question about writing custom reader for paraview

Moreland, Kenneth kmorel at sandia.gov
Thu Mar 19 13:57:30 EDT 2009


What you are using is not quite right.  First, it sounds like you really want to create a vtkImageData.  This data holds a 1D, 2D, or 3D grid of points with origin and uniform spacing on each axis.  Thus, you would inherit from vtkImageAlgorithm and cast your output to vtkImageData.

Second, the only thing you directly set in the output information is the WHOLE_EXTENT().  You do this in RequestInformation so that the downstream pipeline can make decisions about what to load before the data is actually loaded.  So, the first line you have below is correct, assuming you put it in RequestInformation.

Now, you don't set UPDATE_EXTENT, you get it.  Someone downstream will set this the region of data in which it wants you to load.  You don't actually have to get this directly from the output information; you can get it from the output object.  So in RequestData, you would have code like this:

 vtkImageData *output = vtkImageData::GetData(outInfo);
  int *extent = output->GetUpdateExtent();

Now you can set the actual extent, spacing, origin, and data itself directly into the data object.

 output->SetExtent(extent);
  output->SetOrigin(origin);
  output->SetSpacing(ar);

You can then set the data either by allocating and getting scalar data through the vtkImageData or by adding data to the image data's point data structure (retrieved with GetPointData()).  More details are in The VTK User's Guide.

-Ken


On 3/19/09 1:08 AM, "shenyanwen" <shenyanwen at gmail.com> wrote:





Hi, I am writing a custom reader for paraview to read my own data file which paraview hasn't have.
I have known that the most important method is RequestInformation and RequestData, and I just want to write a reader that can output the data type of StructuredPoints with Scalar and some vectors.I have already use :
outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(),
                 0,dim[1]-1,0,dim[1]-1,0,dim[2]-1);
    outInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(),
                 0,dim[1]-1,0,dim[1]-1,0,dim[2]-1);
and:outInfo->Set(vtkDataObject::SPACING(), ar, 3);
outInfo->Set(vtkDataObject::ORIGIN(), origin, 3);
and how can I read the scalar data just like the file-format describes:
SCALAR dataName dataType numComp
LOOKUP_TABLE tableName
s0
s1
s2
...
s(n-1)

which method or function can I use to read the s0,s1,...,s(n-1) into the variable and set to the outInfo.
Thanks so much!





   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.paraview.org/pipermail/paraview/attachments/20090319/7545b963/attachment.htm>


More information about the ParaView mailing list