--------------------------------------------------------------------------------------------------
| 287 | |
| 288 | //-------------------------------------------------------------------------------------------------- |
| 289 | bool vtkNetCDFUGRIDReader::ParseHeader() |
| 290 | { |
| 291 | int varCount{}; |
| 292 | if (!this->CheckError(nc_inq_nvars(this->NcId, &varCount))) |
| 293 | { |
| 294 | return false; |
| 295 | } |
| 296 | |
| 297 | if (varCount == 0) |
| 298 | { |
| 299 | vtkErrorMacro("No variable defined in file."); |
| 300 | return false; |
| 301 | } |
| 302 | |
| 303 | std::vector<int> vars{}; |
| 304 | vars.resize(static_cast<std::size_t>(varCount)); |
| 305 | if (!this->CheckError(nc_inq_varids(this->NcId, &varCount, vars.data()))) |
| 306 | { |
| 307 | return false; |
| 308 | } |
| 309 | |
| 310 | std::vector<int> meshIds{}; |
| 311 | std::vector<int> faceIds{}; |
| 312 | std::vector<int> nodeIds{}; |
| 313 | |
| 314 | for (int var : vars) |
| 315 | { |
| 316 | int attCount{}; |
| 317 | if (!this->CheckError(nc_inq_varnatts(this->NcId, var, &attCount))) |
| 318 | { |
| 319 | return false; |
| 320 | } |
| 321 | |
| 322 | for (int i = 0; i < attCount; ++i) |
| 323 | { |
| 324 | const auto name(this->GetAttributeName(var, i)); |
| 325 | |
| 326 | nc_type type{ NC_NAT }; |
| 327 | if (!this->CheckError(nc_inq_atttype(this->NcId, var, name.c_str(), &type))) |
| 328 | { |
| 329 | return false; |
| 330 | } |
| 331 | |
| 332 | if (type != NC_CHAR) |
| 333 | { |
| 334 | continue; |
| 335 | } |
| 336 | |
| 337 | // if the cf_role attribute is "mesh_topology" then the var is a mesh |
| 338 | if (name == "cf_role") |
| 339 | { |
| 340 | const auto value = this->GetAttributeString(var, name); |
| 341 | if (value == "mesh_topology") |
| 342 | { |
| 343 | meshIds.emplace_back(var); |
| 344 | } |
| 345 | } |
| 346 | else if (name == "location") |
no test coverage detected