------------------------------------------------------------------------------ Returns true if we need to read the data for the current time step
| 1954 | //------------------------------------------------------------------------------ |
| 1955 | // Returns true if we need to read the data for the current time step |
| 1956 | int vtkXMLUnstructuredDataReader::CellsNeedToReadTimeStep( |
| 1957 | vtkXMLDataElement* eNested, int& cellstimestep, unsigned long& cellsoffset) |
| 1958 | { |
| 1959 | // Easy case no timestep: |
| 1960 | int numTimeSteps = |
| 1961 | eNested->GetVectorAttribute("TimeStep", this->NumberOfTimeSteps, this->TimeSteps); |
| 1962 | assert(numTimeSteps <= this->NumberOfTimeSteps); |
| 1963 | if (!numTimeSteps && !this->NumberOfTimeSteps) |
| 1964 | { |
| 1965 | assert(cellstimestep == -1); // No timestep in this file |
| 1966 | return 1; |
| 1967 | } |
| 1968 | // else TimeStep was specified but no TimeValues associated were found |
| 1969 | assert(!this->NumberOfTimeSteps); |
| 1970 | |
| 1971 | // case numTimeSteps > 1 |
| 1972 | int isCurrentTimeInArray = |
| 1973 | vtkXMLReader::IsTimeStepInArray(this->CurrentTimeStep, this->TimeSteps, numTimeSteps); |
| 1974 | if (!isCurrentTimeInArray && numTimeSteps) |
| 1975 | { |
| 1976 | return 0; |
| 1977 | } |
| 1978 | // we know that time steps are specified and that CurrentTimeStep is in the array |
| 1979 | // we need to figure out if we need to read the array or if it was forwarded |
| 1980 | // Need to check the current 'offset' |
| 1981 | unsigned long offset; |
| 1982 | if (eNested->GetScalarAttribute("offset", offset)) |
| 1983 | { |
| 1984 | if (cellsoffset != offset) |
| 1985 | { |
| 1986 | // save the cellsOffset we are about to read |
| 1987 | assert(cellstimestep == -1); // cannot have mixture of binary and appended |
| 1988 | cellsoffset = offset; |
| 1989 | return 1; |
| 1990 | } |
| 1991 | } |
| 1992 | else |
| 1993 | { |
| 1994 | // No offset is specified this is a binary file |
| 1995 | // First thing to check if numTimeSteps == 0: |
| 1996 | if (!numTimeSteps && this->NumberOfTimeSteps && cellstimestep == -1) |
| 1997 | { |
| 1998 | // Update last PointsTimeStep read |
| 1999 | cellstimestep = this->CurrentTimeStep; |
| 2000 | return 1; |
| 2001 | } |
| 2002 | int isLastTimeInArray = |
| 2003 | vtkXMLReader::IsTimeStepInArray(cellstimestep, this->TimeSteps, numTimeSteps); |
| 2004 | // If no time is specified or if time is specified and match then read |
| 2005 | if (isCurrentTimeInArray && !isLastTimeInArray) |
| 2006 | { |
| 2007 | // CurrentTimeStep is in TimeSteps but Last is not := need to read |
| 2008 | // Update last cellstimestep read |
| 2009 | cellstimestep = this->CurrentTimeStep; |
| 2010 | return 1; |
| 2011 | } |
| 2012 | } |
| 2013 | // all other cases we don't need to read: |
nothing calls this directly
no test coverage detected