Add points to polyline

Hello,
I have a vtkPoints and a vtkPolyline. And I would like to add a point to my vtkPoints with the points connected by lines. I manage to do it at initialization but when I am trying to do it later, it doesn’t work. Do you know how to do it ?
Thanks for your help

I don’t really understand what you intend to do. Are you working within a vtkDataSet such as vtkPolyData or vtkUnstructuredGrid? Are you editing the points within your vtkPolyLine and are wondering why they wouldn’t update in a vtkPoints outside of it?

For now I am using vtkPolyData but I could use ‘vtkUnstructuredGrid’ instead. I want to do a InsertNexPoint to my vtkPoints and at the same time update my vtkPolyline to add a line between the lastPoint and the newPoint.

All right, you won’t be able to do that in a clean way. You cannot add points to a cell that is already in storage in a vtkPolyData (nor vtkUnstructuredGrid). What you could do is deal with vtkLine instead of vtkPolyLine, and add a line using vtkPolyData::InsertNextCell.

Another solution would be to not insert the full poly line until it is finalized.

Do you have a short example ? vtkPolyData::InsertNexCell is not very clear for me

You can find the documentation of vtkPolyData here .

vtkNew<vtkPoints> points;
vtkNew<vtkPolyData> polyData;
vtkNew<vtkIdList> polyLinePointIds;

FillPoints(points); // a function setting points
FillPolyLinePointIds(polyLinePointIds); // extracting the points that are in my polyline
polyData->SetPoints(points);
polyData->InsertNextCell(VTK_POLY_LINE, polyLinePointIds);