Commit 8563476f authored by Andreas Buykx's avatar Andreas Buykx

Minor fixes to computation of divisions

Fixes an error in finding the maximum length.
The return value could be negative because of
integer multiplication overflow for 2 or more
large divs values.
parent 4242f492
......@@ -484,6 +484,7 @@ ComputeDivisions(vtkIdType totalBins, double bounds[6], int divs[3]) const
if ( lengths[i] > max )
{
maxIdx = i;
max = lengths[i];
}
if ( lengths[i] > zeroDetectionTolerance )
{
......@@ -539,9 +540,8 @@ ComputeDivisions(vtkIdType totalBins, double bounds[6], int divs[3]) const
bounds[2*i+1] = this->MaxPnt[i] + delta;
}
}
// Safe to return
return (divs[0] * divs[1] * divs[2]);
assert( static_cast<vtkIdType>(divs[0])*divs[1]*divs[2] < totalBins );
return static_cast<vtkIdType>(divs[0])*divs[1]*divs[2];
}
// ---------------------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment