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

Method SetTimeStepToRead

IO/EnSight/core/EnSightFile.cxx:190–293  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

188
189//------------------------------------------------------------------------------
190bool EnSightFile::SetTimeStepToRead(double ts)
191{
192 if ((this->FileSet == -1 && this->TimeSet == -1) || !this->TimeInfo)
193 {
194 // non transient data
195 return this->OpenFile(this->FileNamePattern);
196 }
197
198 if (this->TimeInfo->TimeValues.empty())
199 {
200 vtkGenericWarningMacro(
201 "Time sets are used, but some error has caused the TimeValues to be empty");
202 return false;
203 }
204
205 auto tsIdx = getFileNameNumberIndex(ts, this->TimeInfo);
206 if (this->TimeSet != -1 && this->FileSet == -1)
207 {
208 // only using time sets
209 if (tsIdx != this->TimeStepIndex)
210 {
211 this->TimeStepIndex = tsIdx;
212 this->CloseFile();
213 std::string filename = this->FileNamePattern;
214
215 // check if the filename contains wildcards
216 std::regex exp("\\*+");
217 std::smatch sm;
218 if (std::regex_search(this->FileNamePattern, sm, exp))
219 {
220 if (!this->TimeInfo)
221 {
222 vtkGenericWarningMacro("TimeSet is " << this->TimeSet << ", but TimeInfo was not set");
223 return false;
224 }
225 filename = replaceWildcards(filename, this->TimeInfo->FileNameNumbers[this->TimeStepIndex]);
226 }
227 if (!this->OpenFile(filename))
228 {
229 vtkGenericWarningMacro("the file " << filename << " could not be opened");
230 return false;
231 }
232 }
233 this->ResetFile();
234 }
235 else if (this->TimeSet != -1 && this->FileSet != -1)
236 {
237 std::streampos posToRead;
238 int fileIndex = -1;
239 int tsIndexForFile = tsIdx;
240 if (!this->FileInfo->FileNameIndex.empty())
241 {
242 // in this case we may have to switch files, depending on what
243 // time step we're on
244 // otherwise we just stay in the file we already have opened
245 fileIndex = getFileSetIndex(tsIdx, this->FileInfo);
246 tsIndexForFile = this->FileInfo->TimeStepIndexInFile[tsIdx];
247 this->CurrentFileIndex = fileIndex;

Callers 6

ReadGeometryMethod · 0.80
ReadMeasuredGeometryMethod · 0.80
GetPartInfoMethod · 0.80
ReadVariableNodesMethod · 0.80
ReadVariableElementsMethod · 0.80

Calls 14

OpenFileMethod · 0.95
CloseFileMethod · 0.95
ResetFileMethod · 0.95
MoveToPositionMethod · 0.95
ReadNextLineMethod · 0.95
GetCurrentPositionMethod · 0.95
getFileNameNumberIndexFunction · 0.85
replaceWildcardsFunction · 0.85
getFileSetIndexFunction · 0.85
backMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected