| 395 | // BuildLocator must be called by all processes in the parallel application |
| 396 | |
| 397 | void vtkPKdTree::BuildLocator() |
| 398 | { |
| 399 | SCOPETIMER("BuildLocator"); |
| 400 | |
| 401 | int fail = 0; |
| 402 | int rebuildLocator = 0; |
| 403 | |
| 404 | if ((this->Top == nullptr) || (this->BuildTime < this->GetMTime()) || this->NewGeometry()) |
| 405 | { |
| 406 | // We don't have a k-d tree, or parameters that affect the |
| 407 | // build of the tree have changed, or input geometry has changed. |
| 408 | |
| 409 | rebuildLocator = 1; |
| 410 | } |
| 411 | |
| 412 | if (this->NumProcesses == 1) |
| 413 | { |
| 414 | if (rebuildLocator) |
| 415 | { |
| 416 | this->SingleProcessBuildLocator(); |
| 417 | } |
| 418 | return; |
| 419 | } |
| 420 | this->UpdateProgress(0); |
| 421 | |
| 422 | TIMER("Determine if we need to rebuild"); |
| 423 | |
| 424 | this->SubGroup = vtkSubGroup::New(); |
| 425 | this->SubGroup->Initialize( |
| 426 | 0, this->NumProcesses - 1, this->MyId, 0x00001000, this->Controller->GetCommunicator()); |
| 427 | |
| 428 | int vote; |
| 429 | this->SubGroup->ReduceSum(&rebuildLocator, &vote, 1, 0); |
| 430 | this->SubGroup->Broadcast(&vote, 1, 0); |
| 431 | |
| 432 | rebuildLocator = (vote > 0); |
| 433 | |
| 434 | TIMERDONE("Determine if we need to rebuild"); |
| 435 | |
| 436 | if (rebuildLocator) |
| 437 | { |
| 438 | TIMER("Build k-d tree"); |
| 439 | this->InvokeEvent(vtkCommand::StartEvent); |
| 440 | |
| 441 | this->FreeSearchStructure(); |
| 442 | this->ReleaseTables(); |
| 443 | |
| 444 | this->AllCheckParameters(); // global operation to ensure same parameters |
| 445 | |
| 446 | double volBounds[6]; |
| 447 | if (!this->VolumeBounds(volBounds)) // global operation to get bounds |
| 448 | { |
| 449 | goto doneError; |
| 450 | } |
| 451 | this->UpdateProgress(0.1); |
| 452 | |
| 453 | if (this->UserDefinedCuts) |
| 454 | { |