@@ -0,0 +1,2445 @@
+import vtk.vtkNativeLibrary;%0Aimport vtk.vtkRenderWindow;%0Aimport vtk.vtkRenderWindowInteractor;%0Aimport vtk.vtkRenderer;%0Aimport vtk.vtkImageCanvasSource2D;%0Aimport vtk.vtkPNMWriter;%0Aimport vtk.vtkPNMReader;%0Aimport vtk.vtkImageActor;%0Aimport vtk.vtkInteractorStyleImage;%0A%0A%0Apublic class WritePNM%0A%7B%0A  // -----------------------------------------------------------------%0A  // Load VTK library and print which library was not properly loaded%0A  static %0A  %7B%0A    if (!vtkNativeLibrary.LoadAllNativeLibraries()) %0A    %7B%0A      for (vtkNativeLibrary lib : vtkNativeLibrary.values()) %0A      %7B%0A        if (!lib.IsLoaded()) %0A        %7B%0A          System.out.println(lib.GetLibraryName() + %22 not loaded%22);%0A        %7D%0A      %7D%0A    %7D%0A    vtkNativeLibrary.DisableOutputWindow(null);%0A  %7D%0A  // -----------------------------------------------------------------%0A%0A  public static void main(String args%5B%5D) %0A  %7B%0A%0A    //parse command line arguments%0A    if (args.length != 1) %0A    %7B%0A      System.err.println(%22Usage: java -classpath ... Filename(.pnm) e.g OutputFile.pnm%22);%0A      return;%0A    %7D%0A    String Filename = args%5B0%5D;%0A     %0A    vtkImageCanvasSource2D imageSource = new vtkImageCanvasSource2D();%0A    imageSource.SetScalarTypeToUnsignedChar();%0A    imageSource.SetExtent(0,9,0,9,0,0);%0A    imageSource.SetNumberOfScalarComponents(3);%0A    imageSource.SetDrawColor(0, 0, 0, 0);%0A    imageSource.FillBox(0,9,0,9);%0A    imageSource.SetDrawColor(255, 0, 0, 0);%0A    imageSource.FillBox(5,7,5,7);%0A    imageSource.Update();%0A    %0A    vtkPNMWriter pnmWriter = new vtkPNMWriter();%0A    pnmWriter.SetFileName(Filename);%0A    pnmWriter.SetInputConnection(imageSource.GetOutputPort());%0A    pnmWriter.Write();%0A    %0A    // Read and display for verification%0A    vtkPNMReader reader = new vtkPNMReader();%0A    reader.SetFileName(Filename);%0A    reader.Update();%0A    %0A    vtkImageActor actor = new vtkImageActor();%0A    actor.GetMapper().SetInputConnection(reader.GetOutputPort());%0A%0A    // Create the renderer, render window and interactor.%0A    vtkRenderer ren = new vtkRenderer();%0A    vtkRenderWindow renWin = new vtkRenderWindow();%0A    renWin.AddRenderer(ren);%0A    vtkRenderWindowInteractor iren = new vtkRenderWindowInteractor();%0A    iren.SetRenderWindow(renWin);%0A    %0A    vtkInteractorStyleImage style = new vtkInteractorStyleImage();%0A    iren.SetInteractorStyle(style);%0A%0A    ren.AddActor(actor);%0A%0A    renWin.SetSize(300,300);%0A    renWin.Render();%0A    %0A    iren.Initialize();%0A    iren.Start();%0A%0A  %7D%0A%7D%0A

Create WritePNM.java