------------------------------------------------------------------------------
| 250 | |
| 251 | //------------------------------------------------------------------------------ |
| 252 | bool 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 | //------------------------------------------------------------------------------ |
| 293 | bool TestMeshOnly(TestMeshPipeline* pipeline) |
no test coverage detected