------------------------------------------------------------------------------
| 581 | |
| 582 | //------------------------------------------------------------------------------ |
| 583 | int vtkNetCDFCFReader::vtkDependentDimensionInfo::LoadBoundsVariable( |
| 584 | int ncFD, int varId, vtkDoubleArray* coords) |
| 585 | { |
| 586 | int dimIds[3]; |
| 587 | CALL_NETCDF_GW(this->Accessor->inq_vardimid(ncFD, varId, dimIds)); |
| 588 | |
| 589 | size_t dimSizes[3]; |
| 590 | for (int i = 0; i < 3; i++) |
| 591 | { |
| 592 | CALL_NETCDF_GW(this->Accessor->inq_dimlen(ncFD, dimIds[i], &dimSizes[i])); |
| 593 | } |
| 594 | |
| 595 | if (dimSizes[2] != 4) |
| 596 | { |
| 597 | vtkGenericWarningMacro(<< "Expected 2D dependent coordinate bounds to have" |
| 598 | << " 4 entries in final dimension. Instead has " << dimSizes[2]); |
| 599 | return 0; |
| 600 | } |
| 601 | |
| 602 | // Bounds are stored as 4-tuples for every cell. Tuple entries 0 and 1 |
| 603 | // connect to the cell in the -i topological direction. Tuple entries 0 and 3 |
| 604 | // connect to the cell in the -j topological direction. |
| 605 | std::vector<double> boundsData(dimSizes[0] * dimSizes[1] * 4); |
| 606 | if (!boundsData.empty()) |
| 607 | { |
| 608 | CALL_NETCDF_GW(this->Accessor->get_var_double(ncFD, varId, &boundsData.at(0))); |
| 609 | } |
| 610 | |
| 611 | // The coords array are the coords at the points. There is one more point |
| 612 | // than cell in each topological direction. |
| 613 | int numComponents = static_cast<int>(dimSizes[1]); |
| 614 | vtkIdType numTuples = static_cast<vtkIdType>(dimSizes[0]); |
| 615 | coords->SetNumberOfComponents(numComponents + 1); |
| 616 | coords->SetNumberOfTuples(numTuples + 1); |
| 617 | |
| 618 | // Copy from the bounds data to the coordinates data. Most values will |
| 619 | // be copied from the bound's 0'th tuple entry. Values at the extremes |
| 620 | // will be copied from other entries. |
| 621 | for (vtkIdType j = 0; j < numTuples; j++) |
| 622 | { |
| 623 | for (int i = 0; i < numComponents; i++) |
| 624 | { |
| 625 | coords->SetComponent(j, i, boundsData[(j * numComponents + i) * 4 + 0]); |
| 626 | } |
| 627 | coords->SetComponent(j, numComponents, boundsData[((j + 1) * numComponents - 1) * 4 + 1]); |
| 628 | } |
| 629 | for (int i = 0; i < numComponents; i++) |
| 630 | { |
| 631 | coords->SetComponent(numTuples, i, boundsData[((numTuples - 1) * numComponents) * 4 + 2]); |
| 632 | } |
| 633 | coords->SetComponent( |
| 634 | numTuples, numComponents, boundsData[(numTuples * numComponents - 1) * 4 + 3]); |
| 635 | |
| 636 | return 1; |
| 637 | } |
| 638 | |
| 639 | //------------------------------------------------------------------------------ |
| 640 | int vtkNetCDFCFReader::vtkDependentDimensionInfo::LoadUnstructuredBoundsVariable( |
no test coverage detected