------------------------------------------------------------------------------
| 626 | |
| 627 | //------------------------------------------------------------------------------ |
| 628 | int vtkXMLDataReader::CellDataNeedToReadTimeStep(vtkXMLDataElement* eNested) |
| 629 | { |
| 630 | // First thing need to find the id of this dataarray from its name: |
| 631 | const char* name = eNested->GetAttribute("Name"); |
| 632 | |
| 633 | // Easy case no timestep: |
| 634 | int numTimeSteps = |
| 635 | eNested->GetVectorAttribute("TimeStep", this->NumberOfTimeSteps, this->TimeSteps); |
| 636 | if (!(numTimeSteps <= this->NumberOfTimeSteps)) |
| 637 | { |
| 638 | vtkErrorMacro("Invalid TimeSteps specification"); |
| 639 | this->DataError = 1; |
| 640 | return 0; |
| 641 | } |
| 642 | if (!numTimeSteps && !this->NumberOfTimeSteps) |
| 643 | { |
| 644 | assert(this->CellDataTimeStep->at(name) == -1); // No timestep in this file |
| 645 | return 1; |
| 646 | } |
| 647 | // else TimeStep was specified but no TimeValues associated were found |
| 648 | assert(this->NumberOfTimeSteps); |
| 649 | |
| 650 | // case numTimeSteps > 1 |
| 651 | int isCurrentTimeInArray = |
| 652 | vtkXMLReader::IsTimeStepInArray(this->CurrentTimeStep, this->TimeSteps, numTimeSteps); |
| 653 | if (numTimeSteps && !isCurrentTimeInArray) |
| 654 | { |
| 655 | return 0; |
| 656 | } |
| 657 | // we know that time steps are specified and that CurrentTimeStep is in the array |
| 658 | // we need to figure out if we need to read the array or if it was forwarded |
| 659 | // Need to check the current 'offset' |
| 660 | vtkTypeInt64 offset; |
| 661 | if (eNested->GetScalarAttribute("offset", offset)) |
| 662 | { |
| 663 | if (this->CellDataOffset->at(name) != offset) |
| 664 | { |
| 665 | // save the pointsOffset |
| 666 | assert(this->CellDataTimeStep->at(name) == -1); // cannot have mixture of binary and appended |
| 667 | this->CellDataOffset->at(name) = offset; |
| 668 | return 1; |
| 669 | } |
| 670 | } |
| 671 | else |
| 672 | { |
| 673 | // No offset is specified this is a binary file |
| 674 | // First thing to check if numTimeSteps == 0: |
| 675 | if (!numTimeSteps && this->NumberOfTimeSteps && this->CellDataTimeStep->at(name) == -1) |
| 676 | { |
| 677 | // Update last CellDataTimeStep read |
| 678 | this->CellDataTimeStep->at(name) = this->CurrentTimeStep; |
| 679 | return 1; |
| 680 | } |
| 681 | int isLastTimeInArray = vtkXMLReader::IsTimeStepInArray( |
| 682 | this->CellDataTimeStep->at(name), this->TimeSteps, numTimeSteps); |
| 683 | // If no time is specified or if time is specified and match then read |
| 684 | if (isCurrentTimeInArray && !isLastTimeInArray) |
| 685 | { |
no test coverage detected