- // get the whole model size
- double rootSize = 0;
- {
- SMESH_Octree* root = this;
- while ( root->myLevel > 0 )
- root = root->myFather;
- rootSize = root->maxSize();
- }
- Standard_Real XminChild, YminChild, ZminChild;
- gp_XYZ minChild;
- for (int i = 0; i < 8; i++)
- {
- // We build the eight boxes, we need 2 points to do that:
- // Min and Mid
- // In binary, we can write i from 0 to 7
- // For instance :
- // 5 is 101, it corresponds here in coordinates to ZYX
- // If coordinate is 0 in Y-> box from Ymin to Ymid
- // If coordinate is 1 in Y-> box from Ymid to Ymax
- // Same scheme for X and Z
- // I need the minChild to build the Bnd_B3d box.
-
- XminChild = (i%2==0)?min.X():mid.X();
- YminChild = ((i%4)/2==0)?min.Y():mid.Y();
- ZminChild = (i<4)?min.Z():mid.Z();
- minChild.SetCoord(XminChild, YminChild, ZminChild);
-
- // The child is of the same type than its father (For instance, a SMESH_OctreeNode)
- // We allocate the memory we need for the child
- myChildren[i] = allocateOctreeChild();
- // and we assign to him its box.
- myChildren[i]->myFather = this;
- myChildren[i]->myLimit = myLimit;
- myChildren[i]->myLevel = myLevel + 1;
- myChildren[i]->myBox = new Bnd_B3d(minChild+childHsize,childHsize);
- myChildren[i]->myBox->Enlarge( rootSize * 1e-10 );
- if ( myLimit->myMinBoxSize > 0. && myChildren[i]->maxSize() <= myLimit->myMinBoxSize )
- myChildren[i]->myIsLeaf = true;
- }
-
- // After building the 8 boxes, we put the data into the children.
- buildChildrenData();
-
- //After we pass to the next level of the Octree
- for (int i = 0; i<8; i++)
- myChildren[i]->buildChildren();
-}