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

Method DivideRegion

Filters/Parallel/vtkPKdTree.cxx:704–856  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

702 return returnVal;
703}
704int vtkPKdTree::DivideRegion(vtkKdNode* kd, int L, int level, int tag)
705{
706 if (!this->DivideTest(kd->GetNumberOfPoints(), level))
707 return -1;
708
709 int numpoints = kd->GetNumberOfPoints();
710 int R = L + numpoints - 1;
711
712 if (numpoints < 2)
713 {
714 // Special case: not enough points to go around.
715 int p = this->WhoHas(L);
716 if (this->MyId != p)
717 return -1;
718
719 int maxdim = this->SelectCutDirection(kd);
720 kd->SetDim(maxdim);
721
722 vtkKdNode* left = vtkKdNode::New();
723 vtkKdNode* right = vtkKdNode::New();
724 kd->AddChildNodes(left, right);
725
726 double bounds[6];
727 kd->GetBounds(bounds);
728
729 float* val = this->GetLocalVal(L);
730
731 double coord;
732 if (numpoints > 0)
733 {
734 coord = val[maxdim];
735 }
736 else
737 {
738 coord = (bounds[maxdim * 2] + bounds[maxdim * 2 + 1]) * 0.5;
739 }
740
741 left->SetBounds(bounds[0], ((maxdim == XDIM) ? coord : bounds[1]), bounds[2],
742 ((maxdim == YDIM) ? coord : bounds[3]), bounds[4], ((maxdim == ZDIM) ? coord : bounds[5]));
743
744 left->SetNumberOfPoints(numpoints);
745
746 right->SetBounds(((maxdim == XDIM) ? coord : bounds[0]), bounds[1],
747 ((maxdim == YDIM) ? coord : bounds[2]), bounds[3], ((maxdim == ZDIM) ? coord : bounds[4]),
748 bounds[5]);
749
750 right->SetNumberOfPoints(0);
751
752 // Set the data bounds tightly around L. This will inevitably mean some
753 // regions that are empty will have their data bounds outside of them.
754 // Hopefully, that will not screw up anything down the road.
755 left->SetDataBounds(val[0], val[0], val[1], val[1], val[2], val[2]);
756 right->SetDataBounds(val[0], val[0], val[1], val[1], val[2], val[2]);
757
758 // Return L as the midpoint to guarantee that both left and right trees
759 // are "owned" by the same process as the parent. This is important
760 // because only one process has not culled this node in the tree.
761 return L;

Callers 1

BreadthFirstDivideMethod · 0.95

Calls 15

WhoHasMethod · 0.95
GetLocalValMethod · 0.95
SelectMethod · 0.95
GetDataBoundsMethod · 0.95
AllCheckForFailureMethod · 0.95
SelectCutDirectionMethod · 0.80
SetDimMethod · 0.80
AddChildNodesMethod · 0.80
DeleteMethod · 0.65
NewFunction · 0.50
DivideTestMethod · 0.45
GetNumberOfPointsMethod · 0.45

Tested by

no test coverage detected