------------------------------------------------------------------------------
| 83 | |
| 84 | //------------------------------------------------------------------------------ |
| 85 | void vtkXMLMultiBlockDataReader::ReadComposite(vtkXMLDataElement* element, |
| 86 | vtkCompositeDataSet* composite, const char* filePath, unsigned int& dataSetIndex) |
| 87 | { |
| 88 | vtkMultiBlockDataSet* mblock = vtkMultiBlockDataSet::SafeDownCast(composite); |
| 89 | vtkMultiPieceDataSet* mpiece = vtkMultiPieceDataSet::SafeDownCast(composite); |
| 90 | if (!mblock && !mpiece) |
| 91 | { |
| 92 | vtkErrorMacro("Unsupported composite dataset."); |
| 93 | return; |
| 94 | } |
| 95 | |
| 96 | if (this->GetFileMajorVersion() < 1) |
| 97 | { |
| 98 | // Read legacy file. |
| 99 | this->ReadVersion0(element, composite, filePath, dataSetIndex); |
| 100 | return; |
| 101 | } |
| 102 | |
| 103 | // count how may piece in total are there when reading a multi-piece. |
| 104 | // This helps with distribution of the pieces. |
| 105 | const unsigned int numPieces = (mpiece && this->DistributePiecesInMultiPieces) |
| 106 | ? vtkXMLCompositeDataReader::CountNestedElements(element, "DataSet") |
| 107 | : 0; |
| 108 | |
| 109 | const unsigned int maxElems = element->GetNumberOfNestedElements(); |
| 110 | for (unsigned int cc = 0; cc < maxElems; ++cc) |
| 111 | { |
| 112 | vtkXMLDataElement* childXML = element->GetNestedElement(cc); |
| 113 | if (!childXML || !childXML->GetName()) |
| 114 | { |
| 115 | continue; |
| 116 | } |
| 117 | |
| 118 | int index = 0; |
| 119 | if (!childXML->GetScalarAttribute("index", index)) |
| 120 | // if index not in the structure file, then |
| 121 | // set up to add at the end |
| 122 | { |
| 123 | if (mblock) |
| 124 | { |
| 125 | index = mblock->GetNumberOfBlocks(); |
| 126 | } |
| 127 | else if (mpiece) |
| 128 | { |
| 129 | index = mpiece->GetNumberOfPieces(); |
| 130 | } |
| 131 | } |
| 132 | // child is a leaf node, read and insert. |
| 133 | const char* tagName = childXML->GetName(); |
| 134 | if (strcmp(tagName, "DataSet") == 0) |
| 135 | { |
| 136 | vtkSmartPointer<vtkDataObject> childDS; |
| 137 | const char* name = childXML->GetAttribute("name"); |
| 138 | if (this->ShouldReadDataSet(dataSetIndex, index, numPieces)) |
| 139 | { |
| 140 | // Read |
| 141 | childDS.TakeReference(this->ReadDataObject(childXML, filePath)); |
| 142 | } |
no test coverage detected