--------------------------------------------------------------------------------------------------
| 51 | |
| 52 | //-------------------------------------------------------------------------------------------------- |
| 53 | int vtkNetCDFUGRIDReader::RequestInformation( |
| 54 | vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector) |
| 55 | { |
| 56 | if (!this->Open()) |
| 57 | { |
| 58 | vtkErrorMacro("Can not open file."); |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | if (!this->ParseHeader()) |
| 63 | { |
| 64 | vtkErrorMacro("Can not parse header."); |
| 65 | this->Close(); |
| 66 | return 0; |
| 67 | } |
| 68 | |
| 69 | vtkInformation* outInfo = outputVector->GetInformationObject(0); |
| 70 | |
| 71 | // look for the "time" dimension in the top level block, it should contain timestep count |
| 72 | // of data arrays. |
| 73 | int timeDimId{}; |
| 74 | if (nc_inq_dimid(this->NcId, "time", &timeDimId) == NC_NOERR) |
| 75 | { |
| 76 | std::size_t timeStepCount{}; |
| 77 | if (!this->CheckError(nc_inq_dimlen(this->NcId, timeDimId, &timeStepCount))) |
| 78 | { |
| 79 | this->Close(); |
| 80 | return 0; |
| 81 | } |
| 82 | |
| 83 | int timeVarId{}; |
| 84 | if (!this->CheckError(nc_inq_varid(this->NcId, "time", &timeVarId))) |
| 85 | { |
| 86 | vtkErrorMacro("`time` dimension is defined, but `time` variable is not."); |
| 87 | this->Close(); |
| 88 | return 0; |
| 89 | } |
| 90 | |
| 91 | this->TimeSteps.resize(timeStepCount); |
| 92 | if (!this->CheckError(nc_get_var_double(this->NcId, timeVarId, this->TimeSteps.data()))) |
| 93 | { |
| 94 | this->Close(); |
| 95 | return 0; |
| 96 | } |
| 97 | |
| 98 | const std::array<double, 2> range = { this->TimeSteps.front(), this->TimeSteps.back() }; |
| 99 | |
| 100 | outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), this->TimeSteps.data(), |
| 101 | static_cast<int>(this->TimeSteps.size())); |
| 102 | outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), range.data(), 2); |
| 103 | } |
| 104 | else |
| 105 | { |
| 106 | outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_STEPS()); |
| 107 | outInfo->Remove(vtkStreamingDemandDrivenPipeline::TIME_RANGE()); |
| 108 | } |
| 109 | |
| 110 | outInfo->Set(CAN_HANDLE_PIECE_REQUEST(), 1); |
nothing calls this directly
no test coverage detected