Manually Create PolyData in vtk.js

The structure in memory remain the same but what we try to do in vtk.js is to prevent bad habits that will lead to lot of memory allocation / gc which are way more costly than in C++.

And for example the way you could create your cell array in vtk.js if you don’t know its size before hand could be as follow (The same can be used for the points or any other arrays…):

const cellArray = [];

for (let rrad = 0; rrad < 360; rrad++) {
    // [...]
    cellArray.push(3);
    cellArray.push(p1ind);
    cellArray.push(p2ind);
    cellArray.push(p3ind);
}

const triangles = vtk.Common.Core.vtkCellArray.newInstance({ values: Uint16Array.from(cellArray) });
polydata.setPolys(triangles);