vtkCompositeDataIterator has no metadata while it is expected
I'm trying to use a composite data iterator on a vtkPartitionedDataSetCollection
to retrieve the data and the metadata. I find that when I use the iterator, the metadata is not found. Am I doing something wrong (and if so, how to do this with an iterator?) or is this a bug?
Note that this is also happens with vtkMultiBlockDataSet
.
Below a test that can be run as part of Common/DataModel/Testing/Cxx
that fails in the for-loop of the iterator.
#include <vtkDataObjectTreeIterator.h>
#include <vtkInformation.h>
#include <vtkLogger.h>
#include <vtkMappedUnstructuredGridGenerator.h>
#include <vtkNew.h>
#include <vtkPartitionedDataSetCollection.h>
#include <vtkSmartPointer.h>
#include <vtkUnstructuredGrid.h>
int TestPartitionedDataSetCollectionMetaData(int, char*[])
{
vtkUnstructuredGrid*unstructuredGrid1(nullptr), *unstructuredGrid2(nullptr);
vtkMappedUnstructuredGridGenerator::GenerateUnstructuredGrid(&unstructuredGrid1);
vtkMappedUnstructuredGridGenerator::GenerateUnstructuredGrid(&unstructuredGrid2);
vtkNew<vtkPartitionedDataSetCollection> partitionedCollection;
partitionedCollection->SetNumberOfPartitionedDataSets(2);
partitionedCollection->SetPartition(0u, 0, unstructuredGrid1);
partitionedCollection->SetPartition(1u, 0, unstructuredGrid2);
partitionedCollection->GetMetaData(0u)->Set(vtkCompositeDataSet::NAME(), "GRID_1");
partitionedCollection->GetMetaData(1u)->Set(vtkCompositeDataSet::NAME(), "GRID_2");
vtkLogIfF(ERROR, 1 != partitionedCollection->GetMetaData(0u)->GetNumberOfKeys(),
"Expected 1 key in the partitioned metadata");
vtkLogIfF(ERROR, 1 != partitionedCollection->GetMetaData(1u)->GetNumberOfKeys(),
"Expected 1 key in the partitioned metadata");
auto iter = vtkSmartPointer<vtkDataObjectTreeIterator>
::Take(partitionedCollection->NewTreeIterator());
for(iter->InitTraversal(); !iter->IsDoneWithTraversal(); iter->GoToNextItem())
{
vtkLogIfF(ERROR, !iter->HasCurrentMetaData(), "Metadata expected for the iterator");
auto md = iter->GetCurrentMetaData();
vtkLogIfF(ERROR, 1 != md->GetNumberOfKeys(), "Expected 1 key in the iterator metadata");
}
unstructuredGrid1->Delete();
unstructuredGrid2->Delete();
return EXIT_SUCCESS;
}