[vtkusers] Writing vtkUnstructuredGrid to ExodusII file

Andrew E Slaughter andrew.e.slaughter at gmail.com
Wed Apr 11 14:39:53 EDT 2012


I would like to write vtkUnstructuredGrid object to both a *.vtu and
*.ex2 (ExodusII) file. The *.vtu part is working, but not the ExodusII
part. I am using CGAL to generate the mesh, converting it to an
vtkUnstructredGrid and then writing the file. The following code is
what I have so far:

// VTK includes
#include <vtkUnstructuredGridWriter.h>
#include <vtkXMLDataSetWriter.h>
#include <vtkExodusIIWriter.h>

// Generate the mesh
...

// Convert CGAL object to a vtkUnstructuredGrid
(http://cgal-discuss.949826.n4.nabble.com/mesh-to-vtk-output-td3586974.html)
        vtkUnstructuredGrid *output;
        output = CGAL::output_c3t3_to_vtk_unstructured_grid(c3t3);
        output->Squeeze();

// Output the *.vtu file (this works)
         vtkXMLDataSetWriter *vtu = vtkXMLDataSetWriter::New();
         vtu->SetInput(output);
         vtu->SetFileName("output.vtu");
         vtu->Write();

// Output the *.ex2 file (this fails with the error mentioned below)			
         vtkExodusIIWriter *exII = vtkExodusIIWriter::New();
         exII->SetInput(output);
         exII->SetFileName("output.ex2");
         exII->Write();

The code above fails to compile with: undefined reference to
`vtkExodusIIWriter::New()'

If I change the definition of the pointer to:
     vtkExodusIIWriter *exII;
without the New deceleration the program compiles, but when it is
executed it produces a Segmentation fault.

Any help is appreciated.

Thanks,
Andrew



More information about the vtkusers mailing list