VtkRenderWindowInteractor doesn't start and cause program freezes [java]

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

VtkRenderWindowInteractor doesn't start and cause program freezes [java]

qweee
This post was updated on .
I recently have implemented clipping in my VTK Java program. I used BoxWidget to control what should be clipped. However, i'm having an issue with vtkWindowInteractor that attached to BoxWidget. The program freezes at the renderWindowInteractor.Start() statement ( I've remarked it in my code).

This is my re-simulate code :

or pastebin

import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import vtk.*;

public class VTKWindowInteractor extends JPanel {

    static {
        if (!vtkNativeLibrary.LoadAllNativeLibraries()) {
            for (vtkNativeLibrary lib : vtkNativeLibrary.values()) {
                if (!lib.IsLoaded()) {
                    System.out.println(lib.GetLibraryName() + " not loaded");
                }
            }
            System.out.println("Make sure the search path is correct: ");
            System.out.println(System.getProperty("java.library.path"));
        }
        vtkNativeLibrary.DisableOutputWindow(null);
    }

    private vtkPanel renWin;
    private vtkRenderWindowInteractor renderWindowInteractor;
    private vtkPolyDataMapper mapper;
    private vtkActor coneActor;
    private vtkPlanes planes;
    private vtkBoxWidget boxWidget;

    public VTKWindowInteractor() {
        setLayout(new BorderLayout());
        renWin = new vtkPanel();
        add(renWin, BorderLayout.CENTER);
        renWin.setMinimumSize(new Dimension(50, 50));
        renWin.GetRenderer().SetBackground(0, 0, 0); // black
        renWin.GetRenderWindow().AddRenderer(renWin.GetRenderer());
    }

    public void render() {

        mapper = new vtkPolyDataMapper();
        vtkConeSource cone = new vtkConeSource();
        cone.SetHeight(3.0);
        cone.SetRadius(1.0);
        cone.SetResolution(10);

        mapper.SetInputConnection(cone.GetOutputPort());
        coneActor = new vtkActor();
        coneActor.SetMapper(mapper);

        renWin.GetRenderer().AddActor(coneActor);
       
        planes = new vtkPlanes();
        renderWindowInteractor = new vtkRenderWindowInteractor();
        renderWindowInteractor.SetRenderWindow(renWin.GetRenderWindow());
        boxWidget = new vtkBoxWidget();
        boxWidget.SetInteractor(renderWindowInteractor);
        boxWidget.SetPlaceFactor(1.25);
        boxWidget.PlaceWidget(coneActor.GetBounds());
        boxWidget.AddObserver("InteractionEvent", this, "executeClipping");
        renderWindowInteractor.Initialize();
        boxWidget.On();
        renWin.Render();
        renWin.resetCamera();
        /*********************************/
        // This is where cause the program freezes  //          
        /*********************************/
        renderWindowInteractor.Start(); // if i comment out this line, the program works. However the boxWidget is unable to resized/move/scaled
    }

    public void executeClipping() {
        planes = new vtkPlanes();
        boxWidget.GetPlanes(planes);
        mapper.SetClippingPlanes(planes);
        planes.Delete();
    }

    public static final int WINDOW_WIDTH = 1000;
    public static final int WINDOW_HEIGHT = 500;

    public static void main(String[] args) {
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                VTKWindowInteractor _vtkRendererPanel = new VTKWindowInteractor();

                JFrame frame = new JFrame();
                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                frame.setTitle("......");
                frame.setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
                frame.setVisible(true);
                frame.setLayout(new BorderLayout());
                frame.add(_vtkRendererPanel);
                _vtkRendererPanel.render();
            }
        });
    }
}


I have been finding my mistake for hours and hours and frustrated hence come here to seek for help. If anyone have experienced this or know what did I do wrong please correct me. Thanks !

VTK version : 6.2.0
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

qweee
Use vtkCanvas instead of vtkPanel. I doubt that not one have experienced similar case. Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

Sebastien Jourdain-2
Yes the vtkCanvas has the interactor initialized hence you should use the one that has been build by the vtkCanvas.
vtkPanel drive the camera using Java mouse handling hence your issue.

Sorry just saw your message just now.

Seb

On Wed, Aug 5, 2015 at 6:37 PM, James Potota <[hidden email]> wrote:
Use vtkCanvas instead of vtkPanel. I doubt that not one have experienced
similar case. Thanks.



--
View this message in context: http://vtk.1045678.n5.nabble.com/VtkRenderWindowInteractor-doesn-t-start-and-cause-program-freezes-java-tp5733242p5733293.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers


_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

qweee
No problem Sebastien. Thank you so much.
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

louiskoo
This post has NOT been accepted by the mailing list yet.
In reply to this post by qweee
Is your vtk version is 32 bit or 64bit?
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

qweee
Hi Louis. It was 64bit
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

louiskoo
I hava compiled the vtk with 64 bit jdk on win7 64 but failed and I have destressed for days. Can you send me the 64 bit dll and vtk.jar?
I will appreciate that if you can help me.
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

qweee
check your email.

On Fri, Aug 7, 2015 at 9:58 AM louiskoo <[hidden email]> wrote:
I hava compiled the vtk with 64 bit jdk on win7 64 but failed and I have
destressed for days. Can you send me the 64 bit dll and vtk.jar?
I will appreciate that if you can help me.



--
View this message in context: http://vtk.1045678.n5.nabble.com/VtkRenderWindowInteractor-doesn-t-start-and-cause-program-freezes-java-tp5733242p5733338.html
Sent from the VTK - Users mailing list archive at Nabble.com.
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers

_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ

Search the list archives at: http://markmail.org/search/?q=vtkusers

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/vtkusers
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

louiskoo
Sorry,I haven't received your email and hava you sended success?
Reply | Threaded
Open this post in threaded view
|

Re: VtkRenderWindowInteractor doesn't start and cause program freezes [java]

louiskoo
Sorry,I haven't received your email of vtk dlls and jar and can you send the files to louiskooliuxin@hotmail.com.
Thanks a lot.