------------------------------------------------------------------------------
| 1611 | |
| 1612 | //------------------------------------------------------------------------------ |
| 1613 | void vtkStructuredAMRGridConnectivity::EstablishNeighbors(int i, int j) |
| 1614 | { |
| 1615 | int ext1[6]; /* extent for grid i */ |
| 1616 | int ext2[6]; /* extent for grid j */ |
| 1617 | |
| 1618 | // STEP 0: Compute the level difference between the two grids |
| 1619 | int levelDiff = std::abs((this->GridLevels[j] - this->GridLevels[i])); |
| 1620 | |
| 1621 | // STEP 1: If this is a balanced refinement, check the level difference |
| 1622 | if (this->BalancedRefinement) |
| 1623 | { |
| 1624 | if (levelDiff > 1) |
| 1625 | { |
| 1626 | // If the refinement is balanced, adjacent grids are guaranteed to have |
| 1627 | // a level difference of 1, hence, we skip grids that have bigger level |
| 1628 | // difference. |
| 1629 | return; |
| 1630 | } |
| 1631 | } // END if balanced refinement |
| 1632 | |
| 1633 | // NOTE: To establish neighboring connectivity, the grids must be coarsened |
| 1634 | // or refined at the same level. By convention, we always normalize to the |
| 1635 | // level of grid j. |
| 1636 | int normalizedLevel = this->GridLevels[j]; |
| 1637 | |
| 1638 | // STEP 2: Get normalized extents, i.e., extents at the same level |
| 1639 | if (this->GridLevels[i] == this->GridLevels[j]) |
| 1640 | { |
| 1641 | // Grids at the same level, connectivity can be determined directly |
| 1642 | // by acquiring each grid extent. |
| 1643 | this->GetGridExtent(i, ext1); |
| 1644 | this->GetGridExtent(j, ext2); |
| 1645 | } // END if the grids are at the same level |
| 1646 | else if (this->GridLevels[i] < this->GridLevels[j]) |
| 1647 | { |
| 1648 | // Grid "i" is coarser than grid "j" |
| 1649 | this->GetRefinedExtent(i, this->GridLevels[i], this->GridLevels[j], ext1); |
| 1650 | this->GetGridExtent(j, ext2); |
| 1651 | } |
| 1652 | else if (this->GridLevels[i] > this->GridLevels[j]) |
| 1653 | { |
| 1654 | // Grid "i" is finer than grid "j" |
| 1655 | this->GetCoarsenedExtent(i, this->GridLevels[i], this->GridLevels[j], ext2); |
| 1656 | this->GetGridExtent(j, ext2); |
| 1657 | } |
| 1658 | else |
| 1659 | { |
| 1660 | // Code should not reach here! |
| 1661 | vtkErrorMacro("Code should not reach here!"); |
| 1662 | } |
| 1663 | |
| 1664 | // STEP 3: Get the whole extent at the normalized level |
| 1665 | int myWholeExtent[6]; |
| 1666 | this->GetWholeExtentAtLevel(normalizedLevel, myWholeExtent); |
| 1667 | |
| 1668 | // STEP 4: Use vtkStructuredGridConnectivity to establish neighbors |
| 1669 | vtkStructuredGridConnectivity* gridConnectivity = vtkStructuredGridConnectivity::New(); |
| 1670 | gridConnectivity->SetWholeExtent(myWholeExtent); |
no test coverage detected