Reading more than 2,147,483,647 points in legacy VTK format
I think there is an error in
VTK/IO/Legacy/vtkStructuredPointsReader.cxx. When I try to read a VTK file (
STRUCTURED_POINTS) with more than 2,147,483,647 points, I get the following error: Number of points don't match data values!
The error is clearly raised by the following lines in the file:
if (npts != numPts) ... vtkErrorMacro(<< "Number of points don't match data values!");
Also, somewhere in the file the following code:
vtkIdType numPts = 0, ... ... int dim; ... numPts = dim * dim * dim;
exists. I think the problem is that while
numPts is a 64 bit integer in my case (checked), it is calculated by multiplying three 32 bit integers, which will be of the same type, and then is moved into the 64 bit
numPts variable. When the results is over 2,147,483,647, it is truncated before moving to
numPts, thus the test fails and the error is raised.
If I am right, the fix is really easy;
dim can be defined as an array of
dim can be cast into
vtkIdType and then multiplied.
Can someone please confirm and fix this?