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

Function FindBlockIndex

IO/AMR/vtkAMREnzoParticlesReader.cxx:31–69  ·  view source on GitHub ↗

------------------------------------------------------------------------------ Description: Finds the block index (blockIndx) within the HDF5 file associated with the given file index.

Source from the content-addressed store, hash-verified

29// Finds the block index (blockIndx) within the HDF5 file associated with
30// the given file index.
31VTK_ABI_NAMESPACE_BEGIN
32static 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:

Callers 1

GetParticlesMethod · 0.85

Calls 4

H5Gget_num_objsFunction · 0.85
H5Gget_objtype_by_idxFunction · 0.85
H5Gget_objname_by_idxFunction · 0.85
valueMethod · 0.45

Tested by

no test coverage detected