# vtkPointSource & vtkPoints

**URL:** https://discourse.vtk.org/t/vtkpointsource-vtkpoints/12082
**Category:** Development
**Created:** [August 2, 2023, 9:41pm UTC](https://discourse.vtk.org/t/vtkpointsource-vtkpoints/12082 "2023-08-02T21:41:05Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![totte\_karlsson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/totte_karlsson/32/4281_2.png) [@totte\_karlsson](https://discourse.vtk.org/u/totte_karlsson)
#### Post date: [August 2, 2023, 9:41pm UTC](https://discourse.vtk.org/t/vtkpointsource-vtkpoints/12082/1 "2023-08-02T21:41:06Z")

</div>

Hi,  
I’m working on a tool to select points, using the rubberband interactor.

However, question is about basic vtk data types.

In the [vtkRubberband](https://examples.vtk.org/site/Cxx/Picking/HighlightSelectedPoints/) select example, the data is generated like this

```auto
 vtkNew<vtkPointSource> pointSource;
 pointSource->SetNumberOfPoints(2000);
 pointSource->Update();

 vtkNew<vtkIdFilter> idFilter;
 idFilter->SetInputConnection(pointSource->GetOutputPort());
 idFilter->SetCellIdsArrayName("OriginalIds");
 idFilter->SetPointIdsArrayName("OriginalIds");
 idFilter->Update();

```

Our data is stored using vtkPoints.

What I’m struggling with is, how do I create the input to the IdFilter, starting from vtkPoints?

---

<div class="post-metadata">

### Author: ![totte\_karlsson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/totte_karlsson/32/4281_2.png) [@totte\_karlsson](https://discourse.vtk.org/u/totte_karlsson)
#### Post date: [August 2, 2023, 9:56pm UTC](https://discourse.vtk.org/t/vtkpointsource-vtkpoints/12082/2 "2023-08-02T21:56:35Z")

</div>

I found (one) answer from another post here: [How to create a mesh data from vtkPoints? - #4 by Charles\_Gueunet](https://discourse.vtk.org/t/how-to-create-a-mesh-data-from-vtkpoints/6585/4)

```auto
  // vtk data set to fill
  vtkNew<vtkPolyData> myPolyData;

   // compute a vtkIdList that contains ids of each points 
 vtkIdType numPoints = points->GetNumberOfPoints();  
 vtkSmartPointer<vtkIdList> pointIds = vtkSmartPointer<vtkIdList>::New();
 pointIds->SetNumberOfIds(numPoints);
 for (vtkIdType i = 0; i < numPoints; ++i)
 {
    pointIds->SetId(i, i);
 }

   // create a vtkCellArray from this list
  vtkSmartPointer<vtkCellArray> polyPoint = vtkSmartPointer<vtkCellArray>::New();
  polyPoint->InsertNextCell(pointIds);
 
   // give the points and cells to the final poly data
  myPolyData->SetPoints(points);
  myPolyData->SetVerts(polyPoint);

```

So, the points are used to construct the cell(s). It seems all points are “within” one cell. But not sure if that is proper semantics.

I believe I read somewhere that in order to render any data, the data need to be in “cells”.

I guess this small example goes to the core of how primitive data is represented in vtk, in order to be visualized, so, time to read the manual(!)

---

<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: [August 3, 2023, 4:28pm UTC](https://discourse.vtk.org/t/vtkpointsource-vtkpoints/12082/3 "2023-08-03T16:28:16Z")

</div>

Hello,

Please:

1. Post the link to the original post as additional info there may benefit others;

2. Enclose the code between two ``` to have it appropriately formatted by the markdown engine;

3. Mark the solution as solution so others with the same problem as yours promptly find the answer to their needs.

thanks,

PC

---

<div class="post-metadata">

### Author: ![totte\_karlsson](https://discourse.vtk.org/user_avatar/discourse.vtk.org/totte_karlsson/32/4281_2.png) [@totte\_karlsson](https://discourse.vtk.org/u/totte_karlsson)
#### Post date: [August 3, 2023, 5:23pm UTC](https://discourse.vtk.org/t/vtkpointsource-vtkpoints/12082/4 "2023-08-03T17:23:04Z")

</div>

Thanks Paulo, I cleaned up the question/answer.

---

<div class="post-metadata">

### Author: ![Charles\_Gueunet](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charles_gueunet/32/239_2.png) [@Charles\_Gueunet](https://discourse.vtk.org/u/Charles_Gueunet)
#### Post date: [August 31, 2023, 7:38am UTC](https://discourse.vtk.org/t/vtkpointsource-vtkpoints/12082/5 "2023-08-31T07:38:45Z")

</div>

@totte_karlsson glad you found this answer. I would like to complete a bit, because since then VTK has evolved.  
If memory is important to you, it is now possible to instantiate a `vtkPointSet` instead of a `vtkPolyData`, see the related discussion [here](https://discourse.vtk.org/t/proposal-adding-a-vtkpointcloud-data-structure/3872/17)
