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

Method GetArrayData

IO/NetCDF/vtkNetCDFUGRIDReader.cxx:873–914  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

871
872//--------------------------------------------------------------------------------------------------
873vtkSmartPointer<vtkDataArray> vtkNetCDFUGRIDReader::GetArrayData(
874 int var, std::size_t time, std::size_t size)
875{
876 nc_type type{ NC_NAT };
877 if (!this->CheckError(nc_inq_vartype(this->NcId, var, &type)))
878 {
879 return nullptr;
880 }
881
882 DataArrayExtractor worker{};
883 using Dispatcher = vtkArrayDispatch::DispatchByValueType<vtkArrayDispatch::AllTypes>;
884
885 auto output(MakeDataArray(type));
886 if (!output)
887 {
888 vtkErrorMacro("Unsupported data array type");
889 return nullptr;
890 }
891
892 output->SetName(this->GetVariableName(var).c_str());
893
894 // Check if variable is time-dependent
895 int varDimCount{};
896 if (!this->CheckError(nc_inq_varndims(this->NcId, var, &varDimCount)))
897 {
898 vtkErrorMacro(
899 "Could not obtain number of dimensions for variable " << this->GetVariableName(var));
900 return nullptr;
901 }
902 const bool isTemporal = (varDimCount > 1);
903
904 int result{ NC_NOERR };
905 Dispatcher::Execute(
906 output, worker, this->NcId, var, time, size, isTemporal, this->ReplaceFillValueWithNan, result);
907
908 if (!this->CheckError(result))
909 {
910 return nullptr;
911 }
912
913 return output;
914}
915
916//--------------------------------------------------------------------------------------------------
917void vtkNetCDFUGRIDReader::PrintSelf(ostream& os, vtkIndent indent)

Callers 1

FillArraysMethod · 0.95

Calls 8

CheckErrorMethod · 0.95
GetVariableNameMethod · 0.95
nc_inq_vartypeFunction · 0.85
MakeDataArrayFunction · 0.85
nc_inq_varndimsFunction · 0.85
ExecuteFunction · 0.50
SetNameMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected