------------------------------------------------------------------------------ Description: Finds the block index (blockIndx) within the HDF5 file associated with the given file index.
| 29 | // Finds the block index (blockIndx) within the HDF5 file associated with |
| 30 | // the given file index. |
| 31 | VTK_ABI_NAMESPACE_BEGIN |
| 32 | static bool FindBlockIndex(hid_t fileIndx, int blockIdx, hid_t& rootIndx) |
| 33 | { |
| 34 | // retrieve the contents of the root directory to look for a group |
| 35 | // corresponding to the target block, if available, open that group |
| 36 | hsize_t numbObjs; |
| 37 | rootIndx = H5Gopen(fileIndx, "/"); |
| 38 | if (rootIndx < 0) |
| 39 | { |
| 40 | vtkGenericWarningMacro("Failed to open root node of particles file"); |
| 41 | return false; |
| 42 | } |
| 43 | |
| 44 | bool found = false; |
| 45 | H5Gget_num_objs(rootIndx, &numbObjs); |
| 46 | for (int objIndex = 0; objIndex < static_cast<int>(numbObjs); objIndex++) |
| 47 | { |
| 48 | if (H5Gget_objtype_by_idx(rootIndx, objIndex) == H5G_GROUP) |
| 49 | { |
| 50 | char blckName[65]; |
| 51 | H5Gget_objname_by_idx(rootIndx, objIndex, blckName, 64); |
| 52 | |
| 53 | // Is this the target block? |
| 54 | auto result = vtk::scan<int>(blckName, "Grid{:d}"); |
| 55 | if (result && result->value() == blockIdx) |
| 56 | { |
| 57 | // located the target block |
| 58 | rootIndx = H5Gopen(rootIndx, blckName); |
| 59 | if (rootIndx < 0) |
| 60 | { |
| 61 | vtkGenericWarningMacro("Could not locate target block!\n"); |
| 62 | } |
| 63 | found = true; |
| 64 | break; |
| 65 | } |
| 66 | } // END if group |
| 67 | } // END for all objects |
| 68 | return (found); |
| 69 | } |
| 70 | |
| 71 | //------------------------------------------------------------------------------ |
| 72 | // Description: |
no test coverage detected