AW: [vtkusers] VTKNightly, Java, MDI, ImagePlaneWidget

Stefan Maas stefan.maas at fh-gelsenkirchen.de
Wed Oct 29 07:11:57 EST 2003


Hi Jeff,

I use the VTKNightly-Release (look title :-) ).

Here is a part of the code. It uses the vtkDICOMImageReader and reads
data with ".dcm". It just shows three planes but the same error occurs.
It has nothing to do with the type of data (DICOM), because it got the
same error with other formats. Thanks for trying to help me.

Stefan

--------------------------
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
import javax.swing.plaf.basic.*;
import java.io.File;
import vtk.*;
    
public class VisualMediJ extends JFrame 
{ 
    private Desktop theDesktop;
    private Dimension screenSize;
  
    static String str ="";
    static File file = new File(str);
    
    public VisualMediJ() 
    {
        super("VisualMediJ");
        screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        this.setSize(screenSize.width, screenSize.height);
      
        WindowListener l = new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                System.exit(0);
            }
        };
    this.addWindowListener(l);    
    this.getContentPane().add(theDesktop = new Desktop());
    new MenuMgr();
    this.show();
    }

    public void addMenuBar(JMenuBar m)
    {
        setJMenuBar(m);
    }
   
    private class Desktop extends JDesktopPane 
    {
        public Desktop( )
        {
            super();
            this.setPreferredSize(screenSize);
            this.setDragMode(JDesktopPane.OUTLINE_DRAG_MODE);
        }
    }

    public class VTK3DFrame extends JInternalFrame
    {
        public VTK3DFrame(int x, int y)
        {
            super("3D-Frame", true, true, true, true);
            Dimension mySize = new Dimension();
            mySize.height = 300;
            mySize.width = 300;
            this.setSize(mySize);
            this.getContentPane().setLayout(new BorderLayout());
            this.setLocation(x, y);
            this.getContentPane().add(new VTK_Panel(3),
BorderLayout.CENTER); 
            this.pack();
            this.setVisible(true);     
        }
    }
    
    public class VTK2DFrame extends JInternalFrame
    {
        public VTK2DFrame(int x, int y)
        {
            super("2D-Frame", true, true, true, true);
            Dimension mySize = new Dimension();
            mySize.height = 300;
            mySize.width = 300;
            this.setSize(mySize);
            this.getContentPane().setLayout(new BorderLayout());
            this.setLocation(x, y);
            this.getContentPane().add(new VTK_Panel(2),
BorderLayout.CENTER); 
            this.pack();
            this.setVisible(true);     
        }
    }
    
    private class MenuMgr extends JMenuBar
    {
        JMenu menu;

        public MenuMgr()
        {
            super();
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);

            menu = new JMenu("File");  
            menu.add(new LoadWindowAction("Load File"));
            menu.add(new CreatePlaneAction("Create Plane"));
            menu.add(new KillAction("Exit"));
            add(menu);
            addMenuBar(this);
        }
    }
  
    private class LoadWindowAction extends AbstractAction
    {
        JFileChooser chooser = new JFileChooser();
    
        private int layer = 0;
        public LoadWindowAction  (String label)
        {
            super(label);
        }
    
        public void actionPerformed(ActionEvent ev)
        {
            int state = chooser.showOpenDialog(null);
            file = chooser.getSelectedFile();
        
            if(file != null && state ==JFileChooser.APPROVE_OPTION)
            {
                theDesktop.add(new VTK3DFrame(340, 200), new
Integer(layer));              
            }
            else if(state == JFileChooser.CANCEL_OPTION)
            {
                JOptionPane.showMessageDialog(null, "Canceled");
            }   
        }
    }
    
    private class CreatePlaneAction extends AbstractAction
    {
        private int layer = 0;
        
        public CreatePlaneAction  (String label)
        {
            super(label);
        }
    
        public void actionPerformed(ActionEvent ev)
        {
            theDesktop.add(new VTK2DFrame(340, 200), new
Integer(layer));
        }
    }  
    
    private class KillAction extends AbstractAction
    {
        public KillAction(String label)
        {
            super(label);
        }
    
        public void actionPerformed(ActionEvent ev)
        {
            System.exit(0);
        }
    }
    
    public static String GetDir()
    {
        return file.getParent();
    }  
    
    public static String GetPath()
    {
        return file.getPath();
    }

    public static void main(String[] args)
    {
        JFrame f = new VisualMediJ();    
    }
    
    public class VTK_Panel extends JPanel
    {     
        vtkPanel renPanel = null;
        vtkCanvas renWin = null;
       
        private int width = 512;
        private int height = 512;

        public VTK_Panel(int dimension)
        {
            if (dimension == 3)
            {
                setLayout(new BorderLayout());
                renWin = new vtkCanvas();
               
                add(renWin, BorderLayout.CENTER);
                              
                if(GetPath().endsWith("dcm"))
                {
                    vtkDICOMImageReader DICOMReader = new
vtkDICOMImageReader();
                    DICOMReader.SetDataByteOrderToLittleEndian();
                    DICOMReader.SetDirectoryName(GetDir());
                    DICOMReader.Update();
                    
                    setImageData(DICOMReader.GetOutput());
                }
            }
        }
        
        public void setImageData(vtkImageData imagedata) 
        {
            //vtkDICOMImageReader DICOMReader = new
vtkDICOMImageReader();
            //DICOMReader.SetDataByteOrderToLittleEndian();
            //DICOMReader.SetDirectoryName(GetDir());
            //DICOMReader.Update();

            vtkCellPicker picker = new vtkCellPicker();
            picker.SetTolerance(0.005);

            vtkImagePlaneWidget planeWidgetX = new
vtkImagePlaneWidget();
            planeWidgetX.DisplayTextOn();
            planeWidgetX.SetInput(imagedata);
            planeWidgetX.SetInteractor(renWin.getIren());
            planeWidgetX.SetPlaneOrientationToXAxes();
            planeWidgetX.SetSliceIndex(32);
            planeWidgetX.SetPicker(picker);
            planeWidgetX.SetKeyPressActivationValue('x');
            planeWidgetX.GetPlaneProperty().SetColor(1, 0, 0);
            planeWidgetX.On();

            vtkImagePlaneWidget planeWidgetY = new
vtkImagePlaneWidget();
            planeWidgetY.DisplayTextOn();
            planeWidgetY.SetInput(imagedata);
            planeWidgetY.SetInteractor(renWin.getIren());
            planeWidgetY.SetPlaneOrientationToYAxes();
            planeWidgetY.SetSliceIndex(32);
            planeWidgetY.SetPicker(picker);
            planeWidgetY.SetKeyPressActivationValue('y');
            planeWidgetY.GetPlaneProperty().SetColor(1, 1, 0);
            planeWidgetY.On();

            vtkImagePlaneWidget planeWidgetZ = new
vtkImagePlaneWidget();
            planeWidgetZ.DisplayTextOn();
            planeWidgetZ.SetInput(imagedata);
            planeWidgetZ.SetInteractor(renWin.getIren());
            planeWidgetZ.SetPlaneOrientationToZAxes();
            planeWidgetZ.SetSliceIndex(46);
            planeWidgetZ.SetPicker(picker);
            planeWidgetZ.SetKeyPressActivationValue('z');
            planeWidgetZ.GetPlaneProperty().SetColor (0, 0, 1);
            planeWidgetZ.On();

            vtkOutlineFilter outline = new vtkOutlineFilter();
            outline.SetInput (imagedata);

            vtkPolyDataMapper outlineMapper = new vtkPolyDataMapper();
            outlineMapper.SetInput (outline.GetOutput()  );

            vtkActor outlineActor = new vtkActor();
            outlineActor.SetMapper(outlineMapper);

            renWin.GetRenderer().AddActor(outlineActor);
            renWin.GetRenderer().SetBackground(0.1, 0.1, 0.2);
        }
    }
}
--------------------------------------------------------------


-----Ursprüngliche Nachricht-----
Von: Jeff Lee [mailto:jeff at cdnorthamerica.com] 
Gesendet: Mittwoch, 29. Oktober 2003 13:04
An: Stefan Maas
Cc: vtkusers at vtk.org
Betreff: Re: [vtkusers] VTKNightly, Java, MDI, ImagePlaneWidget

hi,
What version of vtk? I rewrote that example recently because of problems

like that. can you send some code?
-Jeff

Stefan Maas wrote:

> Hello,
>
> I try to use a modified “ImagePlaneWidget.java” inside a 
> JInternalFrame. When I open a dataset (e.g. the well known “headsq” ) 
> there is no Problem. It is shown inside the JInternalFrame and also 
> three ImagePlaneWidgets are painted. I can move and resize the 
> JInternalFrame – no problem. But when I try to rotate the Actor (or 
> use other mouse-events) the program crashes. Not immediately but after

> a few seconds (1-30 sec.). “ImagePlaneWidget.java” works well and 
> without planes the MDI-program works well also. But a combination of 
> both produces errors like the following one:
>
> An unexpected exception has been detected in native code outside the
VM.
>
> Unexpected Signal : EXCEPTION_ACCESS_VIOLATION (0xc0000005) occurred 
> at PC=0x0
>
> Function=[Unknown.]
>
> Library=(N/A)
>
> NOTE: We are unable to locate the function name symbol for the error
>
> just occurred. Please refer to release documentation for possible
>
> reason and solutions.
>
> Current Java thread:
>
> at vtk.vtkGenericRenderWindowInteractor.LeftButtonPressEvent_5(Native 
> Method)
>
> at 
>
vtk.vtkGenericRenderWindowInteractor.LeftButtonPressEvent(vtkGenericRend
erWindowInteractor.java:32)
>
> at vtk.vtkCanvas.mousePressed(vtkCanvas.java:124)
>
> at java.awt.Component.processMouseEvent(Component.java:5097)
>
> at java.awt.Component.processEvent(Component.java:4897)
>
> at java.awt.Component.dispatchEventImpl(Component.java:3615)
>
> at java.awt.Component.dispatchEvent(Component.java:3477)
>
> at java.awt.EventQueue.dispatchEvent(EventQueue.java:456)
>
> at 
>
java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThrea
d.java:201)
>
> at 
>
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.
java:151)
>
> at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
>
> at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
>
> at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
>
> Dynamic libraries:
>
> 0x00400000 - 0x00406000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\java.exe
>
> 0x77F40000 - 0x77FEE000 C:\WINDOWS\System32\ntdll.dll
>
> 0x77E40000 - 0x77F38000 C:\WINDOWS\system32\kernel32.dll
>
> 0x77DA0000 - 0x77E3C000 C:\WINDOWS\system32\ADVAPI32.dll
>
> 0x78000000 - 0x78086000 C:\WINDOWS\system32\RPCRT4.dll
>
> 0x77BE0000 - 0x77C33000 C:\WINDOWS\system32\MSVCRT.dll
>
> 0x08000000 - 0x08136000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\client\jvm.dll
>
> 0x77D10000 - 0x77D9C000 C:\WINDOWS\system32\USER32.dll
>
> 0x77C40000 - 0x77C80000 C:\WINDOWS\system32\GDI32.dll
>
> 0x76AF0000 - 0x76B1D000 C:\WINDOWS\System32\WINMM.dll
>
> 0x10000000 - 0x10007000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\hpi.dll
>
> 0x00390000 - 0x0039E000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\verify.dll
>
> 0x003A0000 - 0x003B8000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\java.dll
>
> 0x003C0000 - 0x003CD000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\zip.dll
>
> 0x02E60000 - 0x02F6A000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\awt.dll
>
> 0x72F70000 - 0x72F93000 C:\WINDOWS\System32\WINSPOOL.DRV
>
> 0x76330000 - 0x7634C000 C:\WINDOWS\System32\IMM32.dll
>
> 0x7CCC0000 - 0x7CDE1000 C:\WINDOWS\system32\ole32.dll
>
> 0x02F70000 - 0x02FC0000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\fontmanager.dll
>
> 0x51000000 - 0x51047000 C:\WINDOWS\System32\ddraw.dll
>
> 0x73B30000 - 0x73B36000 C:\WINDOWS\System32\DCIMAN32.dll
>
> 0x5C000000 - 0x5C0C8000 C:\WINDOWS\System32\D3DIM700.DLL
>
> 0x773A0000 - 0x77B9C000 C:\WINDOWS\system32\shell32.dll
>
> 0x63180000 - 0x631E5000 C:\WINDOWS\system32\SHLWAPI.dll
>
> 0x78090000 - 0x78174000 
>
C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df
_6.0.10.0_x-ww_f7fb5805\comctl32.dll
>
> 0x77310000 - 0x7739B000 C:\WINDOWS\system32\comctl32.dll
>
> 0x71BA0000 - 0x71BEE000 C:\WINDOWS\System32\netapi32.dll
>
> 0x71A80000 - 0x71A91000 C:\WINDOWS\system32\MPR.dll
>
> 0x75F00000 - 0x75F06000 C:\WINDOWS\System32\drprov.dll
>
> 0x71B90000 - 0x71B9D000 C:\WINDOWS\System32\ntlanman.dll
>
> 0x71C50000 - 0x71C66000 C:\WINDOWS\System32\NETUI0.dll
>
> 0x71C10000 - 0x71C4C000 C:\WINDOWS\System32\NETUI1.dll
>
> 0x71C00000 - 0x71C06000 C:\WINDOWS\System32\NETRAP.dll
>
> 0x71B70000 - 0x71B81000 C:\WINDOWS\System32\SAMLIB.dll
>
> 0x75F10000 - 0x75F19000 C:\WINDOWS\System32\davclnt.dll
>
> 0x76620000 - 0x76708000 C:\WINDOWS\System32\SETUPAPI.dll
>
> 0x75EE0000 - 0x75EFF000 C:\WINDOWS\system32\appHelp.dll
>
> 0x770F0000 - 0x7717B000 C:\WINDOWS\system32\OLEAUT32.dll
>
> 0x07740000 - 0x077B7000
C:\Programme\vtk43\bin\release\vtkCommonJava.dll
>
> 0x077C0000 - 0x079A0000 C:\PROGRA~1\vtk43\bin\release\vtkCommon.dll
>
> 0x7C080000 - 0x7C0F7000 C:\WINDOWS\System32\MSVCP70.dll
>
> 0x7C000000 - 0x7C054000 C:\WINDOWS\System32\MSVCR70.dll
>
> 0x07290000 - 0x072B4000 
> C:\Programme\vtk43\bin\release\vtkFilteringJava.dll
>
> 0x079A0000 - 0x07A0A000 C:\PROGRA~1\vtk43\bin\release\vtkFiltering.dll
>
> 0x07A60000 - 0x07AA3000 C:\Programme\vtk43\bin\release\vtkIOJava.dll
>
> 0x07AB0000 - 0x07CB7000 C:\PROGRA~1\vtk43\bin\release\vtkIO.dll
>
> 0x07A10000 - 0x07A33000 C:\PROGRA~1\vtk43\bin\release\vtkpng.dll
>
> 0x07CC0000 - 0x07CD3000 C:\PROGRA~1\vtk43\bin\release\vtkzlib.dll
>
> 0x07CE0000 - 0x07D06000 C:\PROGRA~1\vtk43\bin\release\vtkjpeg.dll
>
> 0x07D10000 - 0x07D5E000 C:\PROGRA~1\vtk43\bin\release\vtktiff.dll
>
> 0x07D60000 - 0x07D82000 C:\PROGRA~1\vtk43\bin\release\vtkexpat.dll
>
> 0x07D90000 - 0x07DDD000
C:\Programme\vtk43\bin\release\vtkImagingJava.dll
>
> 0x08140000 - 0x083BF000 C:\PROGRA~1\vtk43\bin\release\vtkImaging.dll
>
> 0x07DE0000 - 0x07E76000
C:\Programme\vtk43\bin\release\vtkGraphicsJava.dll
>
> 0x083C0000 - 0x0860D000 C:\PROGRA~1\vtk43\bin\release\vtkGraphics.dll
>
> 0x07E80000 - 0x07EFB000 
> C:\Programme\vtk43\bin\release\vtkRenderingJava.dll
>
> 0x08610000 - 0x08843000 C:\PROGRA~1\vtk43\bin\release\vtkRendering.dll
>
> 0x07F00000 - 0x07F12000 C:\PROGRA~1\vtk43\bin\release\vtkftgl.dll
>
> 0x5F0D0000 - 0x5F196000 C:\WINDOWS\System32\OPENGL32.dll
>
> 0x68FC0000 - 0x68FDE000 C:\WINDOWS\System32\GLU32.dll
>
> 0x07F20000 - 0x07F6B000 C:\PROGRA~1\vtk43\bin\release\vtkfreetype.dll
>
> 0x07A40000 - 0x07A45000 C:\Program 
> Files\j2sdk_nb\j2sdk1.4.2\jre\bin\jawt.dll
>
> 0x07F70000 - 0x07FB9000
C:\Programme\vtk43\bin\release\vtkHybridJava.dll
>
> 0x08850000 - 0x089C2000 C:\PROGRA~1\vtk43\bin\release\vtkHybrid.dll
>
> 0x69500000 - 0x6981E000 C:\WINDOWS\System32\nvoglnt.dll
>
> 0x76C50000 - 0x76C72000 C:\WINDOWS\system32\imagehlp.dll
>
> 0x6DA00000 - 0x6DA7D000 C:\WINDOWS\system32\DBGHELP.dll
>
> 0x77BD0000 - 0x77BD7000 C:\WINDOWS\system32\VERSION.dll
>
> 0x76BB0000 - 0x76BBB000 C:\WINDOWS\System32\PSAPI.DLL
>
> Heap at VM Abort:
>
> Heap
>
> def new generation total 576K, used 534K [0x10010000, 0x100b0000, 
> 0x104f0000)
>
> eden space 512K, 94% used [0x10010000, 0x100888d0, 0x10090000)
>
> from space 64K, 81% used [0x100a0000, 0x100ad0e8, 0x100b0000)
>
> to space 64K, 0% used [0x10090000, 0x10090000, 0x100a0000)
>
> tenured generation total 1408K, used 703K [0x104f0000, 0x10650000, 
> 0x14010000)
>
> the space 1408K, 49% used [0x104f0000, 0x1059fec8, 0x105a0000,
0x10650000)
>
> compacting perm gen total 6400K, used 6377K [0x14010000, 0x14650000, 
> 0x18010000)
>
> the space 6400K, 99% used [0x14010000, 0x1464a700, 0x1464a800,
0x14650000)
>
> Local Time = Wed Oct 29 09:29:19 2003
>
> Elapsed Time = 53
>
> #
>
> # The exception above was detected in native code outside the VM
>
> #
>
> # Java VM: Java HotSpot(TM) Client VM (1.4.2-b28 mixed mode)
>
> #
>
> ----------------------
>
> I think the 99% in the last line of “Heap” is the problem (every time 
> this error occurs it is 96-99%) or rather the symptom of the error. I 
> have the dim feeling that the error has something to do with 
> “planeWidget.SetInteractor(renWin.getIren())”. This could be the point

> of problem but this is just what my intuition says.
>
> Can anyone please help me? I am at my wits end.
>
> Greetings,
>
> Stefan
>

-- 
Jeff Lee
Senior Software Engineer
Computational Dynamics North America Ltd
21 Lafayette Street, Suite 230
Lebanon NH 03766 USA
fax:   603 643 9994
phone: 603 643 9993 x109
http://www.cd-adapco.com








More information about the vtkusers mailing list