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

Method ReadImageBlocks

IO/ADIOS2/vtkADIOS2CoreImageReader.cxx:704–854  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

702
703//------------------------------------------------------------------------------
704void vtkADIOS2CoreImageReader::ReadImageBlocks(vtkMultiBlockDataSet* mbds)
705{
706 try
707 {
708 // One adios block is mapped to one vtk image data.
709 size_t blockExtentI{ 0 };
710 for (size_t blockI = this->Impl->BlockStart;
711 blockI < this->Impl->BlockStart + this->Impl->BlockCount; blockI++)
712 {
713 vtkNew<vtkImageData> outputImage;
714 outputImage->SetOrigin(this->Origin);
715 outputImage->SetSpacing(this->Spacing);
716 const auto& extents = this->Impl->BlockExtents[blockExtentI++];
717 if (this->IsColumnMajor)
718 {
719 outputImage->SetExtent(
720 extents[0], extents[1], extents[2], extents[3], extents[4], extents[5]);
721 }
722 else
723 {
724 outputImage->SetExtent(
725 extents[4], extents[5], extents[2], extents[3], extents[0], extents[1]);
726 }
727 // The index of mbds starts from 0
728 mbds->SetBlock(static_cast<unsigned int>(blockI - this->Impl->BlockStart), outputImage);
729 // Fetch all datas for current image
730 for (const auto& iter : this->Impl->InquiredVars)
731 {
732 std::string varName = iter.first;
733 if (this->Impl->AvailVars.find(varName) == this->Impl->AvailVars.end())
734 {
735 vtkErrorMacro("Inquire variable " << varName << " cannot be found in the provided file");
736 continue;
737 }
738 // TODO: Add validation for inquire variable's dimensions
739 std::string typeStr = this->FetchTypeStringFromVarName(varName);
740 if (typeStr.empty())
741 {
742 vtkErrorMacro("Cannot find a type for " << varName << " invalid name is provided");
743 continue;
744 }
745
746 vtkSmartPointer<vtkAbstractArray> dataArray;
747 // Use the adios_types_map in adios2 code base to generate types
748 if (typeStr == "string")
749 { // vtkStringArray uses vtkStdString instead of std::string. So we manually
750 // do the work here
751 auto varADIOS2 = this->Impl->AdiosIO.InquireVariable<std::string>(varName);
752 varADIOS2.SetBlockSelection(blockI);
753 varADIOS2.SetStepSelection({ this->Impl->RequestStep, 1 });
754
755 vtkNew<vtkStringArray> array;
756 dataArray = array;
757 array->SetNumberOfComponents(1);
758 array->SetName(varName.c_str());
759 array->SetNumberOfTuples(static_cast<vtkIdType>(varADIOS2.SelectionSize()));
760 this->Impl->BpReader.Get(varADIOS2, dynamic_cast<std::string*>(array->GetPointer(0)));
761 }

Callers 1

RequestDataMethod · 0.95

Calls 15

SetBlockMethod · 0.80
SetActiveScalarsMethod · 0.80
DeleteMethod · 0.65
SetOriginMethod · 0.45
SetSpacingMethod · 0.45
SetExtentMethod · 0.45
findMethod · 0.45
endMethod · 0.45
emptyMethod · 0.45
SetNumberOfComponentsMethod · 0.45
SetNameMethod · 0.45

Tested by

no test coverage detected