------------------------------------------------------------------------------
| 180 | |
| 181 | //------------------------------------------------------------------------------ |
| 182 | size_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 | //------------------------------------------------------------------------------ |
| 210 | bool vtkVASPAnimationReader::ReadMolecule(std::istream& in, vtkMolecule* molecule) |
no test coverage detected