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

Method ReadLevelData

IO/HDF/vtkHDFReaderImplementation.cxx:788–915  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

786
787//------------------------------------------------------------------------------
788bool vtkHDFReader::Implementation::ReadLevelData(unsigned int level,
789 const std::string& levelGroupName, vtkOverlappingAMR* data,
790 vtkDataArraySelection* dataArraySelection[3], bool isTemporalData)
791{
792 vtkHDF::ScopedH5GHandle levelGroupID =
793 H5Gopen(this->VTKGroup, levelGroupName.c_str(), H5P_DEFAULT);
794 if (levelGroupID == H5I_INVALID_HID)
795 {
796 vtkErrorWithObjectMacro(this->Reader, "Can't open group Level" << level);
797 return false;
798 }
799
800 // Now read actual data - one array at a time
801 std::array<const char*, 3> groupNames = { "PointData", "CellData", "FieldData" };
802 for (int attributeType = vtkDataObject::AttributeTypes::POINT;
803 attributeType <= vtkDataObject::AttributeTypes::FIELD; ++attributeType)
804 {
805 vtkHDF::ScopedH5GHandle groupID = H5Gopen(levelGroupID, groupNames[attributeType], H5P_DEFAULT);
806 if (groupID == H5I_INVALID_HID)
807 {
808 // It's OK to not have groups in the file if there are no data arrays
809 // for that attribute type.
810 continue;
811 }
812
813 const std::vector<std::string> arrayNames = this->GetArrayNames(attributeType);
814 for (const std::string& name : arrayNames)
815 {
816 if (!dataArraySelection[attributeType]->ArrayIsEnabled(name.c_str()))
817 {
818 continue;
819 }
820
821 // Open dataset
822 hid_t tempNativeType = H5I_INVALID_HID;
823 std::vector<hsize_t> dims;
824 vtkHDF::ScopedH5DHandle datasetID =
825 vtkHDFUtilities::OpenDataSet(groupID, name.c_str(), &tempNativeType, dims);
826 vtkHDF::ScopedH5THandle nativeType = tempNativeType;
827 if (datasetID < 0)
828 {
829 continue;
830 }
831
832 // Iterate over all datasets, read data and assign attribute
833 hsize_t dataOffset = 0;
834 hsize_t dataSize = 0;
835 unsigned int numberOfDatasets = data->GetNumberOfBlocks(level);
836 for (unsigned int dataSetIndex = 0; dataSetIndex < numberOfDatasets; ++dataSetIndex)
837 {
838 const vtkAMRBox& amrBox = data->GetAMRBox(level, dataSetIndex);
839 vtkImageData* dataSet = data->GetDataSetAsImageData(level, dataSetIndex);
840 if (dataSet == nullptr)
841 {
842 vtkErrorWithObjectMacro(this->Reader,
843 "Error fetching dataset at level " << level << " and dataSetIndex " << dataSetIndex);
844 return false;
845 }

Callers 1

ReadAMRDataMethod · 0.95

Calls 12

GetArrayNamesMethod · 0.95
GetAMRBoxMethod · 0.80
GetDataSetAsImageDataMethod · 0.80
c_strMethod · 0.45
ArrayIsEnabledMethod · 0.45
GetNumberOfBlocksMethod · 0.45
GetNumberOfNodesMethod · 0.45
countMethod · 0.45
GetNumberOfCellsMethod · 0.45
SetNameMethod · 0.45
AddArrayMethod · 0.45

Tested by

no test coverage detected