------------------------------------------------------------------------------
| 98 | |
| 99 | //------------------------------------------------------------------------------ |
| 100 | int vtkSimpleReader::ReadMetaData(vtkInformation* metadata) |
| 101 | { |
| 102 | if (this->HasTemporalMetaData) |
| 103 | { |
| 104 | metadata->Set(vtkStreamingDemandDrivenPipeline::TIME_DEPENDENT_INFORMATION(), 1); |
| 105 | } |
| 106 | else |
| 107 | { |
| 108 | if (!this->Internal->FileNames.empty()) |
| 109 | { |
| 110 | // Call the meta-data function on the first file. |
| 111 | int retval = this->ReadMetaDataSimple(this->Internal->FileNames[0], metadata); |
| 112 | if (!retval) |
| 113 | { |
| 114 | return retval; |
| 115 | } |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | if (this->Internal->FileNames.empty()) |
| 120 | { |
| 121 | // No file names specified. No meta-data. There is still |
| 122 | // no need to return with an error. |
| 123 | return 1; |
| 124 | } |
| 125 | |
| 126 | size_t nTimes = this->Internal->FileNames.size(); |
| 127 | std::vector<double> times(nTimes); |
| 128 | |
| 129 | bool hasTime = true; |
| 130 | auto iter = times.begin(); |
| 131 | for (const auto& fname : this->Internal->FileNames) |
| 132 | { |
| 133 | auto time = this->GetTimeValue(fname); |
| 134 | if (vtkMath::IsNan(time)) |
| 135 | { |
| 136 | hasTime = false; |
| 137 | break; |
| 138 | } |
| 139 | *iter++ = time; |
| 140 | } |
| 141 | |
| 142 | if (!hasTime) |
| 143 | { |
| 144 | std::iota(times.begin(), times.end(), 0); |
| 145 | } |
| 146 | |
| 147 | double timeRange[2]; |
| 148 | timeRange[0] = times[0]; |
| 149 | timeRange[1] = times[nTimes - 1]; |
| 150 | |
| 151 | metadata->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), times.data(), (int)nTimes); |
| 152 | metadata->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2); |
| 153 | |
| 154 | return 1; |
| 155 | } |
| 156 | |
| 157 | //------------------------------------------------------------------------------ |
no test coverage detected