[vtkusers] Rounding error in visualization pipline with a vtkCursor2D

Xiaofeng Z xf10036 at hotmail.com
Mon Mar 29 13:16:15 EDT 2010


Hello VTK users,

 

I'm using a visualization pipeline as the following:

 

vtkImageData->vtkImageReslice->...->vtkImageActor

 

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:

 

vtkRenderer& rndr = *interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer();

rndr.SetDisplayPoint(currPos[0], currPos[1], 0);

rndr.DisplayToWorld();

double point[4];

rndr.GetWorldPoint(point);

// the value in the third component is fake, why???

//point[2] = 0.0;

// next, convert back to the original vtkImageData coordinate system

vtkImageReslice* reslice = ImageReslice;

reslice->GetOutput()->UpdateInformation();

vtkImageData& slice = *reslice->GetOutput();

vtkMatrix4x4 *matrix = reslice->GetResliceAxes();

double center[4];

matrix->MultiplyPoint(point, center);

 

 

 

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.

 

vtkMatrix4x4* invert = vtkMatrix4x4::New();

vtkMatrix4x4::Invert(&xform, invert);

double world[4];

invert->MultiplyPoint(center, world);

vtkRendererCollection* rc = renWin->GetRenderers();

assert(rc && rc->GetNumberOfItems() == 1);

vtkRenderer& rndr = *rc->GetFirstRenderer();

rndr.SetWorldPoint(world);

rndr.WorldToDisplay();

rndr.GetDisplayPoint(display);

vtkCursor2D& cursor = *callback->GetCursor2D();

int* size = renWin->GetSize();

cursor.SetModelBounds(1, size[0], 1, size[1], 0, 0);

cursor.SetFocalPoint(display);

 

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?

 

Thanks!


Xiaofeng Z



 		 	   		  
_________________________________________________________________
The New Busy is not the old busy. Search, chat and e-mail from your inbox.
http://www.windowslive.com/campaign/thenewbusy?ocid=PID27925::T:WLMTAGL:ON:WL:en-US:WM_HMP:032010_3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100329/17bead7d/attachment.htm>


More information about the vtkusers mailing list