Parallel/DIY/vtkDIYGhostUtilities.cxx
bool SynchronizeGridExtents(const ImageDataBlockStructure& localBlockStructure,
  ImageDataBlockStructure& blockStructure)
{
  // Images are spatially defined by origin, spacing, dimension, and orientation.
  // We make sure that they all connect well using those values.
  const VectorType& localOrigin = localBlockStructure.Origin;
  const VectorType& localSpacing = localBlockStructure.Spacing;
  const QuaternionType& localQ = localBlockStructure.OrientationQuaternion;
  int localDim = localBlockStructure.DataDimension;

  const ExtentType& extent = blockStructure.Extent;
  ExtentType& shiftedExtent = blockStructure.ShiftedExtent;
  const QuaternionType& q = blockStructure.OrientationQuaternion;
  const VectorType& spacing = blockStructure.Spacing;
  int dim = blockStructure.DataDimension;

  // We skip if dimension, spacing or quaternions don't match
  // spacing == localSpacing <=> dot(spacing, localSpacing) == norm(localSpacing)^2
  // q == localQ <=> dot(q, localQ) == 1 (both are unitary quaternions)
  if (extent[0] > extent[1] || extent[2] > extent[3] || extent[4] > extent[5] ||
    dim != localDim ||
    !vtkMathUtilities::NearlyEqual(
      vtkMath::Dot(spacing, localSpacing), vtkMath::SquaredNorm(localSpacing)) ||
    !(std::fabs(vtkMath::Dot<double, 4>(q.GetData(), localQ.GetData()) - 1.0) < VTK_DBL_EPSILON))
  {
    return false;
  }

  // We reposition extent all together so we have a unified extent framework with the current
  // neighbor.
  const VectorType& origin = blockStructure.Origin;
  int originDiff[3] = { static_cast<int>(std::lround((origin[0] - localOrigin[0]) / spacing[0])),
    static_cast<int>(std::lround((origin[1] - localOrigin[1]) / spacing[1])),
    static_cast<int>(std::lround((origin[2] - localOrigin[2]) / spacing[2])) };

  shiftedExtent[0] = extent[0] + originDiff[0];
  shiftedExtent[1] = extent[1] + originDiff[0];
  shiftedExtent[2] = extent[2] + originDiff[1];
  shiftedExtent[3] = extent[3] + originDiff[1];
  shiftedExtent[4] = extent[4] + originDiff[2];
  shiftedExtent[5] = extent[5] + originDiff[2];

  return true;
}
//----------------------------------------------------------------------------
/**
 * Function to be overloaded for each supported input grid data sets.
 * This function will return true if 2 input block structures are adjacent, false otherwise.
 */
Function to be overloaded for each supported input grid data sets.
This function will return true if 2 input block structures are adjacent, false otherwise.
Function to be overloaded for each supported input grid data sets . This function will return true if 2 input block structures are adjacent false otherwise .
bool SynchronizeGridExtents(const ImageDataBlockStructure& localBlockStructure,
  ImageDataBlockStructure& blockStructure)
{
  const VectorType& localOrigin = localBlockStructure.Origin;
  const VectorType& localSpacing = localBlockStructure.Spacing;
  const QuaternionType& localQ = localBlockStructure.OrientationQuaternion;
  int localDim = localBlockStructure.DataDimension;
  const ExtentType& extent = blockStructure.Extent;
  ExtentType& shiftedExtent = blockStructure.ShiftedExtent;
  const QuaternionType& q = blockStructure.OrientationQuaternion;
  const VectorType& spacing = blockStructure.Spacing;
  int dim = blockStructure.DataDimension;
  if (extent[0] > extent[1] || extent[2] > extent[3] || extent[4] > extent[5] ||
    dim != localDim ||
    !vtkMathUtilities::NearlyEqual(
      vtkMath::Dot(spacing, localSpacing), vtkMath::SquaredNorm(localSpacing)) ||
    !(std::fabs(vtkMath::Dot<double, 4>(q.GetData(), localQ.GetData()) - 1.0) < VTK_DBL_EPSILON))
  {
    return false;
  }
  const VectorType& origin = blockStructure.Origin;
  int originDiff[3] = { static_cast<int>(std::lround((origin[0] - localOrigin[0]) / spacing[0])),
    static_cast<int>(std::lround((origin[1] - localOrigin[1]) / spacing[1])),
    static_cast<int>(std::lround((origin[2] - localOrigin[2]) / spacing[2])) };
  shiftedExtent[0] = extent[0] + originDiff[0];
  shiftedExtent[1] = extent[1] + originDiff[0];
  shiftedExtent[2] = extent[2] + originDiff[1];
  shiftedExtent[3] = extent[3] + originDiff[1];
  shiftedExtent[4] = extent[4] + originDiff[2];
  shiftedExtent[5] = extent[5] + originDiff[2];
  return true;
}
bool SynchronizeGridExtents ( const ImageDataBlockStructure & localBlockStructure , ImageDataBlockStructure & blockStructure ) { const VectorType & localOrigin = localBlockStructure . Origin ; const VectorType & localSpacing = localBlockStructure . Spacing ; const QuaternionType & localQ = localBlockStructure . OrientationQuaternion ; int localDim = localBlockStructure . DataDimension ; const ExtentType & extent = blockStructure . Extent ; ExtentType & shiftedExtent = blockStructure . ShiftedExtent ; const QuaternionType & q = blockStructure . OrientationQuaternion ; const VectorType & spacing = blockStructure . Spacing ; int dim = blockStructure . DataDimension ; if ( extent [ 0 ] > extent [ 1 ] || extent [ 2 ] > extent [ 3 ] || extent [ 4 ] > extent [ 5 ] || dim != localDim || ! vtkMathUtilities :: NearlyEqual ( vtkMath :: Dot ( spacing , localSpacing ) , vtkMath :: SquaredNorm ( localSpacing ) ) || ! ( std :: fabs ( vtkMath :: Dot < double , 4 > ( q . GetData ( ) , localQ . GetData ( ) ) - 1.0 ) < VTK_DBL_EPSILON ) ) { return false ; } const VectorType & origin = blockStructure . Origin ; int originDiff [ 3 ] = { static_cast < int > ( std :: lround ( ( origin [ 0 ] - localOrigin [ 0 ] ) / spacing [ 0 ] ) ) , static_cast < int > ( std :: lround ( ( origin [ 1 ] - localOrigin [ 1 ] ) / spacing [ 1 ] ) ) , static_cast < int > ( std :: lround ( ( origin [ 2 ] - localOrigin [ 2 ] ) / spacing [ 2 ] ) ) } ; shiftedExtent [ 0 ] = extent [ 0 ] + originDiff [ 0 ] ; shiftedExtent [ 1 ] = extent [ 1 ] + originDiff [ 0 ] ; shiftedExtent [ 2 ] = extent [ 2 ] + originDiff [ 1 ] ; shiftedExtent [ 3 ] = extent [ 3 ] + originDiff [ 1 ] ; shiftedExtent [ 4 ] = extent [ 4 ] + originDiff [ 2 ] ; shiftedExtent [ 5 ] = extent [ 5 ] + originDiff [ 2 ] ; return true ; }
Function to be overloaded for each supported input grid data sets.
Function to be overloaded for each supported input grid data sets .
// Images are spatially defined by origin, spacing, dimension, and orientation. // We make sure that they all connect well using those values. // We skip if dimension, spacing or quaternions don't match // spacing == localSpacing <=> dot(spacing, localSpacing) == norm(localSpacing)^2 // q == localQ <=> dot(q, localQ) == 1 (both are unitary quaternions) // We reposition extent all together so we have a unified extent framework with the current // neighbor.