vtk reeb graph memory access bugs and crashes
VTK reeb graph crashes on moderate sized date. valgrind identifies a number of issues, use of unitialized values (in bounds of malloc'd array and past the size of an stl vector), invalid access size 8 (from use of negative index).
here is data to reproduce: candidate_tris_8.vtp here is a plot of said data.
here is code, that I pulled out of the ctest and tweaked,
int main(int argc, char **argv)
{
const char *arrayName = "x";
int arrayId = 0;
vtkXMLPolyDataReader *pdr = vtkXMLPolyDataReader::New();
pdr->SetFileName(argv[1]);
pdr->Update();
vtkPolyData *pd = pdr->GetOutput();
vtkPointData *ptd = pd->GetPointData();
for (int i = 0; i < ptd->GetNumberOfArrays(); ++i)
{
if (strcmp(arrayName, ptd->GetArray(i)->GetName())==0)
{
cerr << "processing " << i << " " << ptd->GetArray(i)->GetName() << endl;
arrayId = i;
}
}
ptd->SetActiveScalars(arrayName);
vtkPolyDataToReebGraphFilter *rgf = vtkPolyDataToReebGraphFilter::New();
rgf->SetInputData(pd);
rgf->SetFieldId(arrayId);
vtkReebGraphSimplificationFilter *rgs = vtkReebGraphSimplificationFilter::New();
rgs->SetInputConnection(rgf->GetOutputPort());
rgs->SetSimplificationThreshold(0.01);
vtkReebGraphSurfaceSkeletonFilter *rgsf = vtkReebGraphSurfaceSkeletonFilter::New();
rgsf->SetInputData(0, pd);
rgsf->SetInputConnection(1, rgs->GetOutputPort());
rgsf->SetNumberOfSamples(5);
rgsf->Update();
vtkTable *skel = rgsf->GetOutput();
return 0;
}