hi,all, <br> i need your help! Now, user can pick a point on the 3D model(The model is reconsturcted by MC algorithm). And i use vtkCellPicker to finish this task. Then, i need to show the 2D bmp image with corresponding ZSlice to user. I also need to calculate the 2D coordinate in the bmp image of that picked point. The problem for me is that my projection formula is not correct. The 2D coordinates i calculated is not right. Could any one give suggestions or better strategies? <br>
<span style="color: rgb(255, 0, 0);">The program is developped by vc6.0.</span><br> <br> Related code and projection formula is as follows:<br><br> vtkBMPReader *m_read;<br> vtkInteractorStyleTrackballCamera *style;<br>
vtkRenderWindowInteractor *iren;<br> vtkCellPicker *picker;<br> <br> iren->SetInteractorStyle(style);<br> style->AddObserver(vtkCommand::MiddleButtonReleaseEvent, cmd); // the middlebutton is used to pick point<br>
cmd->SetCallback(Execute);<br> picker->SetTolerance(0.0001);<br> iren->SetPicker(picker); <br> <br> void Execute(vtkObject *caller, unsigned long eid, void *clientdata, void *calldata)<br> {<br> double globalCoordinate[3]; //<br>
picker->Pick(iren->GetEventPosition()[0],iren->GetEventPosition()[1],0, aRenderer);<br> picker->GetPickPosition(globalCoordinate); <br> <br> int _2DCoor[3];<br><span style="color: rgb(255, 0, 0);">// this is the projection formula</span><br>
_2DCoor[0] = static_cast<int>(globalCoordinate[0] / m_Dx +0.5); //m_Dx represents space in x axies<br> <br> _2DCoor[1] = m_Ymax + 1 - static_cast<int>(globalCoordinate[1] / m_Dy) +0.5 ;//m_Dy represents space in y axies, m_Ymax represents the length of a 2D image<br>
<br> _2DCoor[2] = static_cast<int>(globalCoordinate[2] / m_Dz + 0.5) ; // m_Dz represents z space in Z axies<br><br>} <br><br>Any help or reply is highly appreciated.<br><br>thanks,<br>wenwu<br> <br> <br>