# How to access cells from in an octant/bin in a vtkStaticCellLocator?

**URL:** https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660
**Category:** Support
**Created:** [January 17, 2022, 9:09pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660 "2022-01-17T21:09:52Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [January 17, 2022, 9:09pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/1 "2022-01-17T21:09:52Z")

</div>

Hello!!!

I want to recover the list/array of cells associated with an octant/bin in a vtkStaticCellLocator, but I don’t see any access methods on the locator to get this info.

What am I missing?

Thanks in advance,

Doug

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [January 18, 2022, 7:04am UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/2 "2022-01-18T07:04:54Z")

</div>

I see that there is a GetCells() method on vtkCellSelector, but it’s not there on the vtkStaticCellLocator and I really need the performance of the static locator.

The class documentation for vtkStaticCellLocator claims that it’s an accelerated version of vtkCellLocator. I’m wondering if removing these methods was a design choice or an oversight? Looking at the implementation it seems like the GetCells() method could be implemented very easily.

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [January 18, 2022, 2:08pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/3 "2022-01-18T14:08:37Z")

</div>

Good catch, it looks like an oversight. I agree, it looks like this could be implemented easily.

Do you want to create a MR? If not, I can get to this sometime in the next week or two.

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [January 18, 2022, 4:38pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/4 "2022-01-18T16:38:01Z")

</div>

Will,  
To date, I haven’t made a code contribution to VTK so I thought I might use this as my first opportunity - given that it looks easy enough to do…  
To that end, I read the instructions on how to do this last night - so I think I’ll give it a go myself. It’ll likely take me a while even though the code change shoudl be minimal.

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [January 18, 2022, 4:41pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/5 "2022-01-18T16:41:54Z")

</div>

Thank you. The software process can definitely be a little confusing at first, but we will help.

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [January 18, 2022, 4:45pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/6 "2022-01-18T16:45:57Z")

</div>

@will.schroeder - One of the reasons I’m looking at this method is because I’m struggling to get highly performant rubber band picking working in VTK (vtkUnstrucutrredGrids, vtkPolyData in composite data sets.  
Basically, I can’t see any path through the code that takes advantage of both Octree/vtkStaticCellLocator AND SMP for this task. I see that vtkFrustumSelector is now SMPTools enabled, but doesn’t take advantage of the binning that is available in vtkStaticCellLocator.  
So I was thinking about extending vtkFrustumSelector to use vtkStaticCellLocator to improve performance - does that make sense?

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [January 18, 2022, 4:46pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/7 "2022-01-18T16:46:18Z")

</div>

Thanks Will!!!

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [January 18, 2022, 5:08pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/8 "2022-01-18T17:08:24Z")

</div>

Got it. Are you going to modify the vtkFrustumSelector to use the cell locator? If so, you probably want to make its use optional because the cost of upfront building the locator can be quite high, and some use cases won’t tolerate that.

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [January 18, 2022, 5:16pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/9 "2022-01-18T17:16:38Z")

</div>

Yes - I was thinking about making it optional. Are there established patterns for this?

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [January 18, 2022, 7:44pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/10 "2022-01-18T19:44:40Z")

</div>

I would add a UseCellLocator boolean (Set/Get/Boolean macros in the .h file) so users can enable / disable it.

---

<div class="post-metadata">

### Author: ![scotsman60](https://discourse.vtk.org/user_avatar/discourse.vtk.org/scotsman60/32/6000_2.png) [@scotsman60](https://discourse.vtk.org/u/scotsman60)
#### Post date: [January 18, 2022, 10:02pm UTC](https://discourse.vtk.org/t/how-to-access-cells-from-in-an-octant-bin-in-a-vtkstaticcelllocator/7660/11 "2022-01-18T22:02:53Z")

</div>

Makes sense. I can also check if the locator is already present and up to date on the dataset and just use it if it is, even if the flag is False…
