[Paraview] Writing binary files: C/Fortran interface to VTK XML files.

Brad King brad.king at kitware.com
Tue Jun 7 10:06:51 EDT 2005


SamuelKey wrote:
> Needing to have a C-compiler is not a problem for me; I have one.
> 
> Let me try to work with what you commit next week and see if I have
> any ideas. I will be gone all next week, so you won't hear from me
> until week after next. With luck you may hear from someone else
> that will help keep you busy, though I suspect "busy" is not a
> problem for you.

Okay, the C/Fortran interface is now available.  A C program can do

#include "vtkXMLWriterC.h"

and link to vtkIO.  A Fortran program can use the interface (see the 
example code below) but will need to compile one extra .c file to link 
properly to vtkIO.  See VTK/IO/vtkXMLWriterF.h for instructions.

-Brad

       PROGRAM Hello
       INTEGER writer
       INTEGER success
       INTEGER*8 numpoints/8/
       INTEGER*8 numcells/1/
       INTEGER*8 cellsSize/9/
       REAL*4 pdata(8)/0,0,0,0,1,1,1,1/
       REAL*4 points(24)/0,0,0, 1,0,0, 1,1,0, 0,1,0,
      _                  0,0,1, 1,0,1, 1,1,1, 0,1,1/
       INTEGER*8 cells(9)/8,0,1,2,3,4,5,6,7/
       call vtkXMLWriterF_New(writer)
       call vtkXMLWriterF_SetDataObjectType(writer, 4)
       call vtkXMLWriterF_SetFileName(writer, 'test1.vtu')
       call vtkXMLWriterF_SetPoints(writer, 10, points, numpoints)
       call vtkXMLWriterF_SetCellsWithType(writer, 12, numcells, cells,
      _                                    cellsSize)
       call vtkXMLWriterF_SetPointData(writer, 'example data', 10, pdata,
      _                                numpoints, 1, 'SCALARS')
       call vtkXMLWriterF_Write(writer, success)
       call vtkXMLWriterF_Delete(writer)
       PRINT *, 'success =', success
       END PROGRAM Hello


More information about the ParaView mailing list