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

Function ReadFromFileOrCache

IO/HDF/vtkHDFReader.cxx:85–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83//----------------------------------------------------------------------------
84template <typename ImplT, typename CacheT>
85vtkSmartPointer<vtkDataArray> ReadFromFileOrCache(ImplT* impl, std::shared_ptr<CacheT> cache,
86 int tag, std::string name, std::string name_modifier, vtkIdType offset, vtkIdType size,
87 bool mData = true)
88{
89 vtkSmartPointer<vtkDataArray> array;
90 std::string cacheName = name + name_modifier;
91 if (cache && cache->CheckExistsAndEqual(tag, cacheName, offset, size))
92 {
93 array = vtkDataArray::SafeDownCast(cache->Get(tag, cacheName));
94 if (!array)
95 {
96 vtkErrorWithObjectMacro(nullptr, "Cannot read the " << cacheName << " array from cache");
97 return nullptr;
98 }
99 }
100 else
101 {
102 array = vtk::TakeSmartPointer(mData ? impl->NewMetadataArray(name.c_str(), offset, size)
103 : impl->NewArray(tag, name.c_str(), offset, size));
104 if (!array)
105 {
106 vtkErrorWithObjectMacro(nullptr, "Cannot read the " + cacheName + " array from file");
107 return nullptr;
108 }
109 if (cache)
110 {
111 cache->Set(tag, cacheName, offset, size, array);
112 }
113 }
114 return array;
115}
116
117//----------------------------------------------------------------------------
118template <typename T, typename CacheT>

Callers 2

ReadPolyDataPieceFunction · 0.85
ReadMethod · 0.85

Calls 6

CheckExistsAndEqualMethod · 0.80
NewMetadataArrayMethod · 0.80
GetMethod · 0.45
c_strMethod · 0.45
NewArrayMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected