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

Function GetTimeStepIndex

IO/CGNS/vtkFileSeriesHelper.cxx:118–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116namespace vtkFileSeriesHelperNS
117{
118int GetTimeStepIndex(const double time, const double* timesteps, int num_timesteps)
119{
120 if (timesteps == nullptr || num_timesteps <= 0)
121 {
122 return -1;
123 }
124
125 const double* lbptr = std::lower_bound(timesteps, timesteps + num_timesteps, time);
126 int index = static_cast<int>(lbptr - timesteps);
127 assert(index >= 0 && index <= num_timesteps);
128 if (index == num_timesteps)
129 {
130 // if time > last_timestep, just give the last timestep.
131 --index;
132 }
133 return index;
134}
135}
136
137vtkStandardNewMacro(vtkFileSeriesHelper);

Callers 2

GetActiveFilesMethod · 0.70
RequestDataMethod · 0.70

Calls 1

assertFunction · 0.50

Tested by

no test coverage detected