[vtkusers] Question about synchronization bwtween 3D and 2D image
Shade
shade_cn at yahoo.com
Fri Apr 27 23:20:07 EDT 2001
Dear Everyone,
My aim is to synchronize the 2D images accordint to the mouse
cursor position in 3D Render Window.
I have searching the mailing list and found some mails of the same
question, but I didn't find the exact answer.
Following is my method trying to get the silce number of the Transverse,
Coronal and Sagittal View, but it seems not correct, I don't know what's
wrong? Please help me, thank you.
void C4DView3D::OnMouseMove(UINT nFlags, CPoint point)
{
float fBounds[6];
::ZeroMemory( fBounds, sizeof(fBounds) );
this->GetVolumeMapper()->GetBounds(fBounds);
float fX = point.x;
float fY = point.y;
// Convert the Y axis to make it from bottom to top
this->m_pRenderer->LocalDisplayToDisplay( fX, fY );
// Get the ZBuffer value of the mouse point
// Is is the exact Z value of the Display Coordinate?
float fZ = this->m_pRenderer->GetZ( fX, fY );
float fpWorldPoint[4] = { 0.0, 0.0, 0.0, 1.0 };
// Set the Display Point
this->m_pRenderer->SetDisplayPoint( fX, fY, fZ );
// Convert the Display Coordinate to World Coordiante
this->m_pRenderer->DisplayToWorld();
// Get World Coordinate of the mouse point
this->m_pRenderer->GetWorldPoint(fpWorldPoint);
fX = fpWorldPoint[0] / fpWorldPoint[3];
fY = fpWorldPoint[1] / fpWorldPoint[3];
fZ = fpWorldPoint[2] / fpWorldPoint[3];
//Transverse
int nSliceNumT = (int)( fBounds[3] - fBounds[2] - fY );
//Coronal
int nSliceNumC = (int)( fBounds[5] - fBounds[4] ) / 2 + fZ;
//Sagittal
int nSliceNumS = (int)( fBounds[1] - fBounds[0] - fX );
vtkMFCRenderView::OnMouseMove(nFlags, point);
}
The result is as following:
1. Before Rotate the X , Y value seems correct but the Z value is not correct
2. After Rotate the X, Y, Z value all are not correct.
I also tried the vtkWorldPointPicker method, but the result is the same as above method.
Welcome any opinion and suggestion. Thank you in advance!
Best Regards,
***********************************************************
Liu Jiquan
College of Biomedical Engineering & Instrument Science
Zhejiang University
Hangzhou, Zhejiang, 310027
P.R.China
Tel: +86-571-7951792Ext.13
Fax: +86-571-7951792Ext.18
EMail:shade_cn at yahoo.com
***********************************************************
ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿü:¢æÿügÊ«~·ÿ&¡¢Ü¢fv·¬±«a¶Úÿÿù_òj(ýÊ&
More information about the vtkusers
mailing list