示例#1
0
 /// <summary>
 /// Removes the node.
 /// </summary>
 /// <param name="node">Node.</param>
 public void RemoveNode(SpatialFruitNode node)
 {
     if (!System.Object.ReferenceEquals(node, null))
     {
         Nodes.Remove(node);
     }
 }
示例#2
0
        public bool AddNode(SpatialFruitNode node)
        {
            if (!System.Object.ReferenceEquals(node, null))
            {
                return(QTree.AddNode(node));
            }

            return(false);
        }
示例#3
0
 public void RemoveNode(SpatialFruitNode node)
 {
     if (!System.Object.ReferenceEquals(node, null))
     {
         QuadTree tree = GetTreeByID(node.SpatialNodeID);
         if (!System.Object.ReferenceEquals(tree, null))
         {
             tree.RemoveNode(node);
         }
     }
 }
示例#4
0
        public void HandleNodePosChanged(SpatialFruitNode node)
        {
            QuadTree tree = GetTreeByID(node.SpatialNodeID);

            if (!System.Object.ReferenceEquals(tree, null))
            {
                if (!tree.IsNodeInrange(ref node))
                {
                    tree.RemoveNode(node);
                    AddNode(node);
                }
            }
        }
示例#5
0
        /// <summary>
        /// Adds the node.
        /// </summary>
        /// <returns><c>true</c>, if node was added,
        /// <c>false</c> otherwise.</returns>
        /// <param name="node">Node.</param>
        public bool AddNode(SpatialFruitNode node)
        {
            if (!System.Object.ReferenceEquals(node, null) &&
                IsNodeInrange(ref node))
            {
                if (NotShouldDivide() && !IsSubOpened)
                {
                    Nodes.Add(node);
                    node.SpatialNodeID = ID;
                    CurNodeCount++;

                    //TinyLogger.Instance.DebugLog(
                    //String.Format("$ add leaf node {0}, {1}, " +
                    //"count: {2}, MaxCapacity {3}",
                    //node.Position.x, node.Position.y,
                    //CurNodeCount, MaxCapacity));

                    //TinyLogger.Instance.DebugLog(
                    //String.Format("$ in leaf range {0}" +
                    //", {1}, {2}, {3}, {4}",
                    //Boundary.X,
                    //Boundary.Y,
                    //Boundary.Width,
                    //Boundary.Height,
                    //Nodes.Count));

                    return(true);
                }

                if (!IsSubOpened)
                {
                    SubDivide();

                    for (int j = 0; j < Nodes.Count; j++)
                    {
                        var qtnode = Nodes[j];
                        for (var i = 0; i < SubTrees.Count; i++)
                        {
                            var result = SubTrees[i].AddNode(qtnode);

                            if (result)
                            {
                                //TinyLogger.Instance.DebugLog(
                                //String.Format("$$$ add leaf node pos {0}, {1}",
                                //qtnode.Position.x, qtnode.Position.y));

                                //TinyLogger.Instance.DebugLog(
                                //String.Format("$$$ add leaf range {0}, " +
                                //"{1}, {2}, {3}, {4}",
                                //SubTrees[i].Boundary.X,
                                //SubTrees[i].Boundary.Y,
                                //SubTrees[i].Boundary.Width,
                                //SubTrees[i].Boundary.Height,
                                //SubTrees[i].Nodes.Count));

                                break;
                            }
                        }
                    }

                    Nodes.Clear();
                    CurNodeCount = 0;
                }

                for (var i = 0; i < SubTrees.Count; i++)
                {
                    if (SubTrees[i].AddNode(node))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
示例#6
0
 /// <summary>
 /// Ises the node inrange.
 /// </summary>
 /// <returns><c>true</c>, if node inrange was ised,
 /// <c>false</c> otherwise.</returns>
 /// <param name="node">Node.</param>
 public bool IsNodeInrange(ref SpatialFruitNode node)
 {
     return(Boundbox.Contains(node.Position));
     //return Boundary.ContainPoint(ref node.Position);
 }