/// <summary> /// Moves to the timestep and item /// Returns true if it was actually necessary to move /// Note that it is not possible to move backwards into something that has been written without /// </summary> /// <param name="TimeStep"></param> /// <param name="Item"></param> /// <returns></returns> private bool MoveToItemTimeStep(int TimeStep, int Item) { TimeStep = Math.Min(TimeStep, NumberOfTimeStepsWritten); Item = Math.Min(Item, NumberOfItems); if (TimeStep != _currentTimeStep || Item != _currentItem) { _currentTimeStep = TimeStep; _currentItem = Item; if (TimeStep == NumberOfTimeStepsWritten) { DfsDLLWrapper.dfsFindItemDynamic(_headerPointer, _filePointer, TimeStep - 1, NumberOfItems); //Spools to last item DfsDLLWrapper.dfsSkipItem(_headerPointer, _filePointer); // now at end _currentItem = 1; return(true); } else { //Spools to the correct Item and TimeStep DfsDLLWrapper.dfsFindItemDynamic(_headerPointer, _filePointer, TimeStep, Item); return(true); } } return(false); }
//read dynamic data from the given item number and timestep into the output array and give the time offset of the given timestep from the start of the file in dT public int ReadDynData(int timeStep, int itemNo, out float[] data, out double dT) { dT = 0; data = new float[Items[itemNo - 1].TotNoPoints]; DfsDLLWrapper.dfsFindItemDynamic(pHeader, pFile, timeStep, itemNo); // find item //dfsReadItemTimeStep always returns uncompressed data bool isRead = DfsDLLWrapper.dfsReadItemTimeStep(pHeader, pFile, out dT, data); if (!isRead) { throw new Exception("dfsReadItemTimeStep fail."); } return(0); }