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

Method PointsNeedToReadTimeStep

IO/XML/vtkXMLUnstructuredDataReader.cxx:1894–1952  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1892
1893//------------------------------------------------------------------------------
1894int vtkXMLUnstructuredDataReader::PointsNeedToReadTimeStep(vtkXMLDataElement* eNested)
1895{
1896 // Easy case no timestep:
1897 int numTimeSteps =
1898 eNested->GetVectorAttribute("TimeStep", this->NumberOfTimeSteps, this->TimeSteps);
1899 assert(numTimeSteps <= this->NumberOfTimeSteps);
1900 if (!numTimeSteps && !this->NumberOfTimeSteps)
1901 {
1902 assert(this->PointsTimeStep == -1); // No timestep in this file
1903 return 1;
1904 }
1905 // else TimeStep was specified but no TimeValues associated were found
1906 assert(this->NumberOfTimeSteps);
1907
1908 // case numTimeSteps > 1
1909 int isCurrentTimeInArray =
1910 vtkXMLReader::IsTimeStepInArray(this->CurrentTimeStep, this->TimeSteps, numTimeSteps);
1911 if (!isCurrentTimeInArray && numTimeSteps)
1912 {
1913 return 0;
1914 }
1915 // we know that time steps are specified and that CurrentTimeStep is in the array
1916 // we need to figure out if we need to read the array or if it was forwarded
1917 // Need to check the current 'offset'
1918 unsigned long offset;
1919 if (eNested->GetScalarAttribute("offset", offset))
1920 {
1921 if (this->PointsOffset != offset)
1922 {
1923 // save the pointsOffset we are about to read
1924 assert(this->PointsTimeStep == -1); // cannot have mixture of binary and appended
1925 this->PointsOffset = offset;
1926 return 1;
1927 }
1928 }
1929 else
1930 {
1931 // No offset is specified this is a binary file
1932 // First thing to check if numTimeSteps == 0:
1933 if (!numTimeSteps && this->NumberOfTimeSteps && this->PointsTimeStep == -1)
1934 {
1935 // Update last PointsTimeStep read
1936 this->PointsTimeStep = this->CurrentTimeStep;
1937 return 1;
1938 }
1939 int isLastTimeInArray =
1940 vtkXMLReader::IsTimeStepInArray(this->PointsTimeStep, this->TimeSteps, numTimeSteps);
1941 // If no time is specified or if time is specified and match then read
1942 if (isCurrentTimeInArray && !isLastTimeInArray)
1943 {
1944 // CurrentTimeStep is in TimeSteps but Last is not := need to read
1945 // Update last PointsTimeStep read
1946 this->PointsTimeStep = this->CurrentTimeStep;
1947 return 1;
1948 }
1949 }
1950 // all other cases we don't need to read:
1951 return 0;

Callers 1

ReadPieceDataMethod · 0.95

Calls 3

GetVectorAttributeMethod · 0.80
GetScalarAttributeMethod · 0.80
assertFunction · 0.50

Tested by

no test coverage detected