<html>
Dear All:<br><br>
My MSc project involves describing the relative motions between bones in
the wrist, given 3D reconstructed scans of the same wrist in more than
one posture. I am using VTK for this purpose. I am using another
library V for designing my graphical user interface (gui).
<br><br>
My gui gives control to vtk to render the 3D images of the wrist in a
<b>vtkRenderWindow</b> and starts the
<b>vtkRenderWindowInteractor</b>. When the user wants to
close the 3D vtk model, stop the vtkRenderWindowInteractor, kill the
vtkRenderWindow and come back to the gui for further computation, I
experience a problem. <br><br>
vtkRenderWindowInteractor's default exitMethod kills my application and
gui as well as the vtkRenderWindow. We defined a user-defined
exitMethod to give control back to program by terminating the threads to
vtkRenderWindowInteractor and vtkRenderWindow. This gives me a
segmentation fault when my exitMethod tries to break the threads.
Is there another way...?<br><br>
I will show the relevant code below. My program has a <b>carpus</b>
class. This class has a method called <b>carpalRender</b> for
rendering the carpus. And a new user-defined <b>exitMethod</b> to
exit the vtk window opened by carpalRender.<br><br>
class <b>carpus<br>
</b>{<br>
private:<br><br>
//I define these as members of carpus so that I can terminate the
threads from my exit method<br><br>
vtkRenderWindowInteractor *iren;<br>
vtkRenderWindow* renWindow;<br>
vtkRenderer* scene_render;<br>
...<br><br>
public:<br>
//render to show itself<br>
void <b>carpalRender</b>(...);<br><br>
//new exit method for vtkWindowInteractor so it does not terminate
application<br>
void carpus::<b>MemberExitMethod</b>(void *arg);<br>
...<br>
};<br><br>
Now Here is the relevant code from the method carpus::carpalRender which
calls the ExitMethod.<br><br>
void carpus::<b>carpalRender</b>(...)<br>
{<br>
...<br>
renWindow = vtkRenderWindow::New();<br>
...<br><br>
// Create window interactor<br>
iren = vtkRenderWindowInteractor::New();<br>
...<br><br>
// set the user-defined C-style ExitMethod as the new exit
method<br>
iren->SetExitMethod (ExitMethod,NULL);<br><br>
// Draw the resulting scene<br>
renWindow->Render();<br>
<br>
// Enable mouse interaction <br>
iren->Start();<br><br>
//since vtkRenderWindowInteractor does not give control back to
carpalRender <br>
//any further code in carpalRender would not get executed <br>
};<br><br>
Now the following segment of code is the C-style exit method which then
executes another <b>MemberExitMethod</b> which is a member of the carpus
class.<br><br>
//*********************>>> ExitMethod
<<<<************************//<br>
void <b>ExitMethod</b>(void *arg)<br>
{<br>
static_cast<carpus*>(arg)->MemberExitMethod(arg);<br>
};<br><br>
//*********************>>> carpus::MemberExitMethod
<<<<************************//<br>
void carpus::<b>MemberExitMethod</b>(void *arg)<br>
{<br>
iren->Delete();<br>
renWindow->Delete();<br>
};<br><br>
Any ideas are welcome. Thanks,<br>
Anwar Upal<br><br>
<br><br>
>hi,<br>
><br>
>>>>> "Bill" == William A Hoffman
<billlist@nycap.rr.com> writes:<br>
><br>
> Bill> VTK callback functions are all C
functions and can not be<br>
> Bill> member functions. To call a member
function, you have to<br>
> Bill> create a "C" function that
calls the member funciton:<br>
><br>
> Bill> Something like this:<br>
><br>
> Bill> void newExtiMethod(void* arg) {<br>
> Bill>
static_cast<classname*>(arg)->newExitMethod(); }<br>
><br>
>Are you sure? Shouldnt the following code also work?<br>
><br>
>class Foo{<br>
><br>
> // ...<br>
> static void ExitMethod (void
*arg);<br>
>}<br>
><br>
>iren->SetExitMethod(&Foo::ExitMethod, NULL);<br>
><br>
>prabhu<br>
</html>