MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadPieceData

Method ReadPieceData

IO/XML/vtkXMLUnstructuredDataReader.cxx:455–523  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

453
454//------------------------------------------------------------------------------
455int vtkXMLUnstructuredDataReader::ReadPieceData()
456{
457 // The amount of data read by the superclass's ReadPieceData comes
458 // from point/cell data (we read point specifications here).
459 vtkIdType superclassPieceSize =
460 (this->NumberOfPointArrays * this->GetNumberOfPointsInPiece(this->Piece) +
461 this->NumberOfCellArrays * this->GetNumberOfCellsInPiece(this->Piece));
462
463 // Total amount of data in this piece comes from point/cell data
464 // arrays and the point specifications themselves.
465 vtkIdType totalPieceSize = superclassPieceSize + 1 * this->GetNumberOfPointsInPiece(this->Piece);
466 if (totalPieceSize == 0)
467 {
468 totalPieceSize = 1;
469 }
470
471 // Split the progress range based on the approximate fraction of
472 // data that will be read by each step in this method.
473 float progressRange[2] = { 0, 0 };
474 this->GetProgressRange(progressRange);
475 float fractions[3] = { 0, float(superclassPieceSize) / totalPieceSize, 1 };
476
477 // Set the range of progress for the superclass.
478 this->SetProgressRange(progressRange, 0, fractions);
479
480 // Let the superclass read its data.
481 if (!this->Superclass::ReadPieceData())
482 {
483 return 0;
484 }
485
486 vtkPointSet* output = vtkPointSet::SafeDownCast(this->GetCurrentOutput());
487
488 // Set the range of progress for the Points.
489 this->SetProgressRange(progressRange, 1, fractions);
490
491 // Read the points array.
492 vtkXMLDataElement* ePoints = this->PointElements[this->Piece];
493 if (ePoints)
494 {
495 for (int i = 0; (i < ePoints->GetNumberOfNestedElements() && !this->AbortExecute); ++i)
496 {
497 vtkXMLDataElement* eNested = ePoints->GetNestedElement(i);
498 if (strcmp(eNested->GetName(), "DataArray") != 0 && strcmp(eNested->GetName(), "Array") != 0)
499 {
500 vtkErrorMacro("Invalid Array.");
501 this->DataError = 1;
502 return 0;
503 }
504 int needToRead = this->PointsNeedToReadTimeStep(eNested);
505 if (needToRead)
506 {
507 // Read the array. Test for abort before and after the read. Before
508 // so that we can skip the read, after to prevent unwanted error
509 // messages.
510 if (!this->AbortExecute &&
511 !this->ReadArrayForPoints(eNested, output->GetPoints()->GetData()) && !this->AbortExecute)
512 {

Callers

nothing calls this directly

Calls 12

ReadArrayForPointsMethod · 0.95
GetCurrentOutputMethod · 0.80
GetNestedElementMethod · 0.80
GetProgressRangeMethod · 0.45
SetProgressRangeMethod · 0.45
GetNameMethod · 0.45
GetDataMethod · 0.45
GetPointsMethod · 0.45

Tested by

no test coverage detected