/// <summary> /// Expands the tree as if the point as actually added /// </summary> /// <param name="point">Point to simulate expansion</param> /// <param name="maxPoints">Maximum number of points in a node</param> public void ExpandTree(GISData.PointData point, int maxPoints) { int newIndex; if (IsLeaf()) { if (pointCount >= maxPoints) //split { tree.hasSplit = true; Subdivide(); pointCount = 0; newIndex = GetIndexOfPosition(point.LocalPosition); //go down path for point subNodes[newIndex].ExpandTree(point, maxPoints); } else //add { pointCount++; } } else { newIndex = GetIndexOfPosition(point.LocalPosition); //go down path subNodes[newIndex].ExpandTree(point, maxPoints); } }
/// <summary> /// Recursively runs through tree until at a leaf that contains point /// </summary> /// <param name="point"></param> /// <returns></returns> public OctreeNode GetLeafFromExpandedTree(GISData.PointData point) { if (IsLeaf()) { return(this); } else { int newIndex = GetIndexOfPosition(point.LocalPosition); return(subNodes[newIndex].GetLeafFromExpandedTree(point)); } }