void Octree::fillOctree() { double p[3]; const double *center; int i, l, id, numOfPoints = mInputPoints->GetNumberOfPoints(); OctreeNode* node; for ( i = 0 ; i < numOfPoints ; ++i ) { // Some initialization mInputPoints->GetPoint(i, p); node = mRoot; // Go down to the right leaf for ( l = 0 ; l < mTreeLevels ; ++l ) { node->createChildren(); // If this node already has children -> nothing will happen center = node->getCenter(); id = 0; if ( p[0] >= center[0] ) id |= 4; if ( p[1] >= center[1] ) id |= 2; if ( p[2] >= center[2] ) id |= 1; node->fullDescendantsFlagsBitwiseOR((unsigned char)0x01 << id); node = node->getChild(id); } this->fillOctreeLeaf(node, i, p); } }