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

Method AddFieldArrays

IO/HDF/vtkHDFReader.cxx:858–915  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

856
857//------------------------------------------------------------------------------
858int vtkHDFReader::AddFieldArrays(vtkDataObject* data)
859{
860 const std::vector<std::string> names = this->Impl->GetArrayNames(vtkDataObject::FIELD);
861 for (const std::string& name : names)
862 {
863 if (!this->DataArraySelection[vtkDataObject::FIELD]->ArrayIsEnabled(name.c_str()))
864 {
865 continue;
866 }
867 vtkSmartPointer<vtkAbstractArray> array;
868 vtkIdType offset = -1;
869 std::array<vtkIdType, 2> size = { -1, -1 };
870 if (this->Impl->GetDataSetType() != VTK_OVERLAPPING_AMR && this->GetHasTemporalData())
871 {
872 size = this->Impl->GetFieldArraySize(this->Step, name);
873 offset = this->Impl->GetArrayOffset(this->Step, vtkDataObject::FIELD, name);
874 if (size[0] == 0 && size[1] == 0)
875 {
876 continue;
877 }
878 }
879 if (this->UseCache &&
880 this->Cache->CheckExistsAndEqual(vtkDataObject::FIELD, name, offset, size[1]))
881 {
882 array = this->Cache->Get(vtkDataObject::FIELD, name);
883 if (!array)
884 {
885 vtkErrorMacro("Error retrieving array " + name + " from cache.");
886 return 0;
887 }
888 }
889 else
890 {
891 if ((array = vtk::TakeSmartPointer(
892 this->Impl->NewFieldArray(name.c_str(), offset, size[1], size[0]))) == nullptr)
893 {
894 vtkErrorMacro("Error reading array " << name);
895 return 0;
896 }
897 array->SetName(name.c_str());
898 }
899 data->GetAttributesAsFieldData(vtkDataObject::FIELD)->AddArray(array);
900 if (this->UseCache)
901 {
902 this->Cache->Set(vtkDataObject::FIELD, name, offset, size[1], array);
903 }
904 }
905 if (this->GetHasTemporalData())
906 {
907 vtkNew<vtkDoubleArray> time;
908 time->SetName("Time");
909 time->SetNumberOfComponents(1);
910 time->SetNumberOfTuples(1);
911 time->SetValue(0, this->TimeValue);
912 data->GetAttributesAsFieldData(vtkDataObject::FIELD)->AddArray(time);
913 }
914 return 1;
915}

Callers 3

ReadMethod · 0.95
ReadRecursivelyMethod · 0.95
ReadDataMethod · 0.95

Calls 15

GetHasTemporalDataMethod · 0.95
GetArrayNamesMethod · 0.80
GetFieldArraySizeMethod · 0.80
GetArrayOffsetMethod · 0.80
CheckExistsAndEqualMethod · 0.80
NewFieldArrayMethod · 0.80
ArrayIsEnabledMethod · 0.45
c_strMethod · 0.45
GetDataSetTypeMethod · 0.45
GetMethod · 0.45
SetNameMethod · 0.45
AddArrayMethod · 0.45

Tested by

no test coverage detected