------------------------------------------------------------------------------
| 356 | |
| 357 | //------------------------------------------------------------------------------ |
| 358 | void vtkXMLPTableReader::ReadXMLData() |
| 359 | { |
| 360 | // Get the update request. |
| 361 | vtkInformation* outInfo = this->GetCurrentOutputInformation(); |
| 362 | int piece = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_PIECE_NUMBER()); |
| 363 | int numberOfPieces = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_NUMBER_OF_PIECES()); |
| 364 | |
| 365 | vtkDebugMacro("Updating piece " << piece << " of " << numberOfPieces); |
| 366 | |
| 367 | // Setup the range of pieces that will be read. |
| 368 | this->SetupUpdateExtent(piece, numberOfPieces); |
| 369 | |
| 370 | // If there are no data to read, stop now. |
| 371 | if (this->StartPiece == this->EndPiece) |
| 372 | { |
| 373 | return; |
| 374 | } |
| 375 | |
| 376 | vtkDebugMacro( |
| 377 | "Reading piece range [" << this->StartPiece << ", " << this->EndPiece << ") from file."); |
| 378 | |
| 379 | // Let superclasses read data. This also allocates output data. |
| 380 | this->Superclass::ReadXMLData(); |
| 381 | |
| 382 | // Split current progress range based on fraction contributed by |
| 383 | // each piece. |
| 384 | float progressRange[2] = { 0.f, 0.f }; |
| 385 | this->GetProgressRange(progressRange); |
| 386 | |
| 387 | // Calculate the cumulative fraction of data contributed by each |
| 388 | // piece (for progress). |
| 389 | std::vector<float> fractions(this->EndPiece - this->StartPiece + 1); |
| 390 | fractions[0] = 0; |
| 391 | for (int i = this->StartPiece; i < this->EndPiece; ++i) |
| 392 | { |
| 393 | int index = i - this->StartPiece; |
| 394 | fractions[index + 1] = (fractions[index] + this->GetNumberOfRowsInPiece(i)); |
| 395 | } |
| 396 | if (fractions[this->EndPiece - this->StartPiece] == 0) |
| 397 | { |
| 398 | fractions[this->EndPiece - this->StartPiece] = 1; |
| 399 | } |
| 400 | for (int i = this->StartPiece; i < this->EndPiece; ++i) |
| 401 | { |
| 402 | int index = i - this->StartPiece; |
| 403 | fractions[index + 1] = fractions[index + 1] / fractions[this->EndPiece - this->StartPiece]; |
| 404 | } |
| 405 | |
| 406 | // Read the data needed from each piece. |
| 407 | for (int i = this->StartPiece; (i < this->EndPiece && !this->AbortExecute && !this->DataError); |
| 408 | ++i) |
| 409 | { |
| 410 | // Set the range of progress for this piece. |
| 411 | this->SetProgressRange(progressRange, i - this->StartPiece, fractions.data()); |
| 412 | |
| 413 | if (!this->ReadPieceData(i)) |
| 414 | { |
| 415 | // An error occurred while reading the piece. |
nothing calls this directly
no test coverage detected