------------------------------------------------------------------------------
| 440 | |
| 441 | //------------------------------------------------------------------------------ |
| 442 | void vtkDataObjectMeshCache::CopyCacheToDataObject(vtkDataObject* output) |
| 443 | { |
| 444 | if (!output) |
| 445 | { |
| 446 | vtkWarningMacro("Cannot copy to nullptr"); |
| 447 | return; |
| 448 | } |
| 449 | if (!this->Cache) |
| 450 | { |
| 451 | vtkWarningMacro("Cannot copy from nullptr"); |
| 452 | return; |
| 453 | } |
| 454 | |
| 455 | if (!this->IsSupportedData(output)) |
| 456 | { |
| 457 | vtkWarningMacro("Cannot copy to unsupported data type: " << output->GetClassName()); |
| 458 | return; |
| 459 | } |
| 460 | vtkSmartPointer<vtkDataObject> input = nullptr; |
| 461 | if (this->HasConsumerNoInputPort()) |
| 462 | { |
| 463 | input = vtkSmartPointer<vtkDataObject>::Take(output->NewInstance()); |
| 464 | input->ShallowCopy(output); |
| 465 | } |
| 466 | else if (this->OriginalDataSet) |
| 467 | { |
| 468 | input = this->OriginalDataSet.Get(); |
| 469 | } |
| 470 | else if (this->OriginalCompositeDataSet) |
| 471 | { |
| 472 | input = this->OriginalCompositeDataSet.Get(); |
| 473 | } |
| 474 | |
| 475 | vtkCacheLog(INFO, " Copy Cache to data object"); |
| 476 | output->ShallowCopy(this->Cache); |
| 477 | this->ClearAttributes(output); |
| 478 | |
| 479 | auto outputDataSet = vtkDataSet::SafeDownCast(output); |
| 480 | auto outputComposite = vtkCompositeDataSet::SafeDownCast(output); |
| 481 | if (outputDataSet) |
| 482 | { |
| 483 | auto cacheDataSet = vtkDataSet::SafeDownCast(this->Cache); |
| 484 | auto inputDataSet = vtkDataSet::SafeDownCast(input); |
| 485 | this->ForwardAttributesToDataSet(inputDataSet, cacheDataSet, outputDataSet); |
| 486 | } |
| 487 | else if (outputComposite) |
| 488 | { |
| 489 | auto inputComposite = vtkCompositeDataSet::SafeDownCast(input); |
| 490 | this->ForwardAttributesToComposite(inputComposite, outputComposite); |
| 491 | } |
| 492 | } |
| 493 | |
| 494 | //------------------------------------------------------------------------------ |
| 495 | void vtkDataObjectMeshCache::ForwardAttributesToDataSet( |