VTK/Tutorials/VtkIdType
From KitwarePublic
Jump to navigationJump to search
Confused why you can't use ints or unsigned ints in some places?
Here is an example:
vtkSmartPointer<vtkCellArray> vertices = vtkSmartPointer<vtkCellArray>::New();
for ( unsigned int i = 0; i < polydata->GetNumberOfPoints(); ++i )
{
vertices->InsertNextCell(1,i);
}
The error generated is:
error: invalid conversion from 'unsigned int' to 'const vtkIdType*'
To fix this, you need to put the value into a vtkIdType object, as follows:
vtkSmartPointer<vtkCellArray> vertices = vtkSmartPointer<vtkCellArray>::New();
for ( unsigned int i = 0; i < polydata->GetNumberOfPoints(); ++i )
{
vtkIdType id[1];
id[0] = i;
vertices->InsertNextCell(1,id);
}