------------------------------------------------------------------------------
| 217 | |
| 218 | //------------------------------------------------------------------------------ |
| 219 | int vtkXMLMultiBlockDataReader::FillMetaData(vtkCompositeDataSet* metadata, |
| 220 | vtkXMLDataElement* element, const std::string& filePath, unsigned int& dataSetIndex) |
| 221 | { |
| 222 | vtkMultiBlockDataSet* mblock = vtkMultiBlockDataSet::SafeDownCast(metadata); |
| 223 | vtkMultiPieceDataSet* mpiece = vtkMultiPieceDataSet::SafeDownCast(metadata); |
| 224 | |
| 225 | // count how may piece in total are there when reading a multi-piece. |
| 226 | // This helps with distribution of the pieces. |
| 227 | const unsigned int numPieces = (mpiece && this->DistributePiecesInMultiPieces) |
| 228 | ? vtkXMLCompositeDataReader::CountNestedElements(element, "DataSet") |
| 229 | : 0; |
| 230 | |
| 231 | const unsigned int maxElems = element->GetNumberOfNestedElements(); |
| 232 | for (unsigned int cc = 0; cc < maxElems; ++cc) |
| 233 | { |
| 234 | vtkXMLDataElement* childXML = element->GetNestedElement(cc); |
| 235 | if (!childXML || !childXML->GetName()) |
| 236 | { |
| 237 | continue; |
| 238 | } |
| 239 | |
| 240 | int index = 0; |
| 241 | if (!childXML->GetScalarAttribute("index", index)) |
| 242 | // if index not in the structure file, then |
| 243 | // set up to add at the end |
| 244 | { |
| 245 | if (mblock) |
| 246 | { |
| 247 | index = mblock->GetNumberOfBlocks(); |
| 248 | } |
| 249 | else if (mpiece) |
| 250 | { |
| 251 | index = mpiece->GetNumberOfPieces(); |
| 252 | } |
| 253 | } |
| 254 | // child is a leaf node, read and insert. |
| 255 | const char* tagName = childXML->GetName(); |
| 256 | if (strcmp(tagName, "DataSet") == 0) |
| 257 | { |
| 258 | vtkInformation* piece_metadata = CreateMetaDataIfNecessary(mblock, mpiece, index); |
| 259 | double bounding_box[6]; |
| 260 | if (childXML->GetVectorAttribute("bounding_box", 6, bounding_box) == 6) |
| 261 | { |
| 262 | if (piece_metadata) |
| 263 | { |
| 264 | piece_metadata->Set(vtkDataObject::BOUNDING_BOX(), bounding_box, 6); |
| 265 | } |
| 266 | } |
| 267 | int extent[6]; |
| 268 | if (childXML->GetVectorAttribute("extent", 6, extent) == 6) |
| 269 | { |
| 270 | if (piece_metadata) |
| 271 | { |
| 272 | piece_metadata->Set(vtkDataObject::PIECE_EXTENT(), extent, 6); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | if (this->ShouldReadDataSet(dataSetIndex, index, numPieces)) |
no test coverage detected