------------------------------------------------------------------------------
| 82 | |
| 83 | //------------------------------------------------------------------------------ |
| 84 | void vtkXMLPartitionedDataSetCollectionReader::ReadComposite(vtkXMLDataElement* element, |
| 85 | vtkCompositeDataSet* composite, const char* filePath, unsigned int& dataSetIndex) |
| 86 | { |
| 87 | vtkPartitionedDataSetCollection* col = vtkPartitionedDataSetCollection::SafeDownCast(composite); |
| 88 | vtkPartitionedDataSet* ds = vtkPartitionedDataSet::SafeDownCast(composite); |
| 89 | if (!col && !ds) |
| 90 | { |
| 91 | vtkErrorMacro("Unsupported composite dataset."); |
| 92 | return; |
| 93 | } |
| 94 | |
| 95 | // count partitions to guide partition allocation when reading in parallel. |
| 96 | const unsigned int numberOfParitions = |
| 97 | ds ? vtkXMLCompositeDataReader::CountNestedElements(element, "DataSet") : 0; |
| 98 | |
| 99 | unsigned int maxElems = element->GetNumberOfNestedElements(); |
| 100 | for (unsigned int cc = 0; cc < maxElems; ++cc) |
| 101 | { |
| 102 | vtkXMLDataElement* childXML = element->GetNestedElement(cc); |
| 103 | if (!childXML || !childXML->GetName()) |
| 104 | { |
| 105 | continue; |
| 106 | } |
| 107 | |
| 108 | int index = 0; |
| 109 | if (!childXML->GetScalarAttribute("index", index)) |
| 110 | // if index not in the structure file, then |
| 111 | // set up to add at the end |
| 112 | { |
| 113 | if (col) |
| 114 | { |
| 115 | index = col->GetNumberOfPartitionedDataSets(); |
| 116 | } |
| 117 | else if (ds) |
| 118 | { |
| 119 | index = ds->GetNumberOfPartitions(); |
| 120 | } |
| 121 | } |
| 122 | // child is a leaf node, read and insert. |
| 123 | const char* tagName = childXML->GetName(); |
| 124 | if (strcmp(tagName, "DataSet") == 0) |
| 125 | { |
| 126 | vtkSmartPointer<vtkDataObject> childDS; |
| 127 | if (this->ShouldReadDataSet(dataSetIndex, index, numberOfParitions)) |
| 128 | { |
| 129 | // Read |
| 130 | childDS.TakeReference(this->ReadDataObject(childXML, filePath)); |
| 131 | } |
| 132 | // insert |
| 133 | ds->SetPartition(index, childDS); |
| 134 | dataSetIndex++; |
| 135 | } |
| 136 | else if (col != nullptr && strcmp(tagName, "Partitions") == 0) |
| 137 | { |
| 138 | vtkPartitionedDataSet* childDS = vtkPartitionedDataSet::New(); |
| 139 | this->ReadComposite(childXML, childDS, filePath, dataSetIndex); |
| 140 | col->SetPartitionedDataSet(index, childDS); |
| 141 | childDS->Delete(); |
nothing calls this directly
no test coverage detected