------------------------------------------------------------------------------
| 40 | |
| 41 | //------------------------------------------------------------------------------ |
| 42 | void vtkTimeSourceExample::LookupTimeAndValue(double& time, double& value) |
| 43 | { |
| 44 | double t = time; |
| 45 | if (this->Analytic) |
| 46 | { |
| 47 | time = t; |
| 48 | // clamp within range |
| 49 | time = std::max(time, this->Steps[0]); |
| 50 | time = std::min(time, this->Steps[this->NumSteps - 1]); |
| 51 | value = this->ValueFunction(time); |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | int index = -2; |
| 56 | for (int i = 0; i < this->NumSteps; i++) |
| 57 | { |
| 58 | if (this->Steps[i] == t) |
| 59 | { |
| 60 | index = i; |
| 61 | break; |
| 62 | } |
| 63 | if (this->Steps[i] > t) |
| 64 | { |
| 65 | index = i - 1; |
| 66 | break; |
| 67 | } |
| 68 | } |
| 69 | if (index == -1) |
| 70 | { |
| 71 | index = 0; |
| 72 | } |
| 73 | if (index == -2) |
| 74 | { |
| 75 | index = this->NumSteps - 1; |
| 76 | } |
| 77 | time = this->Steps[index]; |
| 78 | value = this->Values[index]; |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | //------------------------------------------------------------------------------ |
| 83 | int vtkTimeSourceExample::NumCellsFunction(double t) |
no test coverage detected