# Cell picker using HardwareSelector

**URL:** https://discourse.vtk.org/t/cell-picker-using-hardwareselector/9700
**Category:** Support
**Created:** [October 30, 2022, 11:58pm UTC](https://discourse.vtk.org/t/cell-picker-using-hardwareselector/9700 "2022-10-30T23:58:55Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![MarKara](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@MarKara](https://discourse.vtk.org/u/MarKara)
#### Post date: [October 30, 2022, 11:58pm UTC](https://discourse.vtk.org/t/cell-picker-using-hardwareselector/9700/1 "2022-10-30T23:58:55Z")

</div>

I know this question is raised before but I still cannot find definite answer how to use hardwareselector.  
I’m using ActiViz 9.2 and have the same problem discussed here  
[How to select a hexahedral cell using HardwareSelector](https://discourse.vtk.org/t/how-to-select-a-hexahedral-cell-using-hardwareselector/2062).  
I’m using vtkgeometryfilter to triangulate unstructured grids and I do set PassThroughCellIdsOn() in order to preserve original cell id, but vtkSelectionNode always returns the ID of the triangle used to represent faces of the hexahedral or polyhedral cell. Here use the peace of the code I have so far.

vtkHardwareSelector hs = vtkHardwareSelector.New();  
hs.SetRenderer(renderer);  
hs.SetFieldAssociation(1);  
hs.SetArea((uint)pos[0], (uint)pos[1], (uint)(pos[0]+1), (uint)(pos[1])+1);  
vtkSelection selection = hs.Select();  
vtkSelectionNode SelectionNode = selection.GetNode(0);

Previously I was using vtkStaticCellLocator this works fine hexahedral cells, but in case of polyhedral cell type, cell picking is very sketchy and inaccurate. The same issue is with vtkCellPicker

I tested the same polyhedral unstructured grid in ParaView and as expected works perfectly.  
Can anybody please share ideas how they do it or is that heavily guarded secret. 🙂

Thanks in advance.  
MK

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spyridon97/32/7069_2.png) [@spyridon97](https://discourse.vtk.org/u/spyridon97)
#### Post date: [October 31, 2022, 7:35pm UTC](https://discourse.vtk.org/t/cell-picker-using-hardwareselector/9700/2 "2022-10-31T19:35:20Z")

</div>

vtkHardwarePicker uses vtkHardwarSelector and is the equilavent of vtkCellPicker.  
vtkHardwarePicker uses a rendering way to pick cells while vtkCellPicker uses a geometric way to pick cells.

---

<div class="post-metadata">

### Author: ![MarKara](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/m/ecae2f/32.png) [@MarKara](https://discourse.vtk.org/u/MarKara)
#### Post date: [November 2, 2022, 1:55am UTC](https://discourse.vtk.org/t/cell-picker-using-hardwareselector/9700/3 "2022-11-02T01:55:50Z")

</div>

Hi Spiros  
Thanks for reply.  
I tested earlier vtkHardwarePicker and was having the similar issue as with vtkHardwareSelector. Strangely only after I swap vtkDatasetMapper to vtkPolydataMapper, vtkHardwarePicker worked perfectly. Not sure why would that be a problem but at least it works now.  
MK

---

<div class="post-metadata">

### Author: ![spyridon97](https://discourse.vtk.org/user_avatar/discourse.vtk.org/spyridon97/32/7069_2.png) [@spyridon97](https://discourse.vtk.org/u/spyridon97)
#### Post date: [November 3, 2022, 12:49pm UTC](https://discourse.vtk.org/t/cell-picker-using-hardwareselector/9700/4 "2022-11-03T12:49:09Z")

</div>

I am glad to hear that it works as expected.
