------------------------------------------------------------------------------
| 706 | |
| 707 | //------------------------------------------------------------------------------ |
| 708 | int vtkNetCDFReader::FillVariableDimensions(int ncFD) |
| 709 | { |
| 710 | int numVar = this->GetNumberOfVariableArrays(); |
| 711 | this->VariableDimensions->SetNumberOfValues(numVar); |
| 712 | this->AllDimensions->SetNumberOfValues(0); |
| 713 | |
| 714 | for (int i = 0; i < numVar; i++) |
| 715 | { |
| 716 | // Get the dimensions of this variable and encode them in a string. |
| 717 | const char* varName = this->GetVariableArrayName(i); |
| 718 | int varId, numDim, dimIds[NC_MAX_VAR_DIMS]; |
| 719 | CALL_NETCDF_INT(this->Accessor->inq_varid(ncFD, varName, &varId)); |
| 720 | CALL_NETCDF_INT(this->Accessor->inq_varndims(ncFD, varId, &numDim)); |
| 721 | CALL_NETCDF_INT(this->Accessor->inq_vardimid(ncFD, varId, dimIds)); |
| 722 | std::string dimEncoding("("); |
| 723 | for (int j = 0; j < numDim; j++) |
| 724 | { |
| 725 | if ((j == 0) && (this->IsTimeDimension(ncFD, dimIds[j]))) |
| 726 | continue; |
| 727 | char dimName[NC_MAX_NAME + 1]; |
| 728 | CALL_NETCDF_INT(this->Accessor->inq_dimname(ncFD, dimIds[j], dimName)); |
| 729 | if (dimEncoding.size() > 1) |
| 730 | dimEncoding += ", "; |
| 731 | dimEncoding += dimName; |
| 732 | } |
| 733 | dimEncoding += ")"; |
| 734 | // Store all dimensions in the VariableDimensions array. |
| 735 | this->VariableDimensions->SetValue(i, dimEncoding.c_str()); |
| 736 | // Store unique dimensions in the AllDimensions array. |
| 737 | bool unique = true; |
| 738 | for (vtkIdType j = 0; j < this->AllDimensions->GetNumberOfValues(); j++) |
| 739 | { |
| 740 | if (this->AllDimensions->GetValue(j) == dimEncoding) |
| 741 | { |
| 742 | unique = false; |
| 743 | break; |
| 744 | } |
| 745 | } |
| 746 | if (unique && dimEncoding != "()") |
| 747 | this->AllDimensions->InsertNextValue(dimEncoding); |
| 748 | } |
| 749 | |
| 750 | return 1; |
| 751 | } |
| 752 | |
| 753 | //------------------------------------------------------------------------------ |
| 754 | int vtkNetCDFReader::IsTimeDimension(int ncFD, int dimId) |
no test coverage detected