VTK Polydata dataset with points only?

I have a legacy POLYDATA dataset with only points and associated SCALARS (no CELLS) from some hydrologic simulation code. The only important piece of information is the location of the points themselves. I have two questions:

  1. Is having a CELLS field necessary?
  2. If so, how should I define such cells? Can I just define a single cell over the whole volume with the points?

This seems like a basic question but I haven’t ben able to answer this question with previous searches. Thanks for your help!

-James

In next release, you will be able to instantiate vtkPointSet, which will not be abstract anymore, and which will be the designated data structure for point sets. As for now, if you want to display points in a vtkPolyData, you should fill up the vtkCellArray you can get from vtkPolyData::GetVerts(). Your cells would be vtkVertex.

Hi Yohann,

Thanks for the help!

I think I wasn’t clear enough in my first question. The VTK polydata file is being written manually in a FORTRAN code, and the only parts that are written are the POINTS and the SCALARS.

So it looks like:


DATASET POLYDATA
POINTS n dataType
p0x p0y p0z
p1x p1y p1z

p(n-1)x p(n-1)y p(n-1)z

SCALARS dataName dataType numComp
LOOKUP_TABLE tableName
s0
s1

sn-1


It doesn’t have any polygons or cells. I’m trying to figure out: 1) whether this is a valid legacy VTK file format that readers should recognize (I can get the data out of it in Python, but that’s the only one I’ve gotten working so far, with particularly VisIt and ParaView having problems); and 2) what I need to do to adapt the file format if it is not. I have had one person tell me that the VTKs need a structure for the data to lay in, and hence a set of CELLS, so I’m trying to track down more of that.

Since the data doesn’t have any vertices or cells, I don’t get anything when I call vtkPolyData::GetVerts().

Thanks a bunch for your help!

Be Well,
James

Hi James,

I’m not very familiar with legacy formats, but I think you should be able to find everything you want here.

From what I can tell, if you replace SCALARS by POINT_DATA and add a VERTICES section mapping points to vertices, you should be good.

Hi Yohann,

Thanks a bunch.

If I understand what you’re saying, I need to add a vertices section that repeats the points section (with a unique number for each vertex?) because I need to let it know that the points are not parts of cells, but rather are just stand-alone locations in space.

I think that the SCALARS should remain as they are, because in fact it reads:


POINT_DATA
SCALARS dataName dataType
LOOKUP_TABLE default
s0
s1

sn-1
SCALARS dataName dataType
LOOKUP_TABLE default
ss0
ss1

ssn-1


Sorry–I was not careful enough before to make sure I got the whole relevant portion.

Let me know if this makes sense, and thanks a bunch for your help!

Be Well,
James

Yes, you got it all right.