[vtkusers] vtkExtractVOI and vtkReslice

Randy Heiland heiland at ncsa.uiuc.edu
Thu Apr 12 11:02:04 EDT 2001


On Apr 12,  2:52pm, Zeger Knops wrote:
> Subject: [vtkusers] vtkExtractVOI and vtkReslice
> Hi,
>
> I'm using VTK 3.2 with the Java interface. If I use the following code
> something strange happens, I extract a volume and I would like to reslice
> this volume. But VTK crashes when I use the following code. When I display
> only the VOI the program works fine, but when I display the relsliced volume
> VTK crashes. Reslice outputs a volume with the correct size but the data
> inside the volume is corrupt. Any suggestions?
>
> 		vtkExtractVOI extractResliceVOI = new vtkExtractVOI();
> 		extractResliceVOI.SetInput( structuredPoints );
> 		extractResliceVOI.SetVOI( 10, 30,
> 						10, 30,
> 						10, 30 );
>
> 		vtkTransform transform = new vtkTransform();
> 		transform.Identity();
>
> 		vtkImageReslice reslice = new vtkImageReslice();
> 		reslice.SetInput( extractResliceVOI.getOutput() );
> 		reslice.SetResliceTransform( transform );
>


First, I'm assuming your ".getOutput()" is a typo ("g" -> "G")

I've included a full Java pgm, using the carotid dataset, that "works" for me
(i.e., doesn't crash).  But as for what ImageReslice *should* produce, I'm not
sure as I'm not familiar with it.  I get a small "box" located at one corner of
the domain.

fwiw, I too am using a nightly version of VTK 3.2 from early Dec. '00, running
on an SGI, using java version "JavaVM-1.3".

--Randy


import vtk.*;
import java.awt.*;
import java.awt.event.*;
//import java.lang.System.*;

public class sp extends Frame implements ActionListener {

  public sp()
  {
    // Set the title for the Frame
    super("sp");

    // add a menu
    MenuBar menuBar = new MenuBar();
    setMenuBar(menuBar);
    Menu fileMenu = new Menu("File");
    menuBar.add(fileMenu);
    MenuItem item = new MenuItem("Exit");
    fileMenu.add(item);
    item.addActionListener(this);

    // add the vtkPanel object
    // vtkPanel does a:  static { System.loadLibrary("vtkJava"); }

    addNotify();
    vtkPanel renPanel = new vtkPanel();
    renPanel.setSize(400,400);
    removeAll();
    add(renPanel);

    vtkStructuredPointsReader spReader = new vtkStructuredPointsReader();
      spReader.SetFileName("/usr/people/heiland/vtkdata/carotid.vtk");
      spReader.Update();
    vtkStructuredPoints sp = spReader.GetOutput();
      int ndims = sp.GetDataDimension();
      System.out.println("data dim = " + ndims);
      int dims[] = sp.GetDimensions();
      System.out.println("dims = " + dims[0] +","+dims[1]+","+dims[2]);
//data dim = 3
//dims = 76,49,45


      vtkExtractVOI extractResliceVOI = new vtkExtractVOI();
		extractResliceVOI.SetInput( sp );
		extractResliceVOI.SetVOI( 10, 30,
						10, 30,
						10, 30 );

		vtkTransform transform = new vtkTransform();
		transform.Identity();

		vtkImageReslice reslice = new vtkImageReslice();
		reslice.SetInput( extractResliceVOI.GetOutput() );
//		reslice.SetResliceTransform( transform );


    vtkDataSetMapper isoMapper = new vtkDataSetMapper();
      isoMapper.SetInput(reslice.GetOutput());

    vtkActor actor = new vtkActor();
      actor.SetMapper(isoMapper);
//      actor.GetProperty().SetColor(1,0,0);

    vtkOutlineFilter outline = new vtkOutlineFilter();
      outline.SetInput(sp);
    vtkPolyDataMapper outlineMapper = new vtkPolyDataMapper();
      outlineMapper.SetInput(outline.GetOutput());
    vtkActor outlineActor = new vtkActor();
      outlineActor.SetMapper(outlineMapper);
      outlineActor.GetProperty().SetColor(0.5,0.5,0.5);

      // Add actors to renderer
      vtkRenderer ren = renPanel.getRenderer();
      ren.AddActor(outlineActor);
      ren.AddActor(actor);
      ren.SetBackground(0.1, 0.2, 0.4);

      enableEvents(AWTEvent.WINDOW_EVENT_MASK);
      pack();
  }

  public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("Exit")) {
        dispose();
        System.exit(0);
    }
  }

  protected void processWindowEvent(WindowEvent e) {
      if (e.getID() == WindowEvent.WINDOW_CLOSING) {
          dispose();
          System.exit(0);
      }
      super.processWindowEvent(e);
  }

  public static void main (String[] args) {
      sp obj = new sp();
      obj.setVisible(true);
  }
}




More information about the vtkusers mailing list