Hi all.
I’m sorry for asking so many questions recently.
But when I before asking a question, please understand that I have tested with sample code and googling.
My question is …
I want to display the point coordinate information of PCD data depending on the mouse cursor position.
I referred the link:
https://vtk.org/Wiki/VTK/Examples/Cxx/Interaction/MouseEvents
https://vtk.org/Wiki/VTK/Examples/Cxx/Interaction/PointPicker
But the rendering speed is so slow when GetPickPosition API is called continuously by OnMouseMove() event.
My code is as below:
class CCustomMouseInteractorStyle : public vtkInteractorStyleTrackballCamera
{
public:
static CCustomMouseInteractorStyle* New();
vtkTypeMacro(CCustomMouseInteractorStyle, vtkInteractorStyleTrackballCamera);
CCustomMouseInteractorStyle()
{
selectedMapper = vtkSmartPointer<vtkDataSetMapper>::New();
selectedActor = vtkSmartPointer<vtkActor>::New();
}
virtual void OnMouseMove() override
{
// Get the location of the click (in window coordinates)
int* pos = this->GetInteractor()->GetEventPosition();
vtkSmartPointer<vtkPointPicker> picker =
vtkSmartPointer<vtkPointPicker>::New();
// Pick from this location.
picker->Pick(pos[0], pos[1], 0, this->GetDefaultRenderer());
if (picker->GetPointId() != -1)
{
double* worldPosition = picker->GetPickPosition();
/*CString tmp;
tmp.Format(_T("%.3f\n"), worldPosition[2]);
OutputDebugString(tmp);*/
}
vtkInteractorStyleTrackballCamera::OnMouseMove();
}
vtkSmartPointer<vtkPolyData> Data;
vtkSmartPointer<vtkDataSetMapper> selectedMapper;
vtkSmartPointer<vtkActor> selectedActor;
};
vtkStandardNewMacro(CCustomMouseInteractorStyle);
How to speed up the rendering while getting the point coordinate information?
Could you please advise for me?
Thank you