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

Function TestUseCache

Filters/Temporal/Testing/Cxx/TestDataObjectMeshCache.cxx:252–290  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

250
251//------------------------------------------------------------------------------
252bool TestUseCache(TestMeshPipeline* pipeline)
253{
254 vtkNew<vtkDataObjectMeshCache> cache;
255
256 vtkNew<vtkPolyData> expectedOutput;
257 expectedOutput->DeepCopy(pipeline->GetFilterOutputData());
258 // we forward only point data
259 expectedOutput->GetCellData()->Initialize();
260 assert(expectedOutput->GetCellData()->GetGhostArray() == nullptr);
261
262 pipeline->InitializeCache(cache);
263 pipeline->UpdateInputData(details::modifiedData[0]);
264
265 vtkDataObjectMeshCache::Status status = cache->GetStatus();
266 vtkLogIf(ERROR, !status.enabled(), "UseCache: expect usable cache.");
267 vtkNew<vtkPolyData> cacheOutput;
268 cache->CopyCacheToDataObject(cacheOutput);
269 status = cache->GetStatus();
270 vtkLogIf(ERROR, !status.enabled(), "UseCache: using cache should not invalidate it.");
271
272 // Cell data arrays are not forwarded.
273 // This concerns also ghostcells array that is used in GetMeshMTime. So cache output
274 // may appears as older than pipeline data.
275 bool sameMeshTime = pipeline->GetOutputMeshMTime() >= cacheOutput->GetMeshMTime();
276 vtkLogIf(ERROR, !sameMeshTime,
277 "UseCache: cache should have same mesh mtime than previous output. Expected");
278 vtkLogIf(ERROR, !sameMeshTime,
279 "expected: " << pipeline->GetInputMeshMTime() << " but has: " << cacheOutput->GetMeshMTime());
280
281 vtkNew<vtkIntArray> expectedArray;
282 expectedArray->SetName(mockArraysName::pointData.c_str());
283 expectedArray->SetArray(details::modifiedData.data(), 4, 1);
284 expectedOutput->GetPointData()->AddArray(expectedArray);
285
286 bool sameData = vtkTestUtilities::CompareDataObjects(cacheOutput, expectedOutput);
287 vtkLogIf(ERROR, !sameData, "UseCache: wrong cache output.");
288
289 return true;
290}
291
292//------------------------------------------------------------------------------
293bool TestMeshOnly(TestMeshPipeline* pipeline)

Callers 1

TestDataObjectMeshCacheFunction · 0.85

Calls 15

GetFilterOutputDataMethod · 0.80
InitializeCacheMethod · 0.80
UpdateInputDataMethod · 0.80
GetStatusMethod · 0.80
enabledMethod · 0.80
CopyCacheToDataObjectMethod · 0.80
GetOutputMeshMTimeMethod · 0.80
GetInputMeshMTimeMethod · 0.80
assertFunction · 0.50
DeepCopyMethod · 0.45
InitializeMethod · 0.45
GetCellDataMethod · 0.45

Tested by

no test coverage detected