MCPcopy Create free account
hub / github.com/Kitware/VTK / FillVariableDimensions

Method FillVariableDimensions

IO/NetCDF/vtkNetCDFReader.cxx:708–751  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

706
707//------------------------------------------------------------------------------
708int 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//------------------------------------------------------------------------------
754int vtkNetCDFReader::IsTimeDimension(int ncFD, int dimId)

Callers 1

UpdateMetaDataMethod · 0.95

Calls 14

GetVariableArrayNameMethod · 0.95
IsTimeDimensionMethod · 0.95
SetNumberOfValuesMethod · 0.45
inq_varidMethod · 0.45
inq_varndimsMethod · 0.45
inq_vardimidMethod · 0.45
inq_dimnameMethod · 0.45
sizeMethod · 0.45
SetValueMethod · 0.45
c_strMethod · 0.45
GetNumberOfValuesMethod · 0.45

Tested by

no test coverage detected