MantisBT - VTK
View Issue Details
0001504VTK(No Category)public2005-01-20 11:182016-08-12 09:54
Jeff Lee 
Kitware Robot 
normalmajoralways
closedmoved 
 
 
0001504: potential for arithmetic exception in vtkPointLocator
On 2d datasets with very small dataset bounds in a coordinate direction, there can be arithmetic exception (SIGFPE) problems in the method GetOverlappingBuckets. When the width (in x, y or z) of the dataset is small but nonzero (BuildLocator accounts for zero width), the algorithm used in GetOverlappingBuckets can fail when trying to cast a large double to an int. The proposed fix is to do the range determination in double precision, then clamp the values, then do the cast and populate the buckets... Here is the method.

  int i, j, k, nei[3];
  int minLevel[3], maxLevel[3];
  double mindLevel[3], maxdLevel[3];
  // Initialize
  buckets->Reset();

  // Determine the range of indices in each direction
  for (i=0; i < 3; i++)
    {
      mindLevel[i] = this->Divisions[i]*((x[i]-dist) - this->Bounds[2*i])/(this->Bounds[2*i+1] - this->Bounds[2*i]);
      maxdLevel[i] = this->Divisions[i]*((x[i]+dist) - this->Bounds[2*i]) / (this->Bounds[2*i+1] - this->Bounds[2*i]);

      // clamp values
      if ( mindLevel[i] < 0 )
        {
        mindLevel[i] = 0;
        }
      if ( maxdLevel[i] >= this->Divisions[i] )
        {
        maxdLevel[i] = this->Divisions[i] - 1;
        }

      // now safe to cast
      minLevel[i] = (int)mindLevel[i];
      maxLevel[i] = (int)maxdLevel[i];
    }

  for ( i= minLevel[0]; i <= maxLevel[0]; i++ )
    {
    for ( j= minLevel[1]; j <= maxLevel[1]; j++ )
      {
      for ( k= minLevel[2]; k <= maxLevel[2]; k++ )
        {
        if ( i < (ijk[0]-level) || i > (ijk[0]+level) ||
             j < (ijk[1]-level) || j > (ijk[1]+level) ||
             k < (ijk[2]-level) || k > (ijk[2]+level))
          {
          nei[0]=i; nei[1]=j; nei[2]=k;
          buckets->InsertNextPoint(nei);
          }
        }
      }
    }
No tags attached.
Issue History
2010-09-07 13:47François BertelAssigned ToFrançois Bertel =>
2011-06-16 13:11Zack GalbreathCategory => (No Category)
2016-08-12 09:54Kitware RobotNote Added: 0036763
2016-08-12 09:54Kitware RobotStatusexpired => closed
2016-08-12 09:54Kitware RobotResolutionopen => moved
2016-08-12 09:54Kitware RobotAssigned To => Kitware Robot

Notes
(0036763)
Kitware Robot   
2016-08-12 09:54   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current VTK Issues page linked in the banner at the top of this page.