private void AddChild(BUCoverNode <T> child) { if (!Children.Contains(child)) { Children.Add(child); } }
public BUCoverNode(Rectangle bounds, int capacity, int layer, double p_value, BUCoverNode <T> parent) { ActualBounds = bounds; Capacity = capacity; LayerNum = layer; pVal = p_value; OperatingBounds = new Rectangle(ActualBounds.Center, (int)(ActualBounds.Width * (1.0 + pVal)), (int)(ActualBounds.Height * (1.0 + pVal))); Parent = parent; }
public BUCoverNode <T> CreateParent(Point p) { if (ActualBounds.ContainsPoint(p)) { return(this); } Point maxExt = ActualBounds.GetTwiceMaxExtent(); maxExt.X /= 2; maxExt.Y /= 2; Point minExt = ActualBounds.GetTwiceMinExtent(); minExt.X /= 2; minExt.Y /= 2; Point center = new Point(); if (p.X >= minExt.X && p.Y >= maxExt.Y) { center.X = maxExt.X; center.Y = maxExt.Y; } else if (p.X < minExt.X && p.Y >= minExt.Y) { center.X = minExt.X; center.Y = maxExt.Y; } else if (p.X < maxExt.X && p.Y < minExt.Y) { center.X = minExt.X; center.Y = minExt.Y; } else { center.X = maxExt.X; center.Y = minExt.Y; } BUCoverNode <T> new_root = new BUCoverNode <T>(new Rectangle(center, ActualBounds.Width * 2, ActualBounds.Height * 2), Capacity, LayerNum - 1, pVal, null); new_root.AddChild(this); new_root.CreateChildren(); Parent = new_root; return(new_root); }
public bool Equals(BUCoverNode <T> other) { return(LayerNum == other.LayerNum && ActualBounds.Equals(other.ActualBounds)); }