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

Method LoadAttribute

IO/AMR/vtkAMREnzoReaderInternal.cxx:362–573  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

360
361//------------------------------------------------------------------------------
362int vtkEnzoReaderInternal::LoadAttribute(const char* attribute, int blockIdx)
363{
364 // TODO: implement this
365 // called by GetBlockAttribute( ... ) or GetParticlesAttribute()
366 this->ReadMetaData();
367
368 if (attribute == nullptr || blockIdx < 0 || blockIdx >= this->NumberOfBlocks)
369 {
370 return 0;
371 }
372
373 // this->Internal->Blocks includes a pseudo block --- the root as block #0
374 blockIdx++;
375
376 // currently only the HDF5 file format is supported
377 std::string blckFile = this->Blocks[blockIdx].BlockFileName;
378 hid_t fileIndx = H5Fopen(blckFile.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT);
379 if (fileIndx < 0)
380 {
381 return 0;
382 }
383
384 // retrieve the contents of the root directory to look for a group
385 // corresponding to the target block, if available, open that group
386
387 char blckName[65];
388 int objIndex;
389 hsize_t numbObjs;
390 hid_t rootIndx = H5Gopen(fileIndx, "/");
391 H5Gget_num_objs(rootIndx, &numbObjs);
392 for (objIndex = 0; objIndex < static_cast<int>(numbObjs); objIndex++)
393 {
394 int type = H5Gget_objtype_by_idx(rootIndx, objIndex);
395 if (type == H5G_GROUP)
396 {
397 H5Gget_objname_by_idx(rootIndx, objIndex, blckName, 64);
398 auto result = vtk::scan<int>(blckName, "Grid{:d}");
399 if (result && (result->value() == blockIdx || result->value() == (blockIdx + 1)))
400 {
401 // located the target block
402 rootIndx = H5Gopen(rootIndx, blckName);
403 break;
404 }
405 }
406 } // END for all objects
407
408 // disable error messages while looking for the attribute (if any) name
409 // and enable error messages when it is done
410 void* pContext = nullptr;
411 H5E_auto_t erorFunc;
412 H5Eget_auto(&erorFunc, &pContext);
413 H5Eset_auto(nullptr, nullptr);
414
415 hid_t attrIndx = H5Dopen(rootIndx, attribute);
416
417 H5Eset_auto(erorFunc, pContext);
418 pContext = nullptr;
419

Callers 3

GetBlockAttributeMethod · 0.95
GetParticlesTypeArrayMethod · 0.80
GetParticlesMethod · 0.80

Calls 15

ReadMetaDataMethod · 0.95
ReleaseDataArrayMethod · 0.95
H5FopenFunction · 0.85
H5Gget_num_objsFunction · 0.85
H5Gget_objtype_by_idxFunction · 0.85
H5Gget_objname_by_idxFunction · 0.85
H5Dget_typeFunction · 0.85
H5Tget_native_typeFunction · 0.85
H5DcloseFunction · 0.85
NewFunction · 0.50

Tested by

no test coverage detected