Exemplo n.º 1
0
        /// <summary>
        /// Splits the given leaf at the given point and returns itself (with changes, if the leaf was found).
        /// </summary>
        /// <param name="leaf">The leaf supposed to be split.</param>
        /// <param name="x">The x coordinate of the point.</param>
        /// <param name="y">The y coordinate of the point.</param>
        /// <returns>Itself (with changes, if they happened).</returns>
        public override QuadTreeNode <TContent, TAverage> Split(QuadTreeNode <TContent, TAverage> leaf, double x, double y)
        {
            // Can't find a null leaf.
            if (leaf == null)
            {
                return(this);
            }

            throwWhenOutsideNode(x, y);

            if (TopRight.IsInsideNode(x, y))
            {
                TopRight = TopRight.Split(leaf, x, y);
            }

            if (BottomRight.IsInsideNode(x, y))
            {
                BottomRight = BottomRight.Split(leaf, x, y);
            }

            if (BottomLeft.IsInsideNode(x, y))
            {
                BottomLeft = BottomLeft.Split(leaf, x, y);
            }

            if (TopLeft.IsInsideNode(x, y))
            {
                TopLeft = TopLeft.Split(leaf, x, y);
            }

            invalidateAverage();

            return(this);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Splits the leaf node that contains the point at the given point and returns itself (with changes, if they happened).
        /// </summary>
        /// <param name="x">The x coordinate of the point.</param>
        /// <param name="y">The y coordinate of the point.</param>
        /// <returns>Itself (with changes, if they happened).</returns>
        public override QuadTreeNode <TContent, TAverage> Split(double x, double y)
        {
            throwWhenOutsideNode(x, y);

            if (TopRight.IsInsideNode(x, y))
            {
                TopRight = TopRight.Split(x, y);
            }

            if (BottomRight.IsInsideNode(x, y))
            {
                BottomRight = BottomRight.Split(x, y);
            }

            if (BottomLeft.IsInsideNode(x, y))
            {
                BottomLeft = BottomLeft.Split(x, y);
            }

            if (TopLeft.IsInsideNode(x, y))
            {
                TopLeft = TopLeft.Split(x, y);
            }

            invalidateAverage();

            return(this);
        }