<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Hello VTK users,<BR>
<BR>
I'm using a visualization pipeline as the following:<BR>
<BR>
vtkImageData->vtkImageReslice->...->vtkImageActor<BR>
<BR>
for a multi-planar rendering of CT image and use vtkCursor2D to display the focus point by first converting the display coordinate to world coordinate in vtkImageData:<BR>
<BR><FONT size=2>
vtkRenderer& rndr = *interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer();<BR>
rndr.SetDisplayPoint(currPos[0], currPos[1], 0);<BR>
rndr.DisplayToWorld();<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> point[4];<BR>
rndr.GetWorldPoint(point);<BR>
</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// the value in the third component is fake, why???<BR></FONT></FONT><FONT size=2>
</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>//point[2] = 0.0;<BR></FONT></FONT><FONT size=2>
</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2>// next, convert back to the original vtkImageData coordinate system<BR></FONT></FONT><FONT size=2>
vtkImageReslice* reslice = ImageReslice;<BR>
reslice->GetOutput()->UpdateInformation();<BR>
vtkImageData& slice = *reslice->GetOutput();<BR>
vtkMatrix4x4 *matrix = reslice->GetResliceAxes();<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> center[4];<BR>
matrix->MultiplyPoint(point, center);<BR>
</FONT><FONT color=#008000 size=2><FONT color=#008000 size=2></FONT></FONT><FONT size=3> </FONT><BR>
<FONT size=3></FONT> <BR>
<FONT size=3></FONT> <BR>
Then convert it back screen coordinate to vtkCursor2D (this is neccessary to synchronize the multiple views). In the following, "center" is the world coordinate based on vtkImageData.<BR>
<BR><FONT size=2>
vtkMatrix4x4* invert = vtkMatrix4x4::New();<BR>
vtkMatrix4x4::Invert(&xform, invert);<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>double</FONT></FONT><FONT size=2> world[4];<BR>
invert->MultiplyPoint(center, world);<BR>
vtkRendererCollection* rc = renWin->GetRenderers();<BR>
assert(rc && rc->GetNumberOfItems() == 1);<BR>
vtkRenderer& rndr = *rc->GetFirstRenderer();<BR>
rndr.SetWorldPoint(world);<BR>
rndr.WorldToDisplay();<BR>
rndr.GetDisplayPoint(display);<BR>
vtkCursor2D& cursor = *callback->GetCursor2D();<BR>
</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>int</FONT></FONT><FONT size=2>* size = renWin->GetSize();<BR>
cursor.SetModelBounds(1, size[0], 1, size[1], 0, 0);<BR>
cursor.SetFocalPoint(display);<BR></FONT>
<BR>
The problems is the Cursor2D so placed is slightly off from where the mouse is clicked, towards the center of the display. Is it caused by rounding error somewhere? Does anyone know of a fix?<BR>
<BR>
Thanks!<BR>
<BR>Xiaofeng Z<BR><BR><BR><BR> <br /><hr />The New Busy is not the old busy. Search, chat and e-mail from your inbox. <a href='http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_3' target='_new'>Get started.</a></body>
</html>