[vtkusers] Please help : Cross-platform VTK rendering
v.varadhan at gmail.com
Tue Dec 14 02:14:41 EST 2004
Please find my replies inline, I may be wrong as its been a while
since I worked on VTK ;-). So, the thought is given "as is" and use
it at your own risk.. ;-)
On Tue, 14 Dec 2004 11:46:56 +0530, Shastry, Anand C (Research)
<anand.shastry at ge.com> wrote:
> I have a GUI built using RSI IDL. The VTK volume rendering algorithm is in the form of a dll. From the IDL GUI, the dll gets called, the data passed by means of pointers.
> I'm using vtkRenderWindowInteractor to interact with the rendering. I encounter 3 problems :
> 1. Deletion of objects created in the dll. The VTK memory is required as long as the rendered window is active. I dont know how to free this memory (for the window, renderer, volume object, etc of a standard rendering pipeline) on closing the render window. Tried putting it in the destructor, but doesn't seem to work.
VTK objects use "reference counts" to keep/free any memory
allocations. A memory associate with a VTK object is free iff its
"ref-count" is zero.
So, you can easily verify this by placing breakpoints in the
destructor of your render window. Whenever a render window is
destructed, it calls the "Delete() method of appropriate renderers
associated with it and renderer calls "Delete()" of all vtkProps and
so on. In case if you have any memory leaks, it might be because of
some vtk objects having a non-zero positive reference count.
> 2. Mouse/keyboard control transfer. Once the render window is created, the interaction is taken over by VTK. None of the IDL GUI buttons work till the VTK window is closed.
> I want to be able to change rendering parameters (opacity, etc) from the IDL GUI & refresh the render window to reflect these.
> Right now, this is only possible by closing the VTK window & popping up a new rendering window (another dll call).
Are you able to "click" on the IDL buttons/ move your mouse over the
VTK window, etc?
> 3. The IDL GUI display does not refresh, when I drag or move the VTK render window. May be related to above problem.
> The rendering pipeline I follow within the exec loop used to create the dll is :
> vtkRenderer *renderer = vtkRenderer::New();
> vtkVolume* volume = vtkVolume::New();
> vtkRenderWindow *renWin = vtkRenderWindow::New();
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> vtkVolumeProperty *volumeProperty = vtkVolumeProperty::New();
> vtkVolumeRayCastMapper *volMapper = vtkVolumeRayCastMapper::New();
> vtkPiecewiseFunction *opacityTransferFunction = vtkPiecewiseFunction::New();
> vtkColorTransferFunction *colorTransferFunction = vtkColorTransferFunction::New();
> vtkVolumeRayCastCompositeFunction *compFunc = vtkVolumeRayCastCompositeFunction::New();
> //set volume properties
> volMapper->SetInput (pImageIn);
> volMapper->SetVolumeRayCastFunction (compFunc);
> iren->Delete(); //Cannot delete any other object, as it's required
I think you can still delete few more objects like
pImageIn->Delete(); // should be possible because volMapper->SetInput()
// would have incremented its
reference count by 1.
// I may be wrong, just verify
this with some other
// vtk examples.
> Any help is greatly appreciated, as I'm stuck here.
Hope this helps, if not, kindly correct me. ;-)
More information about the vtkusers