------------------------------------------------------------------------------
| 1082 | |
| 1083 | //------------------------------------------------------------------------------ |
| 1084 | bool vtkHDFReader::Implementation::ReadHyperTreeGridData(vtkHyperTreeGrid* htg, |
| 1085 | const vtkDataArraySelection* arraySelection, const vtkIdType cellOffset, |
| 1086 | const vtkIdType treeIdsOffset, const vtkIdType depthOffset, const vtkIdType descriptorOffset, |
| 1087 | const vtkIdType maskOffset, const vtkIdType partOffset, const vtkIdType verticesPerDepthOffset, |
| 1088 | const vtkIdType depthLimit, const vtkIdType step) |
| 1089 | { |
| 1090 | htg->Initialize(); |
| 1091 | |
| 1092 | if (!this->ReadHyperTreeGridMetaInfo(htg)) |
| 1093 | { |
| 1094 | return false; |
| 1095 | } |
| 1096 | |
| 1097 | if (!this->ReadHyperTreeGridDimensions(htg)) |
| 1098 | { |
| 1099 | return false; |
| 1100 | } |
| 1101 | |
| 1102 | // Read meta-data for the current piece |
| 1103 | const vtkIdType treeCount = this->GetMetadata("NumberOfTrees", 1, partOffset)[0]; |
| 1104 | const vtkIdType depthCount = this->GetMetadata("NumberOfDepths", 1, partOffset)[0]; |
| 1105 | const vtkIdType cellCount = this->GetMetadata("NumberOfCells", 1, partOffset)[0]; |
| 1106 | const vtkIdType descriptorCount = this->GetMetadata("DescriptorsSize", 1, partOffset)[0]; |
| 1107 | |
| 1108 | // Read only the tree ids for the current piece |
| 1109 | const std::vector<vtkIdType> treeIds = this->GetMetadata("TreeIds", treeCount, treeIdsOffset); |
| 1110 | const std::vector<vtkIdType> depthPerTree = |
| 1111 | this->GetMetadata("DepthPerTree", treeCount, depthOffset); |
| 1112 | const std::vector<vtkIdType> numberOfCellsPerTreeDepth = |
| 1113 | this->GetMetadata("NumberOfCellsPerTreeDepth", depthCount, verticesPerDepthOffset); |
| 1114 | |
| 1115 | // Read Tree Descriptors |
| 1116 | const std::vector<hsize_t> descriptorExtent = { static_cast<hsize_t>(descriptorOffset), |
| 1117 | static_cast<hsize_t>(descriptorOffset + ::bitSizeToBytes(descriptorCount)) }; |
| 1118 | vtkSmartPointer<vtkUnsignedCharArray> descriptorsByteArray = |
| 1119 | vtk::TakeSmartPointer(vtkArrayDownCast<vtkUnsignedCharArray>( |
| 1120 | vtkHDFUtilities::NewArrayForGroup(this->VTKGroup, "Descriptors", descriptorExtent))); |
| 1121 | |
| 1122 | // Build a bit array from the uint8 array, transferring the memory ownership to the bit array |
| 1123 | vtkNew<vtkBitArray> descriptor; |
| 1124 | descriptor->SetArray(descriptorsByteArray->GetPointer(0), descriptorCount, 0); |
| 1125 | descriptorsByteArray->SetArrayFreeFunction(nullptr); |
| 1126 | |
| 1127 | const bool hasMask = H5Lexists(this->VTKGroup, "Mask", H5P_DEFAULT) > 0; |
| 1128 | if (hasMask) |
| 1129 | { |
| 1130 | vtkNew<vtkBitArray> mask; |
| 1131 | mask->Allocate(cellCount); |
| 1132 | htg->SetMask(mask); |
| 1133 | } |
| 1134 | |
| 1135 | // Create cell arrays |
| 1136 | std::vector<vtkSmartPointer<vtkAbstractArray>> cellArrays; |
| 1137 | if (!this->CreateHyperTreeGridCellArrays(htg, cellArrays, arraySelection, cellCount)) |
| 1138 | { |
| 1139 | return false; |
| 1140 | } |
| 1141 |
no test coverage detected