Bug in vtkTriangleStrip::DecomposeStrip
I found a bug in DecomposeStrip of vtkTriangleStrip. Look at this example:
#include <vtkSuperquadricSource.h>
#include <vtkPolyDataWriter.h>
#include <vtkIntArray.h>
#include <vtkCellArray.h>
#include <vtkNew.h>
#include <vtkTriangleStrip.h>
int main(int argc, char const *argv[]) {
vtkNew<vtkSuperquadricSource> sq;
sq->ToroidalOff();
sq->Update();
vtkNew<vtkPolyData> pd;
pd->DeepCopy(sq->GetOutput());
vtkIdType numCells = pd->GetNumberOfCells();
vtkNew<vtkCellArray> cells;
vtkCellArray *strips = pd->GetStrips();
vtkIdType n;
vtkIdType *pts;
for (strips->InitTraversal(); strips->GetNextCell(n, pts);) {
cells->Reset();
vtkTriangleStrip::DecomposeStrip(n, pts, cells);
for (cells->InitTraversal(); cells->GetNextCell(n, pts);) {
pd->InsertNextCell(VTK_TRIANGLE, n, pts);
numCells++;
}
}
for (int i = 0; i < numCells; i++) {
int type = pd->GetCellType(i);
if (type != VTK_POLYGON && type != VTK_QUAD && type != VTK_TRIANGLE) {
pd->DeleteCell(i);
}
}
pd->RemoveDeletedCells();
vtkNew<vtkPolyDataWriter> writer;
writer->SetFileName("qs.vtk");
writer->SetInputData(pd.GetPointer());
writer->Update();
return 0;
}
DecomposeStrip produces triangles without an area. You can see it in the attached image.