MCPcopy Create free account
hub / github.com/Kitware/VTK / BreadthFirstDivide

Method BreadthFirstDivide

Filters/Parallel/vtkPKdTree.cxx:628–703  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

626 } while (false)
627
628int vtkPKdTree::BreadthFirstDivide(double* volBounds)
629{
630 SCOPETIMER("BreadthFirstDivide");
631
632 int returnVal = 0;
633
634 std::queue<vtkNodeInfo> Queue;
635
636 if (this->AllocateDoubleBuffer())
637 {
638 VTKERROR("memory allocation for double buffering");
639 return 1;
640 }
641
642 this->AllocateSelectBuffer();
643
644 vtkKdNode* kd = this->Top = vtkKdNode::New();
645
646 kd->SetBounds(volBounds[0], volBounds[1], volBounds[2], volBounds[3], volBounds[4], volBounds[5]);
647
648 kd->SetNumberOfPoints(this->TotalNumCells);
649
650 kd->SetDataBounds(
651 volBounds[0], volBounds[1], volBounds[2], volBounds[3], volBounds[4], volBounds[5]);
652
653 int midpt = this->DivideRegion(kd, 0, 0, 0x00000001);
654
655 if (midpt >= 0)
656 {
657 ENQUEUE(kd->GetLeft(), 0, 1, 0x00000002);
658 ENQUEUE(kd->GetRight(), midpt, 1, 0x00000003);
659 }
660 else if (midpt < -1)
661 {
662 this->FreeSelectBuffer();
663 this->FreeDoubleBuffer();
664
665 return 1;
666 }
667
668 while (!Queue.empty())
669 {
670 vtkNodeInfo info = Queue.front();
671 Queue.pop();
672
673 kd = info->kd;
674 int L = info->L;
675 int level = info->level;
676 int tag = info->tag;
677
678 midpt = this->DivideRegion(kd, L, level, tag);
679
680 if (midpt >= 0)
681 {
682 ENQUEUE(kd->GetLeft(), L, level + 1, tag << 1);
683
684 ENQUEUE(kd->GetRight(), midpt, level + 1, (tag << 1) | 1);
685 }

Callers 1

Calls 12

AllocateDoubleBufferMethod · 0.95
AllocateSelectBufferMethod · 0.95
DivideRegionMethod · 0.95
FreeSelectBufferMethod · 0.95
FreeDoubleBufferMethod · 0.95
popMethod · 0.80
NewFunction · 0.50
SetBoundsMethod · 0.45
SetNumberOfPointsMethod · 0.45
SetDataBoundsMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45

Tested by

no test coverage detected