# \[javascript\] Get the cellID having the pointID

**URL:** https://discourse.vtk.org/t/javascript-get-the-cellid-having-the-pointid/11615
**Category:** Support
**Created:** [June 6, 2023, 10:25am UTC](https://discourse.vtk.org/t/javascript-get-the-cellid-having-the-pointid/11615 "2023-06-06T10:25:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Alex\_Vergara](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alex_vergara/32/7082_2.png) [@Alex\_Vergara](https://discourse.vtk.org/u/Alex_Vergara)
#### Post date: [June 6, 2023, 10:25am UTC](https://discourse.vtk.org/t/javascript-get-the-cellid-having-the-pointid/11615/1 "2023-06-06T10:25:22Z")

</div>

Hello

I know the existence of the function `let cellIds = polydata.getPointCells(i, vtkTriangle);`, where “i” is the pointId. I expect a list of cellIds as output (all cells than contain the point i), but this is not the case. Any hint on how to use this undocumented function?

Regards

---

<div class="post-metadata">

### Author: ![Alex\_Vergara](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alex_vergara/32/7082_2.png) [@Alex\_Vergara](https://discourse.vtk.org/u/Alex_Vergara)
#### Post date: [June 6, 2023, 11:46am UTC](https://discourse.vtk.org/t/javascript-get-the-cellid-having-the-pointid/11615/2 "2023-06-06T11:46:59Z")

</div>

Maybe I am asking the wrong question, Here there are other questions with the same goal:

1. How can I get the ids of all the cells that contain a known point in a polydata?
2. How can I get the neighbour points connected with a known point in a polydata?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 7, 2023, 12:03pm UTC](https://discourse.vtk.org/t/javascript-get-the-cellid-having-the-pointid/11615/3 "2023-06-07T12:03:50Z")

</div>

Hello,

I believe that’s not the way `getPointCells()` is supposed to be called. Take a look at this: [https://vtk.org/doc/nightly/html/classvtkPolyData.html#adf9caaa01f72972d9a986ba997af0ac7](https://vtk.org/doc/nightly/html/classvtkPolyData.html#adf9caaa01f72972d9a986ba997af0ac7)

take care,

PC

---

<div class="post-metadata">

### Author: ![Alex\_Vergara](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alex_vergara/32/7082_2.png) [@Alex\_Vergara](https://discourse.vtk.org/u/Alex_Vergara)
#### Post date: [June 7, 2023, 1:58pm UTC](https://discourse.vtk.org/t/javascript-get-the-cellid-having-the-pointid/11615/4 "2023-06-07T13:58:32Z")

</div>

Thanks for your reply  
However:

1. I am on javascript
2. I do call BuildLinks before.
3. the function getPointCells does not accept vtlIdList as it doesn’t exists in vtk.js
4. The returned object makes no sense to me and I can’t use it as even in the console only shows a common Dataset that I can’t get to work.

Regards

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [June 7, 2023, 3:41pm UTC](https://discourse.vtk.org/t/javascript-get-the-cellid-having-the-pointid/11615/5 "2023-06-07T15:41:18Z")

</div>

Hello,

You can make use of JS’ reflection/introspection and do some exploratory programming to discover the `Dataset` object’s methods and members. For example, to get all methods of the returned object:

```javascript
(...)
let cellIds = polydata.getPointCells(i, vtkTriangle);

let methods = [];
for(var key in cellIds) {
    if(cellIds.hasOwnProperty(key) && typeof cellIds[key] == 'function') {
        methods.push(key);
    }
}

for (i = 0; i < methods.length; i++)
  document.writeln("method number " + (i+1) + ": " + methods[i]);

(...)

```

Side note: It is recommended to post under the “web” tag, where most `vtk.js` talk takes place. The “support” tag is mostly for non-web applications (mostly C++, Java and Python).

best,

PC
