<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.&nbsp; I am using another
library V for designing my graphical user interface (gui).&nbsp;
<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>.&nbsp;&nbsp; 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.&nbsp; <br><br>
vtkRenderWindowInteractor's default exitMethod kills my application and
gui as well as the vtkRenderWindow.&nbsp; We defined a user-defined
exitMethod to give control back to program by terminating the threads to
vtkRenderWindowInteractor and vtkRenderWindow.&nbsp; This gives me a
segmentation fault when my exitMethod tries to break the threads.&nbsp;
Is there another way...?<br><br>
I will show the relevant code below.&nbsp; My program has a <b>carpus</b>
class.&nbsp; This class has a method called <b>carpalRender</b> for
rendering the carpus.&nbsp; 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>
&nbsp; //I define these as members of carpus so that I can terminate the
threads from my exit method<br><br>
&nbsp; vtkRenderWindowInteractor *iren;<br>
&nbsp; vtkRenderWindow* renWindow;<br>
&nbsp; vtkRenderer* scene_render;<br>
&nbsp; ...<br><br>
public:<br>
&nbsp; //render to show itself<br>
&nbsp; void <b>carpalRender</b>(...);<br><br>
&nbsp; //new exit method for vtkWindowInteractor so it does not terminate
application<br>
&nbsp; void carpus::<b>MemberExitMethod</b>(void *arg);<br>
&nbsp; ...<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>
&nbsp; ...<br>
&nbsp; renWindow = vtkRenderWindow::New();<br>
&nbsp; ...<br><br>
&nbsp; // Create window interactor<br>
&nbsp; iren = vtkRenderWindowInteractor::New();<br>
&nbsp; ...<br><br>
&nbsp; // set the user-defined C-style ExitMethod as the new exit
method<br>
&nbsp; iren-&gt;SetExitMethod (ExitMethod,NULL);<br><br>
&nbsp; // Draw the resulting scene<br>
&nbsp; renWindow-&gt;Render();<br>
&nbsp;<br>
&nbsp; // Enable mouse interaction <br>
&nbsp; iren-&gt;Start();<br><br>
&nbsp; //since vtkRenderWindowInteractor does not give control back to
carpalRender <br>
&nbsp; //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>
//*********************&gt;&gt;&gt; ExitMethod
&lt;&lt;&lt;&lt;************************//<br>
&nbsp; void <b>ExitMethod</b>(void *arg)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp;
static_cast&lt;carpus*&gt;(arg)-&gt;MemberExitMethod(arg);<br>
&nbsp; };<br><br>
//*********************&gt;&gt;&gt; carpus::MemberExitMethod
&lt;&lt;&lt;&lt;************************//<br>
&nbsp; void carpus::<b>MemberExitMethod</b>(void *arg)<br>
&nbsp; {<br>
&nbsp;&nbsp;&nbsp; iren-&gt;Delete();<br>
&nbsp;&nbsp;&nbsp; renWindow-&gt;Delete();<br>
&nbsp;};<br><br>
Any ideas are welcome.&nbsp; Thanks,<br>
Anwar Upal<br><br>
<br><br>
&gt;hi,<br>
&gt;<br>
&gt;&gt;&gt;&gt;&gt; &quot;Bill&quot; == William A Hoffman
&lt;billlist@nycap.rr.com&gt; writes:<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp; Bill&gt; VTK callback functions are all C
functions and can not be<br>
&gt;&nbsp;&nbsp;&nbsp; Bill&gt; member functions.&nbsp; To call a member
function, you have to<br>
&gt;&nbsp;&nbsp;&nbsp; Bill&gt; create a &quot;C&quot; function that
calls the member funciton:<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp; Bill&gt; Something like this:<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp; Bill&gt; void newExtiMethod(void* arg) {<br>
&gt;&nbsp;&nbsp;&nbsp; Bill&gt;
static_cast&lt;classname*&gt;(arg)-&gt;newExitMethod(); }<br>
&gt;<br>
&gt;Are you sure?&nbsp; Shouldnt the following code also work?<br>
&gt;<br>
&gt;class Foo{<br>
&gt;<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // ...<br>
&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static void ExitMethod (void
*arg);<br>
&gt;}<br>
&gt;<br>
&gt;iren-&gt;SetExitMethod(&amp;Foo::ExitMethod, NULL);<br>
&gt;<br>
&gt;prabhu<br>
</html>