private void RenderQuadTree(TreeGraph <Key> quadTree)
        {
            Key key = quadTree.GetKeys();

            if (key.visible)
            {
                if (quadTree.GetChild(0) == null)
                {
                    if (key.ib != null)
                    {
                        facesCount += key.GetFacesCount();
                        key.Render(0);
                        // key.RenderIndexed(vertexes.Length);
                    }

                    return;
                }
                else
                {
                    for (int t = 0; t < 4; t++)
                    {
                        RenderQuadTree(quadTree.GetChild(t));
                    }
                }
            }
        }
Пример #2
0
        public void Q4_3()
        {
            var array = new List <int>()
            {
                1, 2, 3, 4, 5
            };
            var treeNode = TreeGraph.Q3_CreateMinimalBST(array);

            Assert.AreEqual(3, treeNode.Data);
            Assert.AreEqual(2, treeNode.Left.Data);
            Assert.AreEqual(1, treeNode.Left.Left.Data);
            Assert.AreEqual(5, treeNode.Right.Data);
            Assert.AreEqual(4, treeNode.Right.Left.Data);

            array = new List <int>()
            {
                1, 2, 3, 4, 5, 6, 7, 8, 9, 10
            };
            treeNode = TreeGraph.Q3_CreateMinimalBST(array);

            Assert.AreEqual(6, treeNode.Data);
            Assert.AreEqual(3, treeNode.Left.Data);
            Assert.AreEqual(2, treeNode.Left.Left.Data);
            Assert.AreEqual(1, treeNode.Left.Left.Left.Data);
            Assert.AreEqual(5, treeNode.Left.Right.Data);
            Assert.AreEqual(4, treeNode.Left.Right.Left.Data);
            Assert.AreEqual(9, treeNode.Right.Data);
            Assert.AreEqual(8, treeNode.Right.Left.Data);
            Assert.AreEqual(10, treeNode.Right.Right.Data);
        }
Пример #3
0
        public void Q4_5()
        {
            BinaryTreeNode <IComparable> root = new BinaryTreeNode <IComparable>(0)
            {
                Left = new BinaryTreeNode <IComparable>(1)
                {
                    Left  = new BinaryTreeNode <IComparable>(3),
                    Right = new BinaryTreeNode <IComparable>(4),
                },
                Right = new BinaryTreeNode <IComparable>(2)
            };

            Assert.IsFalse(TreeGraph.Q5_CheckBST(root));

            root = new BinaryTreeNode <IComparable>(4)
            {
                Left = new BinaryTreeNode <IComparable>(2)
                {
                    Left  = new BinaryTreeNode <IComparable>(1),
                    Right = new BinaryTreeNode <IComparable>(3)
                },
                Right = new BinaryTreeNode <IComparable>(6)
                {
                    Left  = new BinaryTreeNode <IComparable>(5),
                    Right = new BinaryTreeNode <IComparable>(7)
                }
            };

            Assert.IsTrue(TreeGraph.Q5_CheckBST(root));
        }
Пример #4
0
        public void InitWith(BehaviourTreeRunner runner)
        {
            if (EditorApplication.isPlaying)
            {
                BindBehaviourTreeEvent(false);
            }
            ContextMenu.Hide();
            Runner         = runner;
            BehaviourAsset = Runner == null ? (Selection.activeObject as BehaviourTreeAsset) : Runner.SourceAsset;
            TreeCanvas.ClearElements();
            CommentCanvas.ClearElements();
            TreeGraph.Clear();

            mRootGUI = new BehaviourRootGUI(this);
            mRootGUI.UpdateLocalData();
            TreeCanvas.AddElement(mRootGUI);
            TreeGraph.AddNode(mRootGUI);

            if (BehaviourAsset != null)
            {
                ImportTreeData();
            }
            ResetIdCounter();
            RebuildExecutionOrder();
            UpdateStateInfo();
            if (EditorApplication.isPlaying)
            {
                BindBehaviourTreeEvent(true);
            }
        }
Пример #5
0
        public BehaviourNodeGUI AddChild(PaintElement parent, BehaviourMeta meta, Vector2 localPos)
        {
            if (parent != null && parent.Parent != TreeCanvas)
            {
                return(null);
            }
            BehaviourNodeGUI node = new BehaviourNodeGUI(this);

            node.Self = new BehaviourNodeGUI.Decorator(GenerateId, meta);
            node.Self.UpdatePropertiesInfo();
            Rect r = new Rect();

            r.size         = node.CalculateLocalSize();
            r.position     = localPos - Vector2.right * r.size.x * 0.5f;
            node.LocalRect = r;
            TreeCanvas.AddElement(node);
            TreeGraph.AddNode(node);
            if (parent != null)
            {
                TreeGraph.AddPath(0, parent, node);
            }
            RebuildExecutionOrder();

            return(node);
        }
Пример #6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            ProcessProgress.Current.RegisterResponser(ShowOrgChartProgressResponser.Instance);

            using (StreamWriter writer = new StreamWriter(context.Response.OutputStream))
            {
                writer.WriteLine("<!DOCTYPE html>");

                WriteProgressBar(writer);
            }

            OrgTreeNode root = BuildOguTree(WebUtility.GetRequestQueryString("ou", string.Empty));

            ResponseHideProgressContainerScript();

            using (StreamWriter writer = new StreamWriter(context.Response.OutputStream))
            {
                if (root != null)
                {
                    TreeGraph graph = root.GenerateGraph();
                    graph.WriteHtmlGraph(writer);
                }
            }
        }
        public QuadTreeGeneralObject(int level, GeneralObject.GeneralVertex[] vertexes, int[] indexes, Vector3 minPosition, Vector3 maxPosition, Matrix world, Texture[] color_textures0, Texture[] color_textures1, Texture[] color_textures2, Texture[] normal_textures)
            : base(null, world, color_textures0, color_textures1, color_textures2, normal_textures)
        {
            this.vertexes = vertexes;

            this.mesh   = null;
            this.device = color_textures0[0].Device;

            this.vertexDecl = new VertexDeclaration(this.device, GeneralObject.GeneralVertex.vertexElements);

            this.vb = new VertexBuffer(typeof(GeneralObject.GeneralVertex), vertexes.Length, this.device, Usage.WriteOnly, GeneralObject.GeneralVertex.Format, Pool.Managed);
            this.vb.SetData(vertexes, 0, LockFlags.NoSystemLock);

            Key key = new Key(this.device, base.GetMatrixWorld(), this.vertexes, indexes, minPosition, maxPosition);

            this.radius = key.radius;
            this.boundingSphereCenter = key.boundingSphereCenter;

            this.quadTree = new TreeGraph <Key>(4, key);

            try
            {
                GenerateQuadTree(level, this.quadTree);
            }
            catch (Exception ex)
            {
                System.Console.WriteLine(ex.Message);
            }
        }
Пример #8
0
        public void Q4_7()
        {
            BinaryTreeNode <int> root = new BinaryTreeNode <int>(0)
            {
                Left = new BinaryTreeNode <int>(1)
                {
                    Left = new BinaryTreeNode <int>(3)
                    {
                        Left  = new BinaryTreeNode <int>(7),
                        Right = new BinaryTreeNode <int>(8)
                    },
                    Right = new BinaryTreeNode <int>(4)
                    {
                        Left  = new BinaryTreeNode <int>(9),
                        Right = new BinaryTreeNode <int>(10)
                    },
                },
                Right = new BinaryTreeNode <int>(2)
                {
                    Left  = new BinaryTreeNode <int>(5),
                    Right = new BinaryTreeNode <int>(6)
                }
            };

            BinaryTreeNode <int> notin = new BinaryTreeNode <int>(11);

            Assert.AreEqual(null, TreeGraph.Q7_GetCommonAncestor(root, root, root));
            Assert.AreEqual(root.Left, TreeGraph.Q7_GetCommonAncestor(root, root.Left.Left, root.Left.Right));
            Assert.AreEqual(root, TreeGraph.Q7_GetCommonAncestor(root, root.Right.Left, root.Left.Right));
            Assert.AreEqual(root.Left, TreeGraph.Q7_GetCommonAncestor(root, root.Left.Left, root.Left.Left));
            Assert.AreEqual(null, TreeGraph.Q7_GetCommonAncestor(root, null, root.Left.Left));
            Assert.AreEqual(null, TreeGraph.Q7_GetCommonAncestor(root, notin, root.Left.Left));
        }
Пример #9
0
        public void GenerateAllGraphNodes()
        {
            OrgTreeNode root = PreareOrgTree();

            TreeGraph graph = root.GenerateGraph();

            OutputTreeGraph(graph);
        }
Пример #10
0
        public PaintElement GetNodeBTParent(PaintElement node)
        {
            TreeGraph.GetAllParent(0, node, mCache);
            PaintElement parent = mCache.Count > 0 ? mCache[0] : null;

            mCache.Clear();
            return(parent);
        }
        public override void OnHeaderGUI()
        {
            GUI.color = Color.white;
            TreeNode  node  = target as TreeNode;
            TreeGraph graph = node.graph as TreeGraph;

            string title = target.name;

            GUILayout.Label(title, NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
            GUI.color = Color.white;
        }
Пример #12
0
        void ImportTreeData()
        {
            for (int i = 0; i < BehaviourAsset.m_Datas.Length; i++)
            {
                BehaviourNodeGUI node = NewNode(BehaviourAsset.m_Datas[i]);
                if (node != null)
                {
                    TreeGraph.AddNode(node);
                    TreeCanvas.AddElement(node);
                }
            }
            int id = 0;
            FilterDelegate <PaintElement> filter = (x) =>
            {
                BehaviourNodeGUI bx = x as BehaviourNodeGUI;
                return(bx != null && bx.Self.BTId == id);
            };

            for (int i = 0; i < BehaviourAsset.m_Datas.Length; i++)
            {
                BTData data = BehaviourAsset.m_Datas[i];
                id = data.m_Id;
                BehaviourNodeGUI gnode = TreeGraph.FindNode(filter) as BehaviourNodeGUI;
                if (gnode == null)
                {
                    continue;
                }
                int len = data.m_Children == null ? 0 : data.m_Children.Length;
                for (int j = 0; j < len; j++)
                {
                    id = data.m_Children[j];
                    BehaviourNodeGUI gchild = TreeGraph.FindNode(filter) as BehaviourNodeGUI;
                    if (gchild != null)
                    {
                        TreeGraph.AddPath(0, gnode, gchild);
                    }
                }
            }
            id = BehaviourAsset.m_RootNodeId;
            BehaviourNodeGUI root = TreeGraph.FindNode(filter) as BehaviourNodeGUI;

            if (root != null)
            {
                TreeGraph.AddPath(0, mRootGUI, root);
            }

            for (int i = 0; i < BehaviourAsset.m_Comments.Length; i++)
            {
                BehaviourCommentGUI comment = new BehaviourCommentGUI(this);
                comment.Comment   = BehaviourAsset.m_Comments[i].m_Comment;
                comment.LocalRect = BehaviourAsset.m_Comments[i].m_Rect;
                CommentCanvas.AddElement(comment);
            }
        }
        public void SetQuadTreeLeaves(List <Key> leaves)
        {
            int             index = 0;
            TreeGraph <Key> tree  = this.quadTree.GetTreeLeaves();

            do
            {
                tree.SetKeys(leaves[index++]);
                tree = tree.GetRightNeighboure();
            } while (tree != null);
        }
Пример #14
0
 // Accumule la lumière de l'arbre, des feuilles vers la base
 private void accumulateLight(ref TreeGraph <Bud> skeleton)
 {
     for (int i = skeleton.levels.Count - 1; i >= 0; i--)
     {
         List <Node <Bud> > list = skeleton.levels[i];
         for (int j = 0; j < list.Count; j++)
         {
             Node <Bud> node = list[j];
             evaluateLight(ref node);
         }
     }
 }
Пример #15
0
    public Node(ref TreeGraph <T> belongsTo, Node <T> parent_, T value_)
    {
        parent  = parent_;
        value   = value_;
        level   = parent.level + 1;
        main    = null;
        lateral = null;

        Node <T> me = this;

        belongsTo.addInLevel(ref me);
    }
    private void addMetamer(ref TreeGraph <Bud> skeleton, ref List <Node <Bud> > leaves, ref Node <Bud> currentNode)
    {
        Bud   currentBud      = currentNode.value;
        float internodeLength = currentBud.l;

        currentBud.lateralDir = Vector3.Normalize(eta * tropismVec + epsilon * currentBud.optimalGrowth + (1 - eta - epsilon) * currentBud.dir);
        Vector3 newLateralBudPosition = currentBud.pos + currentBud.lateralDir * internodeLength;

        Bud        newLateralBud  = new Bud(newLateralBudPosition, true);
        Node <Bud> newLateralNode = new Node <Bud>(ref skeleton, currentNode, newLateralBud);

        currentNode.lateral = newLateralNode;
        leaves.Add(newLateralNode);
    }
        public List <Key> GetQuadTreeLeaves()
        {
            List <Key> leaves = new List <Key>();

            TreeGraph <Key> tree = this.quadTree.GetTreeLeaves();

            do
            {
                leaves.Add(tree.GetKeys());
                tree = tree.GetRightNeighboure();
            } while (tree != null);

            return(leaves);
        }
Пример #18
0
        public VerticalRender( TreeGraph tree )
            : base(tree)
        {
            if( tree.NodeRegionCssClass == null )
            {
                NodeExtendTag = " style='BORDER-RIGHT: "+this.LineColorHtml+" 1px solid; BORDER-TOP: "+this.LineColorHtml+
                    " 1px solid; BORDER-LEFT: "+this.LineColorHtml+" 1px solid; WIDTH: 100px; BORDER-BOTTOM: "+this.LineColorHtml+" 1px solid; HEIGHT: 20px;'";
            }
            else
            {
                NodeExtendTag = "class='" + tree.NodeRegionCssClass + "'";
            }

            LineHtml = string.Format( LineHtml , tree.LineLength.ToString() , LineColorHtml ) ;
        }
        public void SetUp()
        {
            tree = new TreeGraph <int, object, object>(0);
            tree.AddVertex(1, tree[0]);
            tree.AddVertex(2, tree[0]);
            tree.AddVertex(3, tree[1]);
            tree.AddVertex(4, tree[1]);
            tree.AddVertex(5, tree[1]);
            tree.AddVertex(6, tree[2]);
            tree.AddVertex(7, tree[4]);
            tree.AddVertex(8, tree[6]);
            tree.AddVertex(9, tree[6]);

            testObject = new LowestCommonAncestor <int, object, object>(tree, tree[0]);
        }
Пример #20
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            using (StreamWriter writer = new StreamWriter(context.Response.OutputStream))
            {
                writer.WriteLine("<!DOCTYPE html>");

                OrgTreeNode root = OrgTreeNode.PreareOrgTree();

                TreeGraph graph = root.GenerateGraph();

                graph.WriteHtmlGraph(writer);
            }
        }
Пример #21
0
        void ExportTreeData()
        {
            List <BTData>       nodes    = new List <BTData>();
            List <PaintElement> children = new List <PaintElement>();
            int rootId = 0;

            for (int i = 0; i < TreeCanvas.ElementCount; i++)
            {
                BehaviourNodeGUI bnode = TreeCanvas.GetElement <BehaviourNodeGUI>(i);
                if (bnode == null)
                {
                    continue;
                }
                if (TreeGraph.GetParent(0, bnode) == mRootGUI)
                {
                    rootId = bnode.Self.BTId;
                }
                BTData data = bnode.ExportNodeData(nodes);

                children.Clear();
                TreeGraph.GetAllChildren(0, bnode, children);
                GlobalUtil.Sort(children, (x, y) => x.LocalRect.center.x <= y.LocalRect.center.x ? -1 : 1);
                data.m_Children = new int[children.Count];
                for (int j = 0; j < children.Count; j++)
                {
                    BehaviourNodeGUI child = children[j] as BehaviourNodeGUI;
                    data.m_Children[j] = child == null ? 0 : child.Self.BTId;
                }
            }
            BehaviourAsset.m_RootNodeId = rootId;
            GlobalUtil.Sort(nodes, (x, y) => x.m_Id - y.m_Id);
            BehaviourAsset.m_Datas  = nodes.ToArray();
            BehaviourAsset.m_Sorted = true;

            BehaviourTreeAsset.Comment[] comments = new BehaviourTreeAsset.Comment[CommentCanvas.ElementCount];
            for (int i = 0; i < comments.Length; i++)
            {
                comments[i] = new BehaviourTreeAsset.Comment();
                BehaviourCommentGUI com = CommentCanvas.GetElement <BehaviourCommentGUI>(i);
                if (com != null)
                {
                    comments[i].m_Rect    = com.LocalRect;
                    comments[i].m_Comment = com.Comment ?? "";
                }
            }
            BehaviourAsset.m_Comments = comments;
            EditorUtility.SetDirty(BehaviourAsset);
        }
Пример #22
0
        void VisitChildren(List <BehaviourNodeGUI> nodes, BehaviourNodeGUI root)
        {
            nodes.Add(root);
            List <PaintElement> children = new List <PaintElement>();

            TreeGraph.GetAllChildren(0, root, children);
            GlobalUtil.Sort(children, (x, y) => x.LocalRect.center.x <= y.LocalRect.center.x ? -1 : 1);
            for (int i = 0; i < children.Count; i++)
            {
                BehaviourNodeGUI node = children[i] as BehaviourNodeGUI;
                if (node != null)
                {
                    VisitChildren(nodes, node);
                }
            }
        }
Пример #23
0
        public void Q4_1()
        {
            BinaryTree <int> tree;

            BinaryTreeNode <int> balanced = new BinaryTreeNode <int>(0)
            {
                Left = new BinaryTreeNode <int>(1)
                {
                    Left = new BinaryTreeNode <int>(3)
                    {
                        Left  = new BinaryTreeNode <int>(7),
                        Right = new BinaryTreeNode <int>(8)
                    },
                    Right = new BinaryTreeNode <int>(4)
                    {
                        Left  = new BinaryTreeNode <int>(9),
                        Right = new BinaryTreeNode <int>(10)
                    },
                },
                Right = new BinaryTreeNode <int>(2)
                {
                    Left  = new BinaryTreeNode <int>(5),
                    Right = new BinaryTreeNode <int>(6)
                }
            };

            tree = new BinaryTree <int>(Comparer <int> .Default, balanced);
            Assert.IsTrue(TreeGraph.Q1_IsBalanced(tree));

            BinaryTreeNode <int> notBalanced = new BinaryTreeNode <int>(0)
            {
                Right = new BinaryTreeNode <int>(1)
                {
                    Right = new BinaryTreeNode <int>(2)
                    {
                        Right = new BinaryTreeNode <int>(3)
                        {
                            Right = new BinaryTreeNode <int>(4),
                        }
                    }
                }
            };

            tree = new BinaryTree <int>(Comparer <int> .Default, notBalanced);
            Assert.IsFalse(TreeGraph.Q1_IsBalanced(tree));
        }
Пример #24
0
        public void Q4_9()
        {
            var sum   = 0;
            var nodes = new BinaryTreeNode <int>(1)
            {
                Left = new BinaryTreeNode <int>(0)
                {
                    Left  = new BinaryTreeNode <int>(2),
                    Right = new BinaryTreeNode <int>(-1)
                },
                Right = new BinaryTreeNode <int>(-1),
            };

            var result = TreeGraph.Q9_FindSum(nodes, sum);

            var expected = new List <List <BinaryTreeNode <int> > >
            {
                new List <BinaryTreeNode <int> >
                {
                    nodes.Left
                },
                new List <BinaryTreeNode <int> >
                {
                    nodes, nodes.Right
                },
                new List <BinaryTreeNode <int> >
                {
                    nodes, nodes.Left, nodes.Left.Right
                },
            };

            foreach (var exptectedPath in expected)
            {
                bool included = false;
                foreach (var resultPath in result)
                {
                    included = exptectedPath.SequenceEqual(resultPath);
                    if (included)
                    {
                        break;
                    }
                }

                Assert.IsTrue(included);
            }
        }
Пример #25
0
        /// <summary>
        /// 输出树型图
        /// </summary>
        /// <param name="graph"></param>
        /// <param name="writer"></param>
        /// <param name="outputStyle">是否输出样式,默认为true</param>
        public static void WriteHtmlGraph(this TreeGraph graph, TextWriter writer, bool outputStyle = true)
        {
            if (graph != null && writer != null)
            {
                if (outputStyle)
                {
                    WriteInlineStyles(writer);
                }

                writer.WriteLine("\n<div style=\"width: {0}px; height: {1}px; white-space: nowrap; overflow: hidden; margin: 0px 0px 0px 0px;\">",
                                 graph.Width * 120 + 1, (graph.Height + 1) * 60);

                GenerateHtmlRow(writer, new TreeGraphNodeBase[] { graph.Root }, graph.Width);

                writer.WriteLine("\n</div>");
            }
        }
Пример #26
0
        protected override void OnPreRender(EventArgs e)
        {
            OrgTreeNode root = OrgTreeNode.PreareOrgTree();

            TreeGraph graph = root.GenerateGraph();

            StringBuilder strB = new StringBuilder();

            using (StringWriter writer = new StringWriter(strB))
            {
                graph.WriteHtmlGraph(writer);
            }

            this.container.InnerHtml = strB.ToString();

            base.OnPreRender(e);
        }
Пример #27
0
        void DoBuildExecutionOrder()
        {
            EditNodes((x) => x.BTExecutionOrder = 0);
            List <PaintElement> children = new List <PaintElement>();

            TreeGraph.GetAllChildren(0, TreeGraph.Root, children);
            List <BehaviourNodeGUI> nodes = new List <BehaviourNodeGUI>();

            for (int i = 0; i < children.Count; i++)
            {
                VisitChildren(nodes, children[i] as BehaviourNodeGUI);
            }
            for (int i = 0; i < nodes.Count; i++)
            {
                nodes[i].BTExecutionOrder = i + 1;
                nodes[i].CheckError();
            }
        }
        private void DisposeQuadTree(TreeGraph <Key> tree)
        {
            Key k = tree.GetKeys();


            if (k.boundingMesh != null && !k.boundingMesh.Disposed)
            {
                k.boundingMesh.Dispose();
            }

            if (k.ib != null && !k.ib.Disposed)
            {
                k.ib.Dispose();
            }

            if (k.mesh != null && !k.mesh.Disposed)
            {
                k.mesh.Dispose();
            }

            if (k.vb != null && !k.vb.Disposed)
            {
                k.vb.Dispose();
            }

            k.vertexes = null;
            k.indeces  = null;
            k.bounds   = null;

            k = null;
            tree.SetKeys(null);

            TreeGraph <Key> childtree = null;

            for (int t = 0; t < 4; t++)
            {
                childtree = tree.GetChild(t);

                if (childtree != null)
                {
                    DisposeQuadTree(childtree);
                }
            }
        }
        private void ComputeVisibility(TreeGraph <Key> tree, bool visible)
        {
            Key key = tree.GetKeys();

            key.visible = visible;
            tree.SetKeys(key);

            TreeGraph <Key> childtree = null;

            for (int t = 0; t < 4; t++)
            {
                childtree = tree.GetChild(t);

                if (childtree != null)
                {
                    ComputeVisibility(childtree, visible);
                }
            }
        }
Пример #30
0
    // Accumule l'énergie de l'arbre, de la base vers les feuilles
    private void distributeEnergy(ref TreeGraph <Bud> skeleton)
    {
        // On évalue d'abord la quantité d'énergie à la base de l'arbre
        Bud   rootBud = skeleton.root.value;
        float vBase   = alpha * rootBud.Q;

        rootBud.setEnergy(vBase);

        for (int i = 0; i < skeleton.levels.Count; i++)
        {
            List <Node <Bud> > list = skeleton.levels[i];
            for (int j = 0; j < list.Count; j++)
            {
                Node <Bud> node = list[j];
                Bud        bud  = node.value;
                evaluateState(ref bud);
                evaluateEnergy(ref node);
            }
        }
    }
    void drawSkeleton(Color c)
    {
        Gizmos.color = c;
        TreeGraph <Bud> skeleton = treeModel.skeleton;

        if (skeleton == null)
        {
            return;
        }

        for (int i = 1; i < skeleton.levels.Count; i++) // la root est exclue car i initialisé à 1
        {
            List <Node <Bud> > list = skeleton.levels[i];
            for (int j = 0; j < list.Count; j++)
            {
                Node <Bud> node = list[j];
                drawBranch(node);
            }
        }
    }
Пример #32
0
        private TreeGraph CreateDiagnosticRootGraph(Key left_key, long reference)
        {
            // The node being returned
            TreeGraph node;

            // Fetch the node,
            ITreeNode tree_node = FetchNodes(new long[] { reference })[0];

            if (tree_node is TreeLeaf) {
                TreeLeaf leaf = (TreeLeaf)tree_node;
                // The number of bytes in the leaf
                int leaf_size = leaf.Length;

                // Set up the leaf node object
                node = new TreeGraph("leaf", reference);
                node.SetProperty("key", left_key.ToString());
                node.SetProperty("leaf_size", leaf_size);

            } else if (tree_node is TreeBranch) {
                TreeBranch branch = (TreeBranch)tree_node;
                // Set up the branch node object
                node = new TreeGraph("branch", reference);
                node.SetProperty("key", left_key.ToString());
                node.SetProperty("branch_size", branch.ChildCount);
                // Recursively add each child into the tree
                for (int i = 0; i < branch.ChildCount; ++i) {
                    long child_ref = branch.GetChild(i);
                    // If the ref is a special node, skip it
                    if ((child_ref & 0x01000000000000000L) != 0) {
                        // Should we record special nodes?
                    } else {
                        Key new_left_key = (i > 0) ? branch.GetKey(i) : left_key;
                        TreeGraph bn = new TreeGraph("child_meta", reference);
                        bn.SetProperty("extent", branch.GetChildLeafElementCount(i));
                        node.AddChild(bn);
                        node.AddChild(CreateDiagnosticRootGraph(new_left_key, child_ref));
                    }
                }
            } else {
                throw new IOException("Unknown node class: " + tree_node);
            }

            return node;
        }
Пример #33
0
 public TreeGraphRender( TreeGraph tree )
 {
     Control = tree ;
     //LineColorHtml = tree.LineColorHtml ;
     LineColorHtml = System.Drawing.ColorTranslator.ToHtml( tree.LineColor ) ;
 }