| 116 | namespace vtkFileSeriesHelperNS |
| 117 | { |
| 118 | int 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 | |
| 137 | vtkStandardNewMacro(vtkFileSeriesHelper); |
no test coverage detected