------------------------------------------------------------------------------ Execute a simple (non-composite-aware) filter multiple times, once per block. Collect the result in a composite dataset that is of the same structure as the input.
| 312 | // block. Collect the result in a composite dataset that is of the same |
| 313 | // structure as the input. |
| 314 | void vtkCompositeDataPipeline::ExecuteSimpleAlgorithm(vtkInformation* request, |
| 315 | vtkInformationVector** inInfoVec, vtkInformationVector* outInfoVec, int compositePort) |
| 316 | { |
| 317 | vtkDebugMacro(<< "ExecuteSimpleAlgorithm"); |
| 318 | |
| 319 | this->ExecuteDataStart(request, inInfoVec, outInfoVec); |
| 320 | |
| 321 | vtkInformation* outInfo = nullptr; |
| 322 | |
| 323 | if (this->GetNumberOfOutputPorts() > 0) |
| 324 | { |
| 325 | outInfo = outInfoVec->GetInformationObject(0); |
| 326 | } |
| 327 | if (!outInfo) |
| 328 | { |
| 329 | return; |
| 330 | } |
| 331 | |
| 332 | // Make sure a valid composite data object exists for all output ports. |
| 333 | this->CheckCompositeData(request, inInfoVec, outInfoVec); |
| 334 | |
| 335 | // if we have no composite inputs |
| 336 | if (compositePort == -1) |
| 337 | { |
| 338 | return; |
| 339 | } |
| 340 | |
| 341 | // Loop using the first input on the first port. |
| 342 | // This might not be valid for all cases but it is a decent |
| 343 | // assumption to start with. |
| 344 | // TODO: Loop over all inputs |
| 345 | vtkInformation* inInfo = this->GetInputInformation(compositePort, 0); |
| 346 | vtkCompositeDataSet* input = |
| 347 | vtkCompositeDataSet::SafeDownCast(inInfo->Get(vtkDataObject::DATA_OBJECT())); |
| 348 | |
| 349 | bool compositeOutputFound = false; |
| 350 | std::vector<vtkSmartPointer<vtkCompositeDataSet>> compositeOutputs; |
| 351 | for (int port = 0; port < outInfoVec->GetNumberOfInformationObjects(); ++port) |
| 352 | { |
| 353 | compositeOutputs.emplace_back(vtkCompositeDataSet::GetData(outInfoVec, port)); |
| 354 | if (compositeOutputs.back()) |
| 355 | { |
| 356 | compositeOutputFound = true; |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | if (input && compositeOutputFound) |
| 361 | { |
| 362 | for (int port = 0; port < outInfoVec->GetNumberOfInformationObjects(); ++port) |
| 363 | { |
| 364 | if (compositeOutputs[port]) |
| 365 | { |
| 366 | compositeOutputs[port]->PrepareForNewData(); |
| 367 | compositeOutputs[port]->CopyStructure(input); |
| 368 | if (input && input->GetFieldData()) |
| 369 | { |
| 370 | compositeOutputs[port]->GetFieldData()->PassData(input->GetFieldData()); |
| 371 | } |
no test coverage detected