[vtkusers] IsRenderSupported method crash
Sebastien Jourdain
sebastien.jourdain at kitware.com
Sun Jul 17 12:39:31 EDT 2011
Hi Max,
I've seen some issue on windows when trying to cleanup the memory from
the vtkPanel. But I don't see the link between the first part of your
mail about "IsRenderSupported" and the "RemoveAllProps"...
Could you explain more that part about why you created a
"finalize/shutdown" code ?
Thanks,
Seb
On Fri, Jul 15, 2011 at 4:40 PM, EvilMax <maxim.privalov at gmail.com> wrote:
> Hello!
>
>
> I have a problem working with VTK rendering panel and ray cast mapping in
> Java application. It runs once, but crashes on second attempt when getting
> render capablities. Code is following:
>
>
> // Get rendering panel
> RistorRenderWindowPanel rp = getRenderingPanel().getRenderWindowPanel(0);
> vtkVolumeProperty volumeProperty = new vtkVolumeProperty();
> // Setup opacity/colo transfer functions
> TransferFunctionPreset preset = model.getPreset().clone();
> volumeProperty.SetScalarOpacity(preset
> .getScalarOpacityFunction().convertToVTK(model.getOffset()));
> volumeProperty.SetColor(model.getPreset().getColorTransferFunction()
> .convertToVTK(model.getOffset()));
> volumeProperty.ShadeOn();
> volumeProperty.SetInterpolationTypeToLinear();
>
> // Add ray cast mapper to use OpenGL hardware accelerated ray casting
> vtkVolumeMapper rayCastMapper;
> vtkGPUVolumeRayCastMapper gpuMapper = new
> vtkOpenGLGPUVolumeRayCastMapper();
>
>
> rayCastMapper = gpuMapper;
> rayCastMapper.SetBlendModeToComposite();
> rayCastMapper.SetInput(model.getVolume());
>
> // Create volume and add to it property and mapper
> vtkVolume volume = getVolume();
> volume.SetMapper(rayCastMapper);
> volume.SetProperty(volumeProperty);
>
> // Bind to render panel
> rp.GetRenderer().AddViewProp(volume);
>
> // Pre-render and test capabilities
> rp.Render();
> if(gpuMapper.IsRenderSupported(rp.GetRenderWindow(), volumeProperty)==0)
> {
> rayCastMapper = new vtkVolumeRayCastMapper();
> ((vtkVolumeRayCastMapper)
> rayCastMapper).SetVolumeRayCastFunction(compositeFunction);
> rayCastMapper.SetBlendModeToComposite();
> rayCastMapper.SetInput(model.getVolume());
> }
>
>
> After that resetCamera() and Render() methods are called to perform clean
> render. Render window panel is embedded to Java Swing panel and pipeline
> creation and render are called upon showing it. But on second showing JVM
> crashed on *if(gpuMapper.IsRenderSupported(rp.GetRenderWindow(),
> volumeProperty)==0)* code. JVM complains on msvcr100.dll and stack trace to
> raycast mapper. In VTK log file I see following:
>
> *ERROR: In vtkWin32OpenGLRenderWindow.cxx, line 247
> vtkWin32OpenGLRenderWindow (0503DA78): wglMakeCurrent failed in
> MakeCurrent(), error: The handle is invalid.*
>
> I've searched this lilsts and found some proposals. So I've created
> 'finalizing' code:
>
>
> void shutdown()
> {
> RistorRenderWindowPanel rp = getRenderingPanel().getRenderWindowPanel(0);
> if (rp !=null)
> {
> if (rp.GetRenderer() != null)
> {
> rp.GetRenderer().RemoveAllViewProps();
> rp.GetRenderWindow().GetInteractor().SetRenderWindow(null);
> if (rp.GetRenderWindow().GetInteractor() != null)
> {
> LOG.info("Delete interactor");
> rp.GetRenderWindow().GetInteractor().Delete();
> }
> rp.GetRenderer().GetRenderWindow().Finalize();
> rp.GetRenderer().GetRenderWindow().Delete();
> rp.GetRenderer().Delete();
> }
> }
> System.gc();
> }
>
>
> It seems somehow redundant, but this is code from several experiments.
> Anyway it has no effect: crash on second pipeline building is inevitable.
>
> More experiments. If not to render, just build pipeline, second 'shutdown'
> crashes on rp.GetRenderer().RemoveAllViewProps(); In this time JVM complans
> to vtkFiltering.dll and removing viewprops method.
>
>
> Stack: [0x0a7d0000,0x0a820000], sp=0x0a81e8a0, free space=314k
> Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native
> code)
> C [vtkFiltering.dll+0x139293]
> j vtk.vtkViewport.RemoveAllViewProps_6()V+0
> [..skip..]
>
>
> Need any help that VTK guru's can provide.
>
> P.S. Some more diagnostics data.
> VTK 5.6.1 (build with VS2010)
> JVM: 6.0_24 b07
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/IsRenderSupported-method-crash-tp4592105p4592105.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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
More information about the vtkusers
mailing list