[Paraview] Reading C-ordered data from hdf5

Berk Geveci berk.geveci at kitware.com
Fri Aug 15 12:41:43 EDT 2008

VTK uses Fortran ordering for structured datasets (vtkImageData,
vtkStructuredPoints, vtkStructuredGrid, vtkRectilinearGrid and
vtkUniformGrid). If (i, j, k) are the indices of a structured
datasets, arrays are stored such that i increases the fastest, then j,
then k. The tricky part is when you have arrays of multiple components
(for example vectors or tensors). You can treat a vector an array of
dimensions (3, Ni, Nj, Nk) where the component index increases the
fastest, then i, then j, then k. It would have been probably more
logical to use C ordering and store arrays as (Ni, Nj, Nk,
Ncomponents) but it is not done that way. I am guessing the original
developers of VTK like writing their loops like:

for (k=0; k<Nk; k++)
 for (j=0; j<Nj; j++)
  for (i=0; j<Ni; i++)
   for (comp=0; comp<Ncomponents; comp++)
     index = comp + i*Ncomponents + j*Ni*NComponents + k*Nj*Ni*NComponents


On Thu, Aug 14, 2008 at 11:24 PM, John R. Cary <cary at txcorp.com> wrote:
> I have arrays written out from C into HDF5 using the HDF5 C
> API, and so in the file the arrays are in C ordering.  I now
> need to read them into VTK.  AFAICT, VTK is Fortran ordering,
> even though it is written in C++.  So that means I need to
> reverse the ordering.  Of course, I can write a loop to do
> this, but is there some standard way that VTK folks do this?
> I don't want to reinvent the wheel.
> Sorry for what is likely an elementary question, but I could
> not find it on the FAQ or after googling quite a bit.
> Thanks so much......John Cary
> --
> Tech-X Corp., 5621 Arapahoe Ave, Suite A, Boulder CO 80303
> cary at txcorp.com, p 303-448-0727, f 303-448-7756, NEW CELL 303-881-8572
> _______________________________________________
> ParaView mailing list
> ParaView at paraview.org
> http://www.paraview.org/mailman/listinfo/paraview

More information about the ParaView mailing list