------------------------------------------------------------------------------
| 330 | |
| 331 | //------------------------------------------------------------------------------ |
| 332 | bool vtkHyperTreeGridPProbeFilter::Reduce( |
| 333 | vtkHyperTreeGrid* source, vtkDataSet* output, vtkIdList* localPointIds) |
| 334 | { |
| 335 | int procId = 0; |
| 336 | int numProcs = 1; |
| 337 | if (this->Controller) |
| 338 | { |
| 339 | procId = this->Controller->GetLocalProcessId(); |
| 340 | numProcs = this->Controller->GetNumberOfProcesses(); |
| 341 | } |
| 342 | |
| 343 | vtkIdType numPointsFound = localPointIds->GetNumberOfIds(); |
| 344 | if (procId != 0) |
| 345 | { |
| 346 | this->Controller->Send(&numPointsFound, 1, 0, HYPERTREEGRID_PROBE_COMMUNICATION_TAG); |
| 347 | if (numPointsFound > 0) |
| 348 | { |
| 349 | this->Controller->Send(output, 0, HYPERTREEGRID_PROBE_COMMUNICATION_TAG); |
| 350 | this->Controller->Send( |
| 351 | localPointIds->GetPointer(0), numPointsFound, 0, HYPERTREEGRID_PROBE_COMMUNICATION_TAG); |
| 352 | } |
| 353 | output->ReleaseData(); |
| 354 | localPointIds->Initialize(); |
| 355 | } |
| 356 | else |
| 357 | { |
| 358 | auto dealWithRemote = [](vtkIdList* remotePointIds, vtkDataSet* remoteOutput, |
| 359 | vtkHyperTreeGrid* htgSource, vtkDataSet* totOutput) |
| 360 | { |
| 361 | if (remotePointIds->GetNumberOfIds() > 0) |
| 362 | { |
| 363 | vtkNew<vtkIdList> iotaIds; |
| 364 | iotaIds->SetNumberOfIds(remotePointIds->GetNumberOfIds()); |
| 365 | std::iota(iotaIds->begin(), iotaIds->end(), 0); |
| 366 | unsigned int numArrays = htgSource->GetCellData()->GetNumberOfArrays(); |
| 367 | for (unsigned int iA = 0; iA < numArrays; iA++) |
| 368 | { |
| 369 | vtkDataArray* remoteArray = remoteOutput->GetPointData()->GetArray( |
| 370 | htgSource->GetCellData()->GetArray(iA)->GetName()); |
| 371 | vtkDataArray* totArray = |
| 372 | totOutput->GetPointData()->GetArray(htgSource->GetCellData()->GetArray(iA)->GetName()); |
| 373 | totArray->InsertTuples(remotePointIds, iotaIds, remoteArray); |
| 374 | } |
| 375 | } |
| 376 | }; |
| 377 | vtkIdType numRemotePoints = 0; |
| 378 | vtkSmartPointer<vtkDataSet> remoteOutput = vtk::TakeSmartPointer(output->NewInstance()); |
| 379 | vtkNew<vtkIdList> remotePointIds; |
| 380 | // deal with master process |
| 381 | remoteOutput->CopyStructure(output); |
| 382 | unsigned int numArrays = source->GetCellData()->GetNumberOfArrays(); |
| 383 | for (unsigned int iA = 0; iA < numArrays; iA++) |
| 384 | { |
| 385 | vtkDataArray* da = |
| 386 | output->GetPointData()->GetArray(source->GetCellData()->GetArray(iA)->GetName()); |
| 387 | auto localInstance = vtk::TakeSmartPointer(da->NewInstance()); |
| 388 | localInstance->DeepCopy(da); |
| 389 | remoteOutput->GetPointData()->AddArray(localInstance); |
no test coverage detected