------------------------------------------------------------------------------
| 538 | |
| 539 | //------------------------------------------------------------------------------ |
| 540 | bool vtkHDFReader::Implementation::ComputeAMROffsetsPerLevels( |
| 541 | vtkDataArraySelection* dataArraySelection[3], vtkIdType step, unsigned int maxLevel) |
| 542 | { |
| 543 | if (!dataArraySelection) |
| 544 | { |
| 545 | return false; |
| 546 | } |
| 547 | |
| 548 | this->AMRInformation.Clear(); |
| 549 | |
| 550 | if (this->DataSetType != VTK_OVERLAPPING_AMR) |
| 551 | { |
| 552 | vtkWarningWithObjectMacro( |
| 553 | this->Reader, "Bad usage of this method. Should only be use for OverlappingAMR"); |
| 554 | return true; |
| 555 | } |
| 556 | |
| 557 | vtkIdType numberOfSteps = this->GetNumberOfSteps(); |
| 558 | unsigned int level = 0; |
| 559 | while (level < maxLevel) |
| 560 | { |
| 561 | std::stringstream levelGroupName; |
| 562 | levelGroupName << "Steps/Level" << level; |
| 563 | if (H5Lexists(this->VTKGroup, levelGroupName.str().c_str(), H5P_DEFAULT) <= 0) |
| 564 | { |
| 565 | // The level does not exist, just exit. |
| 566 | return true; |
| 567 | } |
| 568 | |
| 569 | vtkHDF::ScopedH5GHandle levelGroupID = |
| 570 | H5Gopen(this->VTKGroup, levelGroupName.str().c_str(), H5P_DEFAULT); |
| 571 | if (levelGroupID == H5I_INVALID_HID) |
| 572 | { |
| 573 | vtkErrorWithObjectMacro(this->Reader, "Can't open group Level" << level); |
| 574 | return false; |
| 575 | } |
| 576 | |
| 577 | std::vector<int> numberOfBox; |
| 578 | numberOfBox.resize(numberOfSteps); |
| 579 | |
| 580 | std::vector<vtkIdType> boxOffsets; |
| 581 | boxOffsets.resize(numberOfSteps); |
| 582 | |
| 583 | // Due to an error in the VTKHDF File Format 2.2, few array names miss an 's' at |
| 584 | // the end. As we should support any VTKHDF version 2.X, we should handle it. |
| 585 | // It concerns: NumberOfAMRBoxes, AMRBoxOffsets and Point/Cell/FieldDataOffsets |
| 586 | std::string numberOfBoxesDatasetName = "NumberOfAMRBoxes"; |
| 587 | std::string amrboxOffsetsDatasetName = "AMRBoxOffsets"; |
| 588 | std::array<const char*, 3> groupNames = { "PointDataOffsets", "CellDataOffsets", |
| 589 | "FieldDataOffsets" }; |
| 590 | |
| 591 | if (this->Version[0] == 2 && this->Version[1] == 2) |
| 592 | { |
| 593 | numberOfBoxesDatasetName = "NumberOfAMRBox"; |
| 594 | amrboxOffsetsDatasetName = "AMRBoxOffset"; |
| 595 | groupNames = { "PointDataOffset", "CellDataOffset", "FieldDataOffset" }; |
| 596 | } |
| 597 |
no test coverage detected