/// <summary> /// Insert a new point into this leaf node. /// </summary> /// <param name="tPoint">The position which represents the data.</param> /// <param name="kValue">The value of the data.</param> public void AddPoint(Point3D kValue) { Vector3d tPoint = kValue.Position; // Find the correct leaf node. KDNode pCursor = this; while (!pCursor.IsLeaf) { // Extend the size of the leaf. pCursor.ExtendBounds(tPoint); pCursor.Size++; // If it is larger select the right, or lower, select the left. if (tPoint[pCursor.iSplitDimension] > pCursor.fSplitValue) { pCursor = pCursor.pRight; } else { pCursor = pCursor.pLeft; } } // Insert it into the leaf. pCursor.AddLeafPoint(tPoint, kValue); }