Update vtkCompositeDataSet::ShallowCopy usage

- Use vtkCompositeDataSet::CompositeShallowCopy wherever possible
- Fix Some wrong vtkCompositeDataSet::ShallowCopy usage
dev
Mathieu Westphal 2 months ago
parent 4a1994d926
commit c08e9325ff

@ -287,7 +287,7 @@ vtkOverlappingAMR* GetAMRDataSet(const int dimension, const int refinementRatio)
amrGPSource->SetRefinementRatio(refinementRatio);
amrGPSource->Update();
vtkOverlappingAMR* myAMR = vtkOverlappingAMR::New();
myAMR->ShallowCopy(amrGPSource->GetOutput());
myAMR->CompositeShallowCopy(amrGPSource->GetOutput());
amrGPSource->Delete();
return (myAMR);
}

@ -618,7 +618,7 @@ int vtkAMRSliceFilter::RequestData(vtkInformation* vtkNotUsed(request),
if (this->IsAMRData2D(inputAMR))
{
outputAMR->ShallowCopy(inputAMR);
outputAMR->CompositeShallowCopy(inputAMR);
return 1;
}

@ -100,7 +100,7 @@ int vtkAppendCompositeDataLeaves::RequestData(vtkInformation* vtkNotUsed(request
if (numInputs == 1)
{
// trivial case.
output->ShallowCopy(input0);
output->CompositeShallowCopy(input0);
return 1;
}

@ -57,7 +57,7 @@ int vtkConvertToPartitionedDataSetCollection::RequestData(
if (auto pdc = vtkPartitionedDataSetCollection::SafeDownCast(inputDO))
{
// nothing to do, input is already a vtkPartitionedDataSetCollection.
output->ShallowCopy(pdc);
output->CompositeShallowCopy(pdc);
this->CheckAbort();
return 1;
}

@ -115,7 +115,7 @@ int vtkExtractBlock::RequestData(vtkInformation* vtkNotUsed(request),
if (this->Indices->find(0) != this->Indices->end())
{
// trivial case.
output->ShallowCopy(input);
output->CompositeShallowCopy(input);
return 1;
}
@ -236,7 +236,7 @@ bool vtkExtractBlock::Prune(vtkMultiBlockDataSet* mblock)
vtkMultiBlockDataSet::SafeDownCast(mblock->GetBlock(0));
if (block0)
{
mblock->ShallowCopy(block0);
mblock->CompositeShallowCopy(block0);
}
}
return (oindex == 0);

@ -336,7 +336,7 @@ int vtkExtractBlockUsingDataAssembly::RequestData(
if (auto result = vtkDataAssemblyUtilities::GenerateCompositeDataSetFromHierarchy(
xformedOutput, xformedOutput->GetDataAssembly()))
{
outputCD->ShallowCopy(result);
outputCD->CompositeShallowCopy(result);
return 1;
}

@ -98,7 +98,7 @@ void vtkCopySubTree(std::unordered_set<unsigned int>& ids, vtkCompositeDataItera
assert(coutput != nullptr);
// shallow copy..this pass the non-leaf nodes over.
coutput->ShallowCopy(cinput);
coutput->CompositeShallowCopy(cinput);
// now, we need to remove all composite ids for the subtree from the set to
// extract to avoid attempting to copy them multiple times (although it
@ -191,7 +191,7 @@ int vtkExtractSelectedBlock::RequestData(vtkInformation* vtkNotUsed(request),
if (has_root && !inverse)
{
// pass everything.
output->ShallowCopy(cd);
output->CompositeShallowCopy(cd);
return 1;
}

@ -195,7 +195,7 @@ int vtkAnimateModes::RequestData(
auto outputDT = vtkDataObjectTree::SafeDownCast(outputDO);
assert(outputDT);
outputDT->RecursiveShallowCopy(inputDT);
outputDT->ShallowCopy(inputDT);
for (auto block : vtkCompositeDataSet::GetDataSets<vtkPointSet>(outputDT))
{
executeBlock(block);

@ -249,7 +249,7 @@ int vtkMergeTimeFilter::RequestData(vtkInformation* vtkNotUsed(request),
}
groupInputs->SetContainerAlgorithm(this);
groupInputs->Update();
output->ShallowCopy(groupInputs->GetOutput());
output->CompositeShallowCopy(groupInputs->GetOutput());
output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(), this->RequestedTimeValue);

@ -114,7 +114,7 @@ int vtkMultiBlockDataGroupFilter::RequestData(vtkInformation* vtkNotUsed(request
{
vtkMultiBlockDataSet* block = vtkMultiBlockDataSet::SafeDownCast(output->GetBlock(0));
block->Register(this);
output->ShallowCopy(block);
output->CompositeShallowCopy(block);
block->UnRegister(this);
}

@ -69,7 +69,7 @@ int vtkMultiBlockMergeFilter::RequestData(vtkInformation* vtkNotUsed(request),
{
// shallow copy first input to output to start off with
// cerr << "Copy first input" << endl;
output->ShallowCopy(vtkMultiBlockDataSet::SafeDownCast(input));
output->CompositeShallowCopy(vtkMultiBlockDataSet::SafeDownCast(input));
first = 0;
}
else

@ -223,7 +223,7 @@ vtkDataObject* vtkTemporalArrayOperatorFilter::Process(
vtkCompositeDataSet* compositeDataSet1 = vtkCompositeDataSet::SafeDownCast(inputData1);
vtkCompositeDataSet* outputCompositeDataSet = compositeDataSet0->NewInstance();
outputCompositeDataSet->ShallowCopy(inputData0);
outputCompositeDataSet->CompositeShallowCopy(compositeDataSet0);
vtkSmartPointer<vtkCompositeDataIterator> iter;
iter.TakeReference(compositeDataSet0->NewIterator());

@ -128,7 +128,7 @@ int vtkAlignImageDataSetFilter::RequestData(
vtkInformation*, vtkInformationVector** inputVector, vtkInformationVector* outputVector)
{
auto outputCD = vtkCompositeDataSet::GetData(outputVector, 0);
outputCD->RecursiveShallowCopy(vtkDataObject::GetData(inputVector[0], 0));
outputCD->ShallowCopy(vtkDataObject::GetData(inputVector[0], 0));
auto images = vtkCompositeDataSet::GetDataSets<vtkImageData>(outputCD);
auto controller = this->GetController()

@ -275,7 +275,7 @@ int vtkDistributedDataFilter::RequestData(vtkInformation* vtkNotUsed(request),
if (outputCD)
{
outputCD->ShallowCopy(input);
outputCD->CompositeShallowCopy(vtkCompositeDataSet::SafeDownCast(input));
}
else
{

@ -65,7 +65,7 @@ int vtkPConvertToMultiBlockDataSet::RequestData(
// ensure that we have exactly the same number of partitions on all ranks.
vtkNew<vtkPartitionedDataSetCollection> clone;
clone->ShallowCopy(input);
clone->CompositeShallowCopy(input);
const auto count = input->GetNumberOfPartitionedDataSets();
std::vector<unsigned int> piece_counts(count);

@ -212,7 +212,7 @@ void vtkPExtractDataArraysOverTime::ReorganizeData(vtkMultiBlockDataSet* dataset
}
this->Controller->Broadcast(stream, 0);
dataset->ShallowCopy(mb);
dataset->CompositeShallowCopy(mb);
} // end rank 0
}
VTK_ABI_NAMESPACE_END

@ -37,7 +37,7 @@ vtkCxxSetObjectMacro(vtkPartitionBalancer, Controller, vtkMultiProcessController
namespace
{
//------------------------------------------------------------------------------
void ShallowCopy(vtkPartitionedDataSet* inputPDS, vtkPartitionedDataSet* outputPDS,
void CompositeShallowCopy(vtkPartitionedDataSet* inputPDS, vtkPartitionedDataSet* outputPDS,
int numberOfNonNullPartitionsInInput, int offset = 0)
{
for (int outPartitionId = 0, inPartitionId = 0; outPartitionId < numberOfNonNullPartitionsInInput;
@ -87,7 +87,7 @@ int vtkPartitionBalancer::RequestData(
if (!this->Controller)
{
outputPDS->ShallowCopy(inputPDS);
outputPDS->CompositeShallowCopy(inputPDS);
outputPDS->RemoveNullPartitions();
return 1;
}
@ -103,14 +103,14 @@ int vtkPartitionBalancer::RequestData(
const int offset = std::accumulate(recvBuf.begin(), recvBuf.begin() + localProcessId, 0);
outputPDS->SetNumberOfPartitions(numberOfPartitions);
ShallowCopy(inputPDS, outputPDS, numberOfNonNullPartitionsInInput, offset);
::CompositeShallowCopy(inputPDS, outputPDS, numberOfNonNullPartitionsInInput, offset);
}
else if (this->Mode == vtkPartitionBalancer::Squash)
{
const int numberOfPartitions = *std::max_element(recvBuf.begin(), recvBuf.end());
outputPDS->SetNumberOfPartitions(numberOfPartitions);
ShallowCopy(inputPDS, outputPDS, numberOfNonNullPartitionsInInput);
::CompositeShallowCopy(inputPDS, outputPDS, numberOfNonNullPartitionsInInput);
}
else
{

@ -101,7 +101,7 @@ int vtkPeriodicFilter::RequestData(vtkInformation* vtkNotUsed(request),
else if (this->Indices.empty())
{
// Trivial case
output->ShallowCopy(input);
output->CompositeShallowCopy(input);
return 1;
}

@ -710,7 +710,7 @@ int vtkExtractSubsetWithSeed::RequestData(
// now, put the pieces in output_blocks in the output MB.
// we use a trick, copy into to output and then replace
outputMB->ShallowCopy(inputMB);
outputMB->CompositeShallowCopy(inputMB);
std::function<vtkDataObject*(vtkDataObject*)> replaceLeaves;
replaceLeaves = [&replaceLeaves, &input_dataset_map, &output_blocks](

@ -499,25 +499,30 @@ int vtkRedistributeDataSetFilter::RequestData(
// ******************************************************
// Now, package the result into the output.
// ******************************************************
if (vtkPartitionedDataSetCollection::SafeDownCast(outputDO))
vtkPartitionedDataSetCollection* outputPDSC =
vtkPartitionedDataSetCollection::SafeDownCast(outputDO);
vtkPartitionedDataSet* outputPDS = vtkPartitionedDataSet::SafeDownCast(outputDO);
vtkMultiBlockDataSet* outputMB = vtkMultiBlockDataSet::SafeDownCast(outputDO);
if (outputPDSC)
{
outputDO->ShallowCopy(result);
outputPDSC->CompositeShallowCopy(result);
}
else if (vtkPartitionedDataSet::SafeDownCast(outputDO))
else if (outputPDS)
{
assert(result->GetNumberOfPartitionedDataSets() <= 1);
if (result->GetNumberOfPartitionedDataSets() == 1)
{
outputDO->ShallowCopy(result->GetPartitionedDataSet(0));
outputPDS->CompositeShallowCopy(result->GetPartitionedDataSet(0));
}
}
else if (vtkMultiBlockDataSet::SafeDownCast(outputDO))
else if (outputMB)
{
// convert result (vtkPartitionedDataSetCollection) to vtkMultiBlockDataSet.
if (auto mbresult = vtkDataAssemblyUtilities::GenerateCompositeDataSetFromHierarchy(
result, result->GetDataAssembly()))
{
outputDO->ShallowCopy(mbresult);
outputMB->CompositeShallowCopy(mbresult);
}
else
{
@ -734,7 +739,7 @@ bool vtkRedistributeDataSetFilter::Redistribute(vtkPartitionedDataSet* inputPDS,
if (this->GenerateGlobalCellIds)
{
auto result = this->AssignGlobalCellIds(outputPDS, mb_offset);
outputPDS->ShallowCopy(result);
outputPDS->CompositeShallowCopy(result);
}
break;
@ -784,7 +789,7 @@ bool vtkRedistributeDataSetFilter::RedistributeDataSet(
auto pieces = vtkDIYKdTreeUtilities::Exchange(parts, this->GetController(), this->Assigner);
assert(pieces->GetNumberOfPartitions() == parts->GetNumberOfPartitions());
outputPDS->ShallowCopy(pieces);
outputPDS->CompositeShallowCopy(pieces);
return true;
}

@ -106,13 +106,13 @@ protected:
return 0;
}
output->ShallowCopy(input);
output->DeepCopy(input);
for (unsigned int level = 0; level < input->GetNumberOfLevels(); ++level)
for (unsigned int level = 0; level < output->GetNumberOfLevels(); ++level)
{
for (unsigned int idx = 0; idx < input->GetNumberOfDataSets(level); ++idx)
for (unsigned int idx = 0; idx < output->GetNumberOfDataSets(level); ++idx)
{
vtkUniformGrid* grid = input->GetDataSet(level, idx);
vtkUniformGrid* grid = output->GetDataSet(level, idx);
if (!grid)
{
continue;

@ -1111,7 +1111,7 @@ bool vtkPLagrangianParticleTracker::UpdateSurfaceCacheIfNeeded(vtkDataObject*& s
{
// Rank 0 reconstruct Composite tree
vtkCompositeDataSet* mb = vtkCompositeDataSet::SafeDownCast(surfaces);
this->TmpSurfaceInputMB->ShallowCopy(mb);
this->TmpSurfaceInputMB->CompositeShallowCopy(mb);
vtkCompositeDataIterator* iter = mb->NewIterator();
iter->SkipEmptyNodesOff();
for (iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())

@ -148,7 +148,8 @@ int vtkStreamingStatistics::RequestData(
// Shallow copy the internal output to external output
outData->ShallowCopy(this->StatisticsAlgorithm->GetOutput(OUTPUT_DATA));
outModel->ShallowCopy(this->StatisticsAlgorithm->GetOutputDataObject(OUTPUT_MODEL));
outModel->CompositeShallowCopy(vtkCompositeDataSet::SafeDownCast(
this->StatisticsAlgorithm->GetOutputDataObject(OUTPUT_MODEL)));
outTest->ShallowCopy(this->StatisticsAlgorithm->GetOutput(OUTPUT_TEST));
return 1;

@ -500,7 +500,7 @@ int vtkCGNSFileSeriesReader::RequestData(
vtkMultiBlockDataSet* output = vtkMultiBlockDataSet::GetData(outputVector, 0);
output->Initialize();
output->ShallowCopy(hierarchy.Get());
output->CompositeShallowCopy(vtkMultiBlockDataSet::SafeDownCast(hierarchy.Get()));
return 1;
}
VTK_ABI_NAMESPACE_END

@ -288,7 +288,8 @@ int vtkGenericEnSightReader::RequestData(vtkInformation* vtkNotUsed(request),
vtkNew<vtkDataSetTriangleFilter> tetrahedralizeFilter;
tetrahedralizeFilter->SetInputData(output);
tetrahedralizeFilter->Update();
output->ShallowCopy(tetrahedralizeFilter->GetOutputDataObject(0));
output->CompositeShallowCopy(
vtkMultiBlockDataSet::SafeDownCast(tetrahedralizeFilter->GetOutputDataObject(0)));
}
return 1;

@ -882,7 +882,7 @@ int vtkGLTFReader::RequestData(
// Save current animations
this->PreviousAnimationSelection->CopySelections(this->AnimationSelection);
output->ShallowCopy(this->OutputDataSet);
output->CompositeShallowCopy(this->OutputDataSet);
return 1;
}

@ -946,7 +946,7 @@ int vtkSLACReader::RequestData(vtkInformation* request,
}
}
this->Internal->MeshCache->ShallowCopy(compositeOutput);
this->Internal->MeshCache->CompositeShallowCopy(compositeOutput);
this->Internal->PointCache = points;
this->MeshReadTime.Modified();
}
@ -1760,8 +1760,10 @@ int vtkSLACReader::MeshUpToDate()
int vtkSLACReader::RestoreMeshCache(vtkMultiBlockDataSet* surfaceOutput,
vtkMultiBlockDataSet* volumeOutput, vtkMultiBlockDataSet* compositeOutput)
{
surfaceOutput->ShallowCopy(this->Internal->MeshCache->GetBlock(SURFACE_OUTPUT));
volumeOutput->ShallowCopy(this->Internal->MeshCache->GetBlock(VOLUME_OUTPUT));
surfaceOutput->CompositeShallowCopy(
vtkCompositeDataSet::SafeDownCast(this->Internal->MeshCache->GetBlock(SURFACE_OUTPUT)));
volumeOutput->CompositeShallowCopy(
vtkCompositeDataSet::SafeDownCast(this->Internal->MeshCache->GetBlock(VOLUME_OUTPUT)));
// Shove two outputs in composite output.
compositeOutput->SetNumberOfBlocks(2);

@ -675,7 +675,7 @@ int vtkPOpenFOAMReader::RequestData(
// reader->RequestInformation() and RequestData() are called
// for all reader instances without setting UPDATE_TIME_STEPS
append->Update();
output->ShallowCopy(append->GetOutput());
output->CompositeShallowCopy(append->GetOutput());
}
append->Delete();

@ -467,8 +467,8 @@ int vtkPlot3DMetaReader::RequestData(
this->Reader->UpdatePiece(outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()),
outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES()),
outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_GHOST_LEVELS()));
vtkDataObject* ioutput = this->Reader->GetOutput();
output->ShallowCopy(ioutput);
vtkMultiBlockDataSet* ioutput = this->Reader->GetOutput();
output->CompositeShallowCopy(ioutput);
output->GetInformation()->Set(vtkDataObject::DATA_NUMBER_OF_GHOST_LEVELS(),
ioutput->GetInformation()->Get(vtkDataObject::DATA_NUMBER_OF_GHOST_LEVELS()));
}

@ -662,7 +662,7 @@ int vtkPExodusIIReader::RequestData(vtkInformation* vtkNotUsed(request),
if (append->GetNumberOfInputConnections(0) != 0)
{
append->Update();
output->ShallowCopy(append->GetOutput());
output->CompositeShallowCopy(append->GetOutput());
}
// I've copied append's output to the 'output' so delete append

@ -46,7 +46,7 @@ vtkSmartPointer<vtkCompositeDataSet> EnsureComposite(vtkDataObject* dobj)
toComposite->Update();
auto outCds = vtkCompositeDataSet::SafeDownCast(toComposite->GetOutputDataObject(0));
auto cds = vtkSmartPointer<vtkCompositeDataSet>::Take(outCds->NewInstance());
cds->ShallowCopy(outCds);
cds->CompositeShallowCopy(outCds);
return cds;
}

@ -118,7 +118,7 @@ protected:
group->AddInputData(pd2);
group->Update();
output->ShallowCopy(group->GetOutput());
output->CompositeShallowCopy(group->GetOutput());
return 1;
}

Loading…
Cancel
Save