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

Method GetAttributeValueAsStr

IO/ERF/vtkERFReader.cxx:913–941  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

911
912//----------------------------------------------------------------------------
913std::string vtkERFReader::GetAttributeValueAsStr(
914 const hid_t& erfIdx, const std::string& attributeName) const
915{
916 vtkHDF::ScopedH5AHandle attributeHandler = H5Aopen(erfIdx, attributeName.c_str(), H5P_DEFAULT);
917 vtkHDF::ScopedH5THandle rawType = H5Aget_type(attributeHandler);
918 vtkHDF::ScopedH5THandle dataType = H5Tget_native_type(rawType, H5T_DIR_ASCEND);
919
920 if (H5Tget_class(dataType) != H5T_STRING)
921 {
922 return "";
923 }
924
925 hsize_t stringLength = H5Aget_storage_size(attributeHandler);
926 std::string value;
927 value.resize(stringLength + 1);
928 if (H5Aread(attributeHandler, dataType, value.data()) >= 0)
929 {
930 value.erase(std::remove_if(value.begin(), value.end(),
931 [](char c)
932 {
933 // convert it to avoid potential issue with negative char
934 unsigned char uc = static_cast<unsigned char>(c);
935 return std::isspace(uc) || !std::isalpha(uc);
936 }),
937 value.end());
938 }
939
940 return value;
941}
942
943//----------------------------------------------------------------------------
944int vtkERFReader::GetAttributeValueAsInt(

Callers 2

AppendSystemBlockMethod · 0.95
BuildMeshMethod · 0.95

Calls 11

H5Aget_typeFunction · 0.85
H5Tget_native_typeFunction · 0.85
H5Aget_storage_sizeFunction · 0.85
remove_ifFunction · 0.85
isalphaFunction · 0.85
c_strMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected