Initialize vtkPolyData coordinates using vtkFloatArray with three components

I want to initialize a vtkPolyData instance using a vtkFloatArray whose three components describe the Cartesian coordinates of the points of a point cloud.

Currently, I create a vtkPoints instance and do the following:

vtkNew<vtkPoints> points;
for (unsigned int i = 0; i < 1000; i++)
	points->InsertNextPoint(i, 2*i, 3*i);  // arbitrarily chosen

vtkNew<vtkPolyData> polyData;

However, I want to use a vtkFloatArray to store the coordinates as the coordinates are already stored in memory at float *coordPtr.

vtkNew<vtkFloatArray> coords;
coords->SetNumberOfComponents(3); // x, y, and z in Cartesian space
coords->SetArray(coordPtr, 1000, 1);

How can I link the vtkPoints instance to coords or can I set the coordinates of polyData directly using coords? The overall goal is to visualize a 3D point cloud.

You can call vtkPoints::SetDataType(VTK_FLOAT) to have the array you want.

I would advise trying to avoid to use InsertNextPoint if you know the final size up front because the internal array will be resized / reallocated pretty often. You should call in this order:

vtkNew<vtkPoints> points;
// insert points using SetPoint API

If you already have a coords array that you want to put inside your vtkPoints, you can use the vtkPoints::SetData(vtkDataArray*) API.