# Use vtkHardwareSelector to select point of vtkGlyph3DMapper

**URL:** https://discourse.vtk.org/t/use-vtkhardwareselector-to-select-point-of-vtkglyph3dmapper/3790
**Category:** Support
**Created:** [July 16, 2020, 12:17pm UTC](https://discourse.vtk.org/t/use-vtkhardwareselector-to-select-point-of-vtkglyph3dmapper/3790 "2020-07-16T12:17:26Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![michael23](https://discourse.vtk.org/user_avatar/discourse.vtk.org/michael23/32/837_2.png) [@michael23](https://discourse.vtk.org/u/michael23)
#### Post date: [July 16, 2020, 12:17pm UTC](https://discourse.vtk.org/t/use-vtkhardwareselector-to-select-point-of-vtkglyph3dmapper/3790/1 "2020-07-16T12:17:26Z")

</div>

Hi,

I am using vtkGlyph3DMapper for rendering cylinders at certain points.  
Now I want to click on a cylinder and get the index of the point which was clicked.

Here is my code (based on TestGlyph3DMapperCellPicking.cxx):

```
	virtual void OnLeftButtonDown()
	{
		vtkNew<vtkHardwareSelector> sel;
		sel->SetFieldAssociation(vtkDataObject::FIELD_ASSOCIATION_POINTS);
		sel->SetRenderer(this->Renderer);

		int event_pos_x = this->GetInteractor()->GetEventPosition()[0];
		int event_pos_y = this->GetInteractor()->GetEventPosition()[1];

		sel->SetArea(event_pos_x, event_pos_y, event_pos_x, event_pos_y);

		vtkSelection *res = sel->Select();
		
		vtkSelectionNode *glyphids = res->GetNode(0);
		if (glyphids != nullptr)
		{
			vtkAbstractArray *abs = glyphids->GetSelectionList();
			vtkIdTypeArray *ids = vtkArrayDownCast<vtkIdTypeArray>(abs);
			if(ids)
			{
				vtkIdType numSelPoints = ids->GetNumberOfTuples();
				for (vtkIdType i = 0; i < numSelPoints; i++)
				{
					vtkIdType value = ids->GetValue(i);
				}
			}
		}
	}

```

If I click close to the center of a cylinder I always get a value of 1, whereas a little bit off I get the right value (point index).

What’s the right way to do it?

Using vtkGlyph3D with GeneratePointIds() is not an option because I have to use  
the GPU (increase performance).

Thank you!!
