Ejemplo n.º 1
0
        public void AddAsChild(Rectangle rect)
        {
            bool rightSide = false;

            switch (Dimension)
            {
            case IntersectRectDimension.Top:
                rightSide = rect.Top > Rect.Top; break;

            case IntersectRectDimension.Left:
                rightSide = rect.Left > Rect.Left; break;

            case IntersectRectDimension.Bottom:
                rightSide = rect.Bottom > Rect.Bottom; break;

            case IntersectRectDimension.Right:
                rightSide = rect.Right > Rect.Right; break;
            }
            if (rightSide)
            {
                if (RightChild != null)
                {
                    RightChild.AddAsChild(rect);
                }
                else
                {
                    RightChild = new IntersectRectNode
                    {
                        Dimension = (IntersectRectDimension)(((int)Dimension + 1) % 4),
                        Rect      = rect
                    };
                }
            }
            else
            {
                if (LeftChild != null)
                {
                    LeftChild.AddAsChild(rect);
                }
                else
                {
                    LeftChild = new IntersectRectNode
                    {
                        Dimension = (IntersectRectDimension)(((int)Dimension + 1) % 4),
                        Rect      = rect
                    };
                }
            }
        }
Ejemplo n.º 2
0
 public void Add(Rectangle rect)
 {
     if (Root == null)
     {
         Root = new IntersectRectNode
         {
             Dimension = IntersectRectDimension.Left,
             Rect      = rect
         };
     }
     else
     {
         Root.AddAsChild(rect);
     }
 }
Ejemplo n.º 3
0
 public void AddAsChild(Rectangle rect)
 {
     bool rightSide = false;
     switch (Dimension)
     {
         case IntersectRectDimension.Top:
             rightSide = rect.Top > Rect.Top; break;
         case IntersectRectDimension.Left:
             rightSide = rect.Left > Rect.Left; break;
         case IntersectRectDimension.Bottom:
             rightSide = rect.Bottom > Rect.Bottom; break;
         case IntersectRectDimension.Right:
             rightSide = rect.Right > Rect.Right; break;
     }
     if (rightSide)
     {
         if (RightChild != null) RightChild.AddAsChild(rect);
         else
         {
             RightChild = new IntersectRectNode
             {
                 Dimension = (IntersectRectDimension)(((int)Dimension + 1) % 4),
                 Rect = rect
             };
         }
     }
     else
     {
         if (LeftChild != null) LeftChild.AddAsChild(rect);
         else
         {
             LeftChild = new IntersectRectNode
             {
                 Dimension = (IntersectRectDimension)(((int)Dimension + 1) % 4),
                 Rect = rect
             };
         }
     }
 }
Ejemplo n.º 4
0
 public void Add(Rectangle rect)
 {
     if (Root == null)
     {
         Root = new IntersectRectNode
         {
             Dimension = IntersectRectDimension.Left,
             Rect = rect
         };
     } else
     {
         Root.AddAsChild(rect);
     }
 }