Skip to content

XMLPImageDataWriter

Repository source: XMLPImageDataWriter

Description

vtkXMLPImageDataWriter object writes the PVTK XML ImageData file format.

One image data 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 "pvti". This writer uses vtkXMLImageDataWriter to write the individual piece files.

Other languages

See (Cxx)

Question

If you have a question about this example, please use the VTK Discourse Forum

Code

XMLPImageDataWriter.java

import vtk.vtkNativeLibrary;
import vtk.vtkImageCanvasSource2D;
import vtk.vtkXMLPImageDataWriter;


public class XMLPImageDataWriter
{
  // -----------------------------------------------------------------
  // 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(.pvti) e.g Test.pvti");
      return;
    }
    String Filename = args[0];
    vtkImageCanvasSource2D drawing = new vtkImageCanvasSource2D();
    drawing.SetNumberOfScalarComponents(3);
    drawing.SetScalarTypeToUnsignedChar();
    drawing.SetExtent(0, 20, 0, 50, 0, 1);
    drawing.SetDrawColor(255.0, 255.0, 255.0);
    drawing.DrawCircle(5, 5, 3);

    int numberOfPieces = 4;

    vtkXMLPImageDataWriter writer = new vtkXMLPImageDataWriter();
    writer.SetInputConnection(drawing.GetOutputPort());
    writer.SetFileName(Filename);
    writer.SetNumberOfPieces(numberOfPieces);
    writer.SetEndPiece(numberOfPieces-1);
    writer.SetStartPiece(0);
    writer.Update();

  }
}