XMLPUnstructuredGridWriter

VTKExamples/Java/IO/XMLPUnstructuredGridWriter

Description

vtkXMLPUnstructuredGridWriter object writes the PVTK XML UnstructuredGrid file format.

One unstructured grid input can be written into a parallel file format with any number of pieces spread across files.

The standard extension for this writer's file format is "pvtu". This writer uses vtkXMLUnstructuredGridWriter to write the individual piece files.

Other Languages

See (Cxx)

Question

If you have a simple question about this example contact us at VTKExamplesProject If your question is more complex and may require extended discussion, please use the VTK Discourse Forum

Code

XMLPUnstructuredGridWriter.java

import vtk.vtkNativeLibrary;
import vtk.vtkSphereSource;
import vtk.vtkDelaunay3D;
import vtk.vtkXMLPUnstructuredGridWriter;

public class XMLPUnstructuredGridWriter
{
  // -----------------------------------------------------------------
  // Load VTK library and print which library was not properly loaded
  static 
  {
    if (!vtkNativeLibrary.LoadAllNativeLibraries()) 
    {
      for (vtkNativeLibrary lib : vtkNativeLibrary.values()) 
      {
        if (!lib.IsLoaded()) 
        {
          System.out.println(lib.GetLibraryName() + " not loaded");
        }
      }
    }
    vtkNativeLibrary.DisableOutputWindow(null);
  }
  // -----------------------------------------------------------------

  public static void main(String args[]) 
  {

    //parse command line arguments
    if (args.length != 1) 
    {
      System.err.println("Usage: java -classpath ... Filename(.pvtu) e.g Test.pvtu");
      return;
    }
    String Filename = args[0];

    vtkSphereSource sphereSource = new vtkSphereSource();
    sphereSource.Update();

    vtkDelaunay3D delaunay = new vtkDelaunay3D();
    delaunay.SetInputConnection(sphereSource.GetOutputPort());
    delaunay.Update();

    vtkXMLPUnstructuredGridWriter writer = new vtkXMLPUnstructuredGridWriter();
    writer.SetInputConnection(delaunay.GetOutputPort());
    writer.SetFileName(Filename);
    writer.SetNumberOfPieces(4);
    writer.SetStartPiece(0);
    writer.SetEndPiece(3);
    writer.Update();

  }
}