Common/DataModel/vtkUnstructuredGrid.cxx
//----------------------------------------------------------------------------
// Faster implementation of GetCellBounds().  Bounds are calculated without
// constructing a cell.
Faster implementation of GetCellBounds().  Bounds are calculated without
constructing a cell.
Faster implementation of GetCellBounds () . Bounds are calculated without constructing a cell .
void vtkUnstructuredGrid::GetCellBounds(vtkIdType cellId, double bounds[6])
{
  vtkIdType i;
  vtkIdType loc;
  double x[3];
  vtkIdType *pts, numPts;
  loc = this->Locations->GetValue(cellId);
  this->Connectivity->GetCell(loc,numPts,pts);
  if (numPts)
  {
    if ( this->Points->GetDataType() == VTK_FLOAT )
    {
      ComputeCellBounds(static_cast<float*>(this->Points->GetVoidPointer(0)),
                                            numPts,pts,bounds);
    }
    else if ( this->Points->GetDataType() == VTK_DOUBLE )
    {
      ComputeCellBounds(static_cast<double*>(this->Points->GetVoidPointer(0)),
                                             numPts,pts,bounds);
    }
    else
    {
      this->Points->GetPoint( pts[0], x );
      bounds[0] = x[0];
      bounds[2] = x[1];
      bounds[4] = x[2];
      bounds[1] = x[0];
      bounds[3] = x[1];
      bounds[5] = x[2];
      for (i=1; i < numPts; i++)
      {
        this->Points->GetPoint( pts[i], x );
        bounds[0] = (x[0] < bounds[0] ? x[0] : bounds[0]);
        bounds[1] = (x[0] > bounds[1] ? x[0] : bounds[1]);
        bounds[2] = (x[1] < bounds[2] ? x[1] : bounds[2]);
        bounds[3] = (x[1] > bounds[3] ? x[1] : bounds[3]);
        bounds[4] = (x[2] < bounds[4] ? x[2] : bounds[4]);
        bounds[5] = (x[2] > bounds[5] ? x[2] : bounds[5]);
      }
    }
  }
  else
  {
    vtkMath::UninitializeBounds(bounds);
  }
}
void vtkUnstructuredGrid :: GetCellBounds ( vtkIdType cellId , double bounds [ 6 ] ) { vtkIdType i ; vtkIdType loc ; double x [ 3 ] ; vtkIdType * pts , numPts ; loc = this -> Locations -> GetValue ( cellId ) ; this -> Connectivity -> GetCell ( loc , numPts , pts ) ; if ( numPts ) { if ( this -> Points -> GetDataType ( ) == VTK_FLOAT ) { ComputeCellBounds ( static_cast < float * > ( this -> Points -> GetVoidPointer ( 0 ) ) , numPts , pts , bounds ) ; } else if ( this -> Points -> GetDataType ( ) == VTK_DOUBLE ) { ComputeCellBounds ( static_cast < double * > ( this -> Points -> GetVoidPointer ( 0 ) ) , numPts , pts , bounds ) ; } else { this -> Points -> GetPoint ( pts [ 0 ] , x ) ; bounds [ 0 ] = x [ 0 ] ; bounds [ 2 ] = x [ 1 ] ; bounds [ 4 ] = x [ 2 ] ; bounds [ 1 ] = x [ 0 ] ; bounds [ 3 ] = x [ 1 ] ; bounds [ 5 ] = x [ 2 ] ; for ( i = 1 ; i < numPts ; i ++ ) { this -> Points -> GetPoint ( pts [ i ] , x ) ; bounds [ 0 ] = ( x [ 0 ] < bounds [ 0 ] ? x [ 0 ] : bounds [ 0 ] ) ; bounds [ 1 ] = ( x [ 0 ] > bounds [ 1 ] ? x [ 0 ] : bounds [ 1 ] ) ; bounds [ 2 ] = ( x [ 1 ] < bounds [ 2 ] ? x [ 1 ] : bounds [ 2 ] ) ; bounds [ 3 ] = ( x [ 1 ] > bounds [ 3 ] ? x [ 1 ] : bounds [ 3 ] ) ; bounds [ 4 ] = ( x [ 2 ] < bounds [ 4 ] ? x [ 2 ] : bounds [ 4 ] ) ; bounds [ 5 ] = ( x [ 2 ] > bounds [ 5 ] ? x [ 2 ] : bounds [ 5 ] ) ; } } } else { vtkMath :: UninitializeBounds ( bounds ) ; } }
Faster implementation of GetCellBounds().
Faster implementation of GetCellBounds () .
// carefully compute the bounds // Slightly faster paths for real types - not sure it's worth it