# Performance of rendering the PCD data.

**URL:** https://discourse.vtk.org/t/performance-of-rendering-the-pcd-data/982
**Category:** Support
**Created:** [May 17, 2019, 7:57am UTC](https://discourse.vtk.org/t/performance-of-rendering-the-pcd-data/982 "2019-05-17T07:57:52Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Kim\_William](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kim_william/32/373_2.png) [@Kim\_William](https://discourse.vtk.org/u/Kim_William)
#### Post date: [May 17, 2019, 7:57am UTC](https://discourse.vtk.org/t/performance-of-rendering-the-pcd-data/982/1 "2019-05-17T07:57:52Z")

</div>

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/MouseEvents)  
[https://vtk.org/Wiki/VTK/Examples/Cxx/Interaction/PointPicker](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 🙂

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [May 17, 2019, 12:19pm UTC](https://discourse.vtk.org/t/performance-of-rendering-the-pcd-data/982/2 "2019-05-17T12:19:05Z")

</div>

You can experiment with the many pickers VTK has. Some are faster (e.g., hardware-based pickers and those that are accelerated by using locator), some are more accurate or simpler.

vtkPointPicker is accurate, but I think it does not use a locator so it can be extremely slow if you have many points. vtkCellPicker can use a locator to speed up its operation. If vtkCellPicker does not work on a point cloud (require cells) then you can try to add a locator to vtkPointPicker or just use a locator directly (without a picker).

---

<div class="post-metadata">

### Author: ![Kim\_William](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kim_william/32/373_2.png) [@Kim\_William](https://discourse.vtk.org/u/Kim_William)
#### Post date: [May 20, 2019, 1:59am UTC](https://discourse.vtk.org/t/performance-of-rendering-the-pcd-data/982/3 "2019-05-20T01:59:19Z")

</div>

Hi Andras Lasso!

Thank you for your reply.

So… what can I do to the test?  
It can’t use with vtkCellPicker because there are no cells, and I can use vtkPointPicker but rendering speed is so slow with Pick API in the OnMouseMove event().

I still don’t know how to speed up the 3D rendering while getting point information.

Thank you 😢

---

<div class="post-metadata">

### Author: ![lassoan](https://discourse.vtk.org/user_avatar/discourse.vtk.org/lassoan/32/50_2.png) [@lassoan](https://discourse.vtk.org/u/lassoan)
#### Post date: [May 20, 2019, 4:21am UTC](https://discourse.vtk.org/t/performance-of-rendering-the-pcd-data/982/4 "2019-05-20T04:21:24Z")

</div>

There are so many options. For example, you may try adding a vertex cell for each point and see if cell picker or hardware-accelerated picker work (vtkScenePicker has some additional caching to speed up hardware-accelerated picking). You may also add a timer to only pick if the mouse is stopped over a point (vtkHoverWidget does something similar). You may also project all your points to the display plane and then use a locator to quickly find the closest point (the disadvantage is that you need to recompute each time you rotate the camera).

---

<div class="post-metadata">

### Author: ![Kim\_William](https://discourse.vtk.org/user_avatar/discourse.vtk.org/kim_william/32/373_2.png) [@Kim\_William](https://discourse.vtk.org/u/Kim_William)
#### Post date: [May 20, 2019, 8:36am UTC](https://discourse.vtk.org/t/performance-of-rendering-the-pcd-data/982/5 "2019-05-20T08:36:44Z")

</div>

So thank you for your guide!

I will try all of that.

Thank you 🙂

---

<div class="post-metadata">

### Author: ![yuhuimoon](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/y/c6cbf5/32.png) [@yuhuimoon](https://discourse.vtk.org/u/yuhuimoon)
#### Post date: [January 11, 2021, 11:00am UTC](https://discourse.vtk.org/t/performance-of-rendering-the-pcd-data/982/6 "2021-01-11T11:00:22Z")

</div>

Hello, I have met the same problem as you describe. Have you solved it?
