------------------------------------------------------------------------------
| 383 | |
| 384 | //------------------------------------------------------------------------------ |
| 385 | void vtkDistributedPointCloudFilter::GetPointsInsideBounds(vtkMPIController* controller, |
| 386 | vtkPointSet* input, vtkPointSet* output, const double outterBounds[6]) |
| 387 | { |
| 388 | vtkMPICommunicator* com = vtkMPICommunicator::SafeDownCast(controller->GetCommunicator()); |
| 389 | int np = com ? com->GetNumberOfProcesses() : 1; |
| 390 | int rank = com ? com->GetLocalProcessId() : 0; |
| 391 | |
| 392 | if (!com || np == 1) |
| 393 | { |
| 394 | output->ShallowCopy(input); |
| 395 | return; |
| 396 | } |
| 397 | |
| 398 | // round bounds to the nearest float value because locator use float internally. |
| 399 | // Otherwise, points that are exactly on the bounds may be wrongly considered as outside |
| 400 | // because of the cast. |
| 401 | double localOutterBounds[6]; |
| 402 | for (int i = 0; i < 3; i++) |
| 403 | { |
| 404 | localOutterBounds[2 * i] = std::nextafter( |
| 405 | static_cast<float>(outterBounds[2 * i]), static_cast<float>(outterBounds[2 * i]) - 1); |
| 406 | localOutterBounds[2 * i + 1] = std::nextafter( |
| 407 | static_cast<float>(outterBounds[2 * i + 1]), static_cast<float>(outterBounds[2 * i + 1]) + 1); |
| 408 | } |
| 409 | |
| 410 | bool emptyData = input->GetNumberOfPoints() == 0; |
| 411 | |
| 412 | std::vector<double> allOutterBounds(np * 6); |
| 413 | com->AllGather(localOutterBounds, allOutterBounds.data(), 6); |
| 414 | |
| 415 | // size in bytes of messages to be sent to other processes |
| 416 | std::vector<vtkIdType> messagesSize(np); |
| 417 | |
| 418 | // number of points in messages to be sent to other processes |
| 419 | std::vector<vtkIdType> messagePointCount(np); |
| 420 | |
| 421 | // array of point ids |
| 422 | vtkNew<vtkIdTypeArray> idArray; |
| 423 | std::vector<vtkSmartPointer<vtkCharArray>> dataToSend; |
| 424 | dataToSend.resize(np); |
| 425 | |
| 426 | // we will need a locator to search points inside each processor assigned regions |
| 427 | vtkNew<vtkOctreePointLocator> locator; |
| 428 | |
| 429 | if (!emptyData) |
| 430 | { |
| 431 | vtkNew<vtkPolyData> inputPolyData; |
| 432 | inputPolyData->SetPoints(input->GetPoints()); |
| 433 | locator->SetDataSet(inputPolyData.Get()); |
| 434 | locator->BuildLocator(); |
| 435 | } |
| 436 | |
| 437 | // 1st step: define messages to send to each processor (including itself) |
| 438 | // with polydata containing closest points to local data bounding box |
| 439 | for (int partner = 0; partner < np; partner++) |
| 440 | { |
| 441 | idArray->SetNumberOfTuples(0); |
| 442 | vtkIdType nPoints = 0; |
nothing calls this directly
no test coverage detected