<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello,<br>
<br>
I'm trying to display a sphere lying on a triangle mesh. The user
can move this sphere over the triangle mesh with the mouse.<br>
<br>
The user put the sphere over the mesh with a click. To get the point
of the mesh clicked I use the following code:<br>
<blockquote><font face="Courier New, Courier, monospace"><small>mPointPicker
= vtkCellPicker::New();<br>
mPointPicker->Pick(mStyle->GetInteractor()->GetEventPosition()[0],
mStyle->GetInteractor()->GetEventPosition()[1], 0,
mStyle->GetInteractor()->GetRenderWindow()->GetRenderers()->GetFirstRenderer());</small><br>
<small><br>
double p[3];<br>
p[0] = p[1] = p[2] = 0.;<br>
if (id_actor == (int)(mModel->getBoneActor()))
mModel->getSkeletonMesh()->GetPoint(id, p);<br>
else if (id_actor == (int)(mModel->getLungsActor()))
mModel->getLungsMesh()->GetPoint(id, p);<br>
else return;<br>
<br>
vtkSphereSource* sphereSource = vtkSphereSource::New();<br>
sphereSource->SetCenter(p[0], p[1], p[2]);<br>
</small></font></blockquote>
<br>
With this code, the position of the sphere is ever well computed (It
have never failed me...)<br>
<br>
The user can move the sphere over the mesh with a click and a
movement of the mouse. To compute the temporal position (while the
user is moving the sphere) I use the following code:<br>
<blockquote><font face="Courier New, Courier, monospace"><small>double
*pointPicker;</small></font><br>
<font face="Courier New, Courier, monospace"><small>mWorldPointPicker->Pick(mStyle->GetInteractor()->GetEventPosition()[0],
mStyle->GetInteractor()->GetEventPosition()[1], 0,</small></font><font
face="Courier New, Courier, monospace"><small>
mQVTKWidget->GetRenderWindow()->GetRenderers()->GetFirstRenderer());</small></font><br>
<font face="Courier New, Courier, monospace"><small>pointPicker =
mWorldPointPicker->GetPickPosition();</small></font><br>
<small><font face="Courier New, Courier, monospace">sphere->SetCenter(pointPicker[0],pointPicker[1],pointPicker[2]);</font></small><br>
</blockquote>
<br>
I use that code, because with it I get better performance than with
the other picker. But, as I get worse precision, when the user
release the mouse button I use the following code to obtain the
exact final position:<br>
<blockquote><font face="Courier New, Courier, monospace"><small>mPointPicker->Pick(mStyle->GetInteractor()->GetEventPosition()[0],
mStyle->GetInteractor()->GetEventPosition()[1], 0,<br>
mStyle->GetInteractor()->GetRenderWindow()->GetRenderers()->GetFirstRenderer());</small></font><br>
<small><font face="Courier New, Courier, monospace"><br>
</font></small><font face="Courier New, Courier, monospace"><small>double
p[3];<br>
p[0] = p[1] = p[2] = 0.;</small></font><br>
<small><font face="Courier New, Courier, monospace">if (id_actor
== (int)(mModel->getBoneActor()))
mModel->getSkeletonMesh()->GetPoint(idPicker, p);<br>
else if (id_actor == (int)(mModel->getLungsActor()))
mModel->getLungsMesh()->GetPoint(idPicker, p);<br>
else return;<br>
<br>
sphere->SetCenter(p[0],p[1],p[2]);</font></small><br>
</blockquote>
<br>
<br>
The problem is that although I use the same code than when the
sphere is added, the position obtained is not correct. Sometimes
after I move the sphere it is not well positioned. It is not on the
surface, it have an empty space between the sphere and the
surface... <br>
<br>
What am I doing wrong? <br>
There is any other call with more precision??<br>
Other actors in the renderer without visibility affect to this call?<br>
<br>
Thank you very much for helping me,<br>
<br>
<pre class="moz-signature" cols="72">--
Imanol Muñoz i Pandiella.</pre>
</body>
</html>