--------------------------------------------------------------------------------------------------
| 871 | |
| 872 | //-------------------------------------------------------------------------------------------------- |
| 873 | vtkSmartPointer<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 | //-------------------------------------------------------------------------------------------------- |
| 917 | void vtkNetCDFUGRIDReader::PrintSelf(ostream& os, vtkIndent indent) |
no test coverage detected