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

Method SelectTimeStepIndex

IO/Chemistry/vtkVASPAnimationReader.cxx:182–207  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

180
181//------------------------------------------------------------------------------
182size_t vtkVASPAnimationReader::SelectTimeStepIndex(vtkInformation* info)
183{
184 if (!info->Has(vtkStreamingDemandDrivenPipeline::TIME_STEPS()) ||
185 !info->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()))
186 {
187 return 0;
188 }
189
190 double* times = info->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
191 int nTimes = info->Length(vtkStreamingDemandDrivenPipeline::TIME_STEPS());
192 double t = info->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP());
193
194 double resultDiff = VTK_DOUBLE_MAX;
195 size_t result = 0;
196 for (int i = 0; i < nTimes; ++i)
197 {
198 double diff = std::fabs(times[i] - t);
199 if (diff < resultDiff)
200 {
201 resultDiff = diff;
202 result = static_cast<size_t>(i);
203 }
204 }
205
206 return result;
207}
208
209//------------------------------------------------------------------------------
210bool vtkVASPAnimationReader::ReadMolecule(std::istream& in, vtkMolecule* molecule)

Callers 1

RequestDataMethod · 0.95

Calls 3

HasMethod · 0.45
GetMethod · 0.45
LengthMethod · 0.45

Tested by

no test coverage detected