[vtkusers] vtkImplicitPlaneWidget + Java.

Said. Said.El_Kasmi at sophia.inria.fr
Fri Nov 7 05:08:53 EST 2003


Hi all,

In this java class I'm testing how to use vtkImplicitPlaneWidget class.
I attached to this mail the output view of the following code.

I need some help to add suport for user intercation: I mean, when the
user replace the plane in the vtkImplicitPlaneWidget, the application
should the new cut plane and show it. I'm browsing vtk examples but I
didn't find any java one.

Thanks.

/*
 * Created on Nov 6, 2003
 */
package caiman.vizu.vtk;
import javax.swing.JFrame;

import vtk.vtkActor;
import vtk.vtkCanvas;
import vtk.vtkCutter;
import vtk.vtkDataSet;
import vtk.vtkDataSetMapper;
import vtk.vtkDataSetReader;
import vtk.vtkImplicitPlaneWidget;
import vtk.vtkPlane;
import vtk.vtkPolyData;
import vtk.vtkPolyDataMapper;


public class TestPlaneWidget extends JFrame{
  
  static { 
      System.loadLibrary("vtkCommonJava"); 
      System.loadLibrary("vtkFilteringJava"); 
      System.loadLibrary("vtkIOJava"); 
      System.loadLibrary("vtkImagingJava"); 
      System.loadLibrary("vtkGraphicsJava"); 
      System.loadLibrary("vtkRenderingJava"); 
      System.loadLibrary("vtkHybridJava"); 
    }


  
  private vtkDataSet data;
  private vtkDataSetReader dsr;
  private vtkCanvas renWin;
  private vtkImplicitPlaneWidget pw;
  private vtkPlane plane;
  private vtkCutter cutter;
  private vtkActor actor;
  private vtkPolyDataMapper mapper;
  
  public TestPlaneWidget() {
   dsr = new vtkDataSetReader();
   dsr.SetFileName("Cube.vtk");
    data = dsr.GetOutput();
    
    vtkDataSetMapper dmapper = new vtkDataSetMapper();
    dmapper.SetInput(data);
    vtkActor dactor = new vtkActor();
    dactor.SetMapper(dmapper);
    
    
    plane = new vtkPlane();
    renWin = new vtkCanvas();
    
    pw = new vtkImplicitPlaneWidget();
    pw.SetOrigin(data.GetCenter());
    pw.SetInteractor(renWin.getIren());
    pw.SetInput(data);
    pw.NormalToZAxisOn();
    pw.On();
    pw.GetPlane(plane);
    vtkPolyData pdata = new vtkPolyData();
    pw.GetPolyData(pdata);
    
   
    
    cutter = new vtkCutter();
    cutter.SetInput(data);
    cutter.SetCutFunction(plane);
    
    mapper = new vtkPolyDataMapper();
    mapper.SetInput(cutter.GetOutput());
    actor = new vtkActor();
    actor.SetMapper(mapper);
    
    renWin.GetRenderer().AddActor(actor);
    //renWin.GetRenderer().AddActor(dactor);
    

    this.getContentPane().add(renWin);
    this.setVisible(true);
	}
  
	public static void main(String[] args) {
    new TestPlaneWidget();
  }
  
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: img.gif
Type: image/gif
Size: 16619 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20031107/96d740aa/attachment.gif>


More information about the vtkusers mailing list