Beispiel #1
0
 public static float Proximity(Node a, Leaf b)
 {
     return Proximity(a.bb, b.bb);
 }
Beispiel #2
0
        public override void MarkLeafQuery(Leaf leaf, bool left, cpBBTree tree, Func<object, object, ulong, object, ulong> func)
        {
            if (cp.bbTreeIntersectsNode(leaf, this))
            {
                if (left)
                {
                    tree.PairInsert(leaf, this);
                }
                else
                {
                    if (this.stamp < leaf.stamp)
                        tree.PairInsert(this, leaf);

                    if (func != null)
                        func(leaf.obj, this.obj, (ulong)leaf.stamp, null);
                }
            }
        }
Beispiel #3
0
 public static float Proximity(Node a, Leaf b)
 {
     return(Proximity(a.bb, b.bb));
 }
Beispiel #4
0
        public Node SubtreeRemove(Node subtree, Leaf leaf)
        {
            if (leaf == subtree)
            {
                return null;
            }
            else
            {
                var parent = leaf.parent;
                if (parent == subtree)
                {
                    var other = subtree.Other(leaf);
                    other.parent = subtree.parent;
                    //NodeRecycle();
                    subtree.Recycle(this);
                    return other;
                }
                else
                {
                    if (parent == null)
                        return null;

                    parent.parent.ReplaceChild(parent, parent.Other(leaf), this);
                    return subtree;
                }
            }
        }
Beispiel #5
0
 public bool TryGetValue(ulong key, out Leaf value)
 {
     return leaves.TryGetValue(key, out value);
 }
Beispiel #6
0
 public void LeafUpdateWrap(Leaf leaf)
 {
     leaf.Update(this);
 }
Beispiel #7
0
        public Node SubtreeInsert(Node subtree, Leaf leaf)
        {
            if (subtree == null)
            {
                return leaf;
            }
            else if (subtree.isLeaf)
            {
                return MakeNode(leaf, subtree);
            }
            else
            {
                var cost_a = subtree.B.bbArea() + subtree.A.bb.MergedArea(leaf.bb);
                var cost_b = subtree.A.bbArea() + subtree.B.bb.MergedArea(leaf.bb);

                if (cost_a == cost_b)
                {
                    cost_a = subtree.A.bb.Proximity(leaf.bb);
                    cost_b = subtree.B.bb.Proximity(leaf.bb);
                }

                if (cost_b < cost_a)
                {
                    subtree.SetB(SubtreeInsert(subtree.B, leaf));
                }
                else
                {
                    subtree.SetA(SubtreeInsert(subtree.A, leaf));
                }

                //		subtree.bb = bbMerge(subtree.bb, leaf.bb);
                subtree.bb.l = Math.Min(subtree.bb.l, leaf.bb.l);
                subtree.bb.b = Math.Min(subtree.bb.b, leaf.bb.b);
                subtree.bb.r = Math.Max(subtree.bb.r, leaf.bb.r);
                subtree.bb.t = Math.Max(subtree.bb.t, leaf.bb.t);

                return subtree;
            }
        }
Beispiel #8
0
        public Leaf Insert(ulong hashid, IObjectBox obj)
        {
            Leaf leaf = new Leaf(this, obj);

            this.leaves.Add(hashid, leaf);

            Node root = this.root;

            this.root = SubtreeInsert(root, leaf);

            //this.root = cp.subtreeInsert(root, leaf, this);

            leaf.STAMP = GetStamp();
            leaf.AddPairs(this); //.AddPairs(this);
            IncrementStamp();
            return leaf;
        }
Beispiel #9
0
 public bool Contains(Leaf obj)
 {
     foreach (var item in leaves)
     {
         if (item.Value == obj)
             return true;
     }
     return false;
 }
Beispiel #10
0
 public virtual void MarkLeafQuery(Leaf leaf, bool left, cpBBTree tree, Func<object, object, ulong, object, ulong> func)
 {
     if (cp.bbTreeIntersectsNode(leaf, this))
     {
         this.A.MarkLeafQuery(leaf, left, tree, func);
         this.B.MarkLeafQuery(leaf, left, tree, func);
     }
 }
Beispiel #11
0
 public void LeafUpdateWrap(Leaf leaf)
 {
     leaf.Update(this);
 }
Beispiel #12
0
 public bool TryGetValue(ulong key, out Leaf value)
 {
     return(leaves.TryGetValue(key, out value));
 }