------------------------------------------------------------------------------
| 1610 | |
| 1611 | //------------------------------------------------------------------------------ |
| 1612 | void vtkNetCDFCFReader::AddStructuredCells( |
| 1613 | vtkUnstructuredGrid* unstructuredOutput, const int extent[6]) |
| 1614 | { |
| 1615 | vtkIdType numPoints[3]; |
| 1616 | numPoints[0] = extent[1] - extent[0] + 1; |
| 1617 | numPoints[1] = extent[3] - extent[2] + 1; |
| 1618 | numPoints[2] = extent[5] - extent[4] + 1; |
| 1619 | |
| 1620 | vtkIdType numCells[3]; |
| 1621 | numCells[0] = numPoints[0] - 1; |
| 1622 | numCells[1] = numPoints[1] - 1; |
| 1623 | numCells[2] = numPoints[2] - 1; |
| 1624 | |
| 1625 | vtkIdType nextPointRow = numPoints[0]; |
| 1626 | vtkIdType nextPointSlab = nextPointRow * numPoints[1]; |
| 1627 | |
| 1628 | bool extentIs2D = (numCells[2] < 1); |
| 1629 | |
| 1630 | if (extentIs2D) |
| 1631 | { |
| 1632 | vtkIdType totalNumCells = numCells[0] * numCells[1]; |
| 1633 | unstructuredOutput->Allocate(totalNumCells); |
| 1634 | vtkCellArray* cells = unstructuredOutput->GetCells(); |
| 1635 | cells->AllocateEstimate(totalNumCells, 4); |
| 1636 | |
| 1637 | for (int j = 0; j < numCells[1]; j++) |
| 1638 | { |
| 1639 | vtkIdType rowStart = j * nextPointRow; |
| 1640 | for (int i = 0; i < numCells[0]; i++) |
| 1641 | { |
| 1642 | vtkIdType lowCellPoint = rowStart + i; |
| 1643 | |
| 1644 | vtkIdType pointIds[4]; |
| 1645 | pointIds[0] = lowCellPoint; |
| 1646 | pointIds[1] = lowCellPoint + 1; |
| 1647 | pointIds[2] = lowCellPoint + nextPointRow + 1; |
| 1648 | pointIds[3] = lowCellPoint + nextPointRow; |
| 1649 | |
| 1650 | unstructuredOutput->InsertNextCell(VTK_QUAD, 4, pointIds); |
| 1651 | } |
| 1652 | } |
| 1653 | } |
| 1654 | else // !extentIs2D |
| 1655 | { |
| 1656 | vtkIdType totalNumCells = numCells[0] * numCells[1] * numCells[2]; |
| 1657 | unstructuredOutput->Allocate(totalNumCells); |
| 1658 | vtkCellArray* cells = unstructuredOutput->GetCells(); |
| 1659 | cells->AllocateEstimate(totalNumCells, 8); |
| 1660 | |
| 1661 | for (int k = 0; k < numCells[2]; k++) |
| 1662 | { |
| 1663 | vtkIdType slabStart = k * nextPointSlab; |
| 1664 | for (int j = 0; j < numCells[1]; j++) |
| 1665 | { |
| 1666 | vtkIdType rowStart = slabStart + j * nextPointRow; |
| 1667 | for (int i = 0; i < numCells[0]; i++) |
| 1668 | { |
| 1669 | vtkIdType lowCellPoint = rowStart + i; |
no test coverage detected