예제 #1
0
        protected TreeNode BuildTree(TreeNode[][] nodesToJoin, int height, int width)
        {
            if (height > 1 && width > 1)
            {
                TreeNode[][] nextLayer = new TreeNode[(width + 1) / 2][];

                for (int i = 0; i < (width + 1) / 2; ++i)
                {
                    nextLayer[i] = new TreeNode[(height + 1) / 2];
                    for (int j = 0; j < (height + 1) / 2; ++j)
                    {
                        nextLayer[i][j] = new TreeNode();
                    }
                }

                for (int x = 0; x < nodesToJoin.Count(); ++x)
                {
                    for (int y = 0; y < nodesToJoin[x].Count(); ++y)
                    {
                        nextLayer[x / 2][y / 2].AddChild(nodesToJoin[x][y]);
                    }
                }

                return BuildTree(nextLayer, (height + 1) / 2, (width + 1) / 2);
            }
            else
            {
                return nodesToJoin[0][0];
            }
        }
예제 #2
0
 public virtual void AddChild(TreeNode childNode)
 {
     childNode.ParentNode = this;
     m_children.Add(childNode);
 }
예제 #3
0
        protected void PopulateRegion()
        {
            var regions = ConstructRegions();
            m_root = BuildTree(regions, regions[0].Count(), regions.Count());

            FillRegions(regions);
        }