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

Method ReadCellArray

IO/XML/vtkXMLUnstructuredDataReader.cxx:632–908  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

630
631//------------------------------------------------------------------------------
632int vtkXMLUnstructuredDataReader::ReadCellArray(vtkIdType numberOfCells,
633 vtkIdType vtkNotUsed(totalNumberOfCells), vtkXMLDataElement* eCells, vtkCellArray* outCells)
634{
635 // This part is here to determine if we need to read the cell array.
636 // If the cell array was already generated in a previous time step, there's no need recreating it.
637 // However, within a same time step, multiple pieces can be present. We need to read them all.
638 // The logic works as follows:
639 // * If there's no output geometry yet, it means we need to create it. We save the current time
640 // step to know in which time step the cell array is being read.
641 // * If there's already geometry, we either are in a new time step and nothing needs to be done,
642 // or we're still in the time step used to create the geometry in a new piece and we need to
643 // read it.
644 // We quit the "create geometry mode" if the cell array time step becomes different than the
645 // current time step.
646 if ((this->ReadFromInputString &&
647 this->CellArrayCachedInputString != this->InputString.c_str()) ||
648 (!this->ReadFromInputString && this->CellArrayCachedFileName != this->FileName))
649 {
650 // We wipe the geometry if a new file or new input string is to be read.
651 outCells->Initialize();
652 if (this->ReadFromInputString)
653 {
654 this->CellArrayCachedInputString = this->InputString.c_str();
655 }
656 else
657 {
658 this->CellArrayCachedFileName = this->FileName;
659 }
660 }
661 if (outCells->GetNumberOfCells() == 0)
662 {
663 this->CellArrayTimeStepRead = this->CurrentTimeStep;
664 this->CanReadCellArray = true;
665 }
666 if (this->CellArrayTimeStepRead != this->CurrentTimeStep)
667 {
668 this->CanReadCellArray = false;
669 }
670 if (!this->CanReadCellArray || numberOfCells <= 0)
671 {
672 return 1;
673 }
674 else
675 {
676 if (!eCells)
677 {
678 return 0;
679 }
680 }
681
682 // Split progress range into 1/5 for offsets array and 4/5 for
683 // connectivity array. This assumes an average of 4 points per
684 // cell. Unfortunately, we cannot know the length of the
685 // connectivity array ahead of time to calculate the real fraction.
686 float progressRange[2] = { 0, 0 };
687 this->GetProgressRange(progressRange);
688 float fractions[3] = { 0, 0.2f, 1 };
689

Callers 2

ReadPieceDataMethod · 0.80
ReadPieceDataMethod · 0.80

Calls 15

MatchArrayTypesFunction · 0.85
FindDataArrayWithNameMethod · 0.80
IsAMethod · 0.80
ReadArrayValuesMethod · 0.80
ExecuteFunction · 0.50
NewFunction · 0.50
c_strMethod · 0.45
InitializeMethod · 0.45
GetNumberOfCellsMethod · 0.45
GetProgressRangeMethod · 0.45
SetProgressRangeMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected