[vtkusers] Create unstructured grid with CellData for vtkXMLPUnstructuredGridWriter

Murphy, John T. jtmurphy at anl.gov
Fri Oct 21 18:22:25 EDT 2011


Hello,

I am hoping to find a simple example that shows me how to transform a collection of raw data into an unstructured grid + cell data, and from there to a set of vtk files that can be read in parallel in Paraview.

The data are originally in a single HDF5 file; my code to convert them runs in parallel on N nodes, and I use the vtkXMLPUnstructuredGridWriter to give me file output. The result should be N data files and one master file with metadata. I don't have any trouble with the parallel aspect of this on either the input or output side. On the input side, I can read the source file and then transform the raw data (on any single process) into any C/C++ array as needed.

The problem is the interim steps: moving from my raw data to the vtk data structure, and then passing all of this to the vtkXMLPUnstructuredGridWriter. I'm not very familiar with vtk, and am at a loss to navigate through the API.

My raw data is, first, X,Y,Z coordinates for points. Sets of points form series that will be used to form polylines. Each output file will have many polylines.

Second, I have attributes that I want to associate with each polyline. Each polyline will have an int value for several attributes (Attribute1, Attribute2, Attribute3). In Paraview I can use these attributes to filter or map colors, etc- all polylines with Attribute1 = 0 will be red, while all those with Attribute1 = 1 will be blue, for example.

So the simplest example of my raw data would be two very dull line segments with two attributes each:

Line A, Point 0 = 0.0, 0.0, 0.0
Line A, Point 1 = 0.0, 0.0., 10.0

Line B, Point 0 = 5.0, 5.0, 0.0
Line B, Point 1 = 5.0, 5.0, 10.0

Line A, Attribute1 = 0
Line A, Attribute2 = 25

Line B, Attribute1 = 1
Line B, Attribute2 = 14

I need to know how to create the vtkUnstructuredGrid that represents the collection of polylines, and the attribute data that Paraview can use to filter it, and then how to use the vtkXMLPUnstructuredGridWriter to write this to the xml output files.

Any help appreciated- thanks,
John


--
John T. Murphy
Computational Postdoctoral Fellow
Decision and Information Sciences and
Argonne Leadership Computing Facility
Argonne National Laboratory
jtmurphy at anl.gov



More information about the vtkusers mailing list