------------------------------------------------------------------------------
| 163 | |
| 164 | //------------------------------------------------------------------------------ |
| 165 | int vtkTimeSourceExample::RequestData(vtkInformation* vtkNotUsed(reqInfo), |
| 166 | vtkInformationVector** vtkNotUsed(inVector), vtkInformationVector* outVector) |
| 167 | { |
| 168 | vtkInformation* outInfo = outVector->GetInformationObject(0); |
| 169 | vtkUnstructuredGrid* output = |
| 170 | vtkUnstructuredGrid::SafeDownCast(outInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 171 | if (!output) |
| 172 | { |
| 173 | return 0; |
| 174 | } |
| 175 | |
| 176 | // determine what time is being asked for |
| 177 | double reqTime = 0.0; |
| 178 | // int reqNTS = 0; |
| 179 | double reqTS(0); |
| 180 | if (outInfo->Has(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP())) |
| 181 | { |
| 182 | // reqNTS = outInfo->Length |
| 183 | // (vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); |
| 184 | reqTS = outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); |
| 185 | |
| 186 | // TODO: produce multiblock output when multiple time steps are asked for |
| 187 | // for now just answer the first one |
| 188 | reqTime = reqTS; |
| 189 | } |
| 190 | |
| 191 | // if analytic compute the value at that time |
| 192 | // if discrete look up the nearest time and value from the table |
| 193 | double time = reqTime; |
| 194 | double value = 0.0; |
| 195 | this->LookupTimeAndValue(time, value); |
| 196 | |
| 197 | output->Initialize(); |
| 198 | output->GetInformation()->Set(vtkDataObject::DATA_TIME_STEP(), time); |
| 199 | |
| 200 | // figure out the world space position of the output |
| 201 | double x = this->XFunction(time); |
| 202 | double y = this->YFunction(time); |
| 203 | |
| 204 | // figure out the number of cells in the output |
| 205 | int numCells = this->NumCellsFunction(time); |
| 206 | |
| 207 | // compute values for each point and cell to test with |
| 208 | vtkDoubleArray* pd = vtkDoubleArray::New(); |
| 209 | pd->SetNumberOfComponents(1); |
| 210 | pd->SetName("Point Value"); |
| 211 | output->GetPointData()->AddArray(pd); |
| 212 | vtkIdTypeArray* id = vtkIdTypeArray::New(); |
| 213 | id->SetNumberOfComponents(1); |
| 214 | id->SetName("Point Label"); |
| 215 | output->GetPointData()->AddArray(id); |
| 216 | output->GetPointData()->SetGlobalIds(id); |
| 217 | vtkDoubleArray* xd = vtkDoubleArray::New(); |
| 218 | xd->SetNumberOfComponents(1); |
| 219 | xd->SetName("Point X"); |
| 220 | output->GetPointData()->AddArray(xd); |
| 221 | vtkDoubleArray* yd = vtkDoubleArray::New(); |
| 222 | yd->SetNumberOfComponents(1); |
nothing calls this directly
no test coverage detected