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

Method ParseHeader

IO/NetCDF/vtkNetCDFUGRIDReader.cxx:289–529  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

287
288//--------------------------------------------------------------------------------------------------
289bool 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")

Callers 2

RequestInformationMethod · 0.95
RequestDataMethod · 0.95

Calls 15

CheckErrorMethod · 0.95
GetAttributeNameMethod · 0.95
GetAttributeStringMethod · 0.95
FillArraySelectionMethod · 0.95
GetDimensionNameMethod · 0.95
nc_inq_nvarsFunction · 0.85
nc_inq_varidsFunction · 0.85
nc_inq_varnattsFunction · 0.85
nc_inq_atttypeFunction · 0.85
nc_get_att_intFunction · 0.85
nc_inq_varidFunction · 0.85
nc_inq_varndimsFunction · 0.85

Tested by

no test coverage detected