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

Method GetSubfileNumberOf

IO/HDF/vtkHDFWriterImplementation.cxx:1338–1398  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1336
1337//------------------------------------------------------------------------------
1338hsize_t vtkHDFWriter::Implementation::GetSubfileNumberOf(const std::string& base,
1339 const std::string& qualifier, std::size_t subfileId, hsize_t part, char primitive)
1340{
1341 const std::string fullPath = base + "/" + qualifier;
1342 bool isPolyData = H5Lexists(this->OpenExistingGroup(this->Root, this->GetBasePath(base).c_str()),
1343 "Lines", H5P_DEFAULT) > 0;
1344 std::stringstream ss;
1345 ss << fullPath << " for subfile " << subfileId << " for part " << part << " with primitive "
1346 << static_cast<int>(primitive);
1347 const std::string debugInfo = ss.str();
1348
1349 vtkDebugWithObjectMacro(this->Writer, << "Fetching " << debugInfo);
1350
1351 if (!this->DatasetAndGroupExist(fullPath, this->Subfiles[subfileId]))
1352 {
1353 // In composite structure, not all subfiles may have a valid block
1354 return 0;
1355 }
1356 vtkHDF::ScopedH5DHandle sourceDataset =
1357 H5Dopen(this->Subfiles[subfileId], fullPath.c_str(), H5P_DEFAULT);
1358 if (sourceDataset == H5I_INVALID_HID)
1359 {
1360 vtkErrorWithObjectMacro(this->Writer, << "Could not open dataset " << debugInfo);
1361 return 0;
1362 }
1363
1364 std::vector<hsize_t> start{ static_cast<unsigned long>(part) }, count{ 1 }, result{ 0 };
1365 int dimension = 1;
1366 constexpr char INVALID_PRIMITIVE = 0xff;
1367
1368 if (isPolyData && primitive != INVALID_PRIMITIVE)
1369 {
1370 start.emplace_back(static_cast<hsize_t>(primitive));
1371 count.emplace_back(1);
1372 dimension++;
1373 }
1374
1375 vtkHDF::ScopedH5SHandle sourceSpace = H5Dget_space(sourceDataset);
1376
1377 vtkHDF::ScopedH5SHandle destSpace = H5Screate_simple(dimension, count.data(), nullptr);
1378 if (sourceSpace == H5I_INVALID_HID || sourceSpace == H5I_INVALID_HID)
1379 {
1380 vtkErrorWithObjectMacro(this->Writer, << "Could not create destination space " << debugInfo);
1381 return 0;
1382 }
1383
1384 if (H5Sselect_hyperslab(
1385 sourceSpace, H5S_SELECT_SET, start.data(), nullptr, count.data(), nullptr) < 0)
1386 {
1387 vtkErrorWithObjectMacro(this->Writer, << "Could not select hyperslab " << debugInfo);
1388 return 0;
1389 }
1390
1391 if (H5Dread(sourceDataset, H5T_STD_I64LE, destSpace, sourceSpace, H5P_DEFAULT, result.data()) < 0)
1392 {
1393 vtkErrorWithObjectMacro(this->Writer, << "Could not read dataset " << debugInfo);
1394 return 0;
1395 }

Callers 4

CreateVirtualDatasetMethod · 0.95
WriteSumStepsMethod · 0.95
WriteSumStepsPolyDataMethod · 0.95

Calls 8

OpenExistingGroupMethod · 0.95
GetBasePathMethod · 0.95
DatasetAndGroupExistMethod · 0.95
H5Sselect_hyperslabFunction · 0.85
c_strMethod · 0.45
strMethod · 0.45
emplace_backMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected