Пример #1
0
        public DecompressedBlock( CompressedBlock block )
        {
            root = new Node( false );
            idTable = new ushort[IDTABLE_SIZE];
            idCount = 0;

            DecodeFrom( block );
        }
Пример #2
0
        public void CreateLeaves()
        {
            BecomeBranch();

            children[0] = new Node( true, level-1 );
            children[1] = new Node( true, level-1 );
            children[2] = new Node( true, level-1 );
            children[3] = new Node( true, level-1 );
        }
Пример #3
0
        public void CreateBranches()
        {
            BecomeBranch();

            children[0] = new Node( false, level-1 );
            children[1] = new Node( false, level-1 );
            children[2] = new Node( false, level-1 );
            children[3] = new Node( false, level-1 );
        }
Пример #4
0
 public DecompressedBlock()
 {
     root = new Node( false );
     idTable = new ushort[IDTABLE_SIZE];
     idCount = 0;
 }
Пример #5
0
        private void WalkTreeTopLeft( Node node, Walker walker, int x, int y )
        {
            if ( node == null ) return;
            int size = ((1 << node.Level) >> 1);

            if ( node.Flag && node.Level >= 1 ) {
                WalkTreeTopLeft( node.TopLeftChild, walker, x, y );
            }
            else {
                walker( node, x, y );
            }
        }
Пример #6
0
        private void WalkTreeFull( Node node, Walker walker, int x, int y )
        {
            if ( node == null ) return;
            int size = ((1 << node.Level) >> 1);

            if ( node.Flag && node.Level >= 1 ) {
                WalkTreeFull( node.BottomRightChild, walker, x+size, y+size );
                WalkTreeFull( node.BottomLeftChild, walker, x, y+size );
                WalkTreeFull( node.TopRightChild, walker, x+size, y );
                WalkTreeFull( node.TopLeftChild, walker, x, y );
            }
            else {
                walker( node, x, y );
            }
        }
Пример #7
0
        private void PopulateTree( Node currentNode, PopulatorState state )
        {
            if ( currentNode == null ) return;

            if ( !currentNode.IsLeaf() ) {
                // Walk over the tree in a breath-first manner
                PopulateTree( currentNode.BottomRightChild, state );
                PopulateTree( currentNode.BottomLeftChild, state );
                PopulateTree( currentNode.TopRightChild, state );
                PopulateTree( currentNode.TopLeftChild, state );
            }
            else {
                currentNode.Owner = state.CurrentOwner;
                currentNode.Color = state.CurrentColor;
                state.NextLeaf();
            }
        }
Пример #8
0
        private void BuildTree( Node currentNode, DecompressorState state, int level )
        {
            bool flag = state.Flag;
            state.NextNode();

            currentNode.Level = level;
            currentNode.Flag = flag;
            if ( flag && level > 1 ) {
                currentNode.CreateBranches( );

                BuildTree( currentNode.BottomRightChild, state, level-1 );
                BuildTree( currentNode.BottomLeftChild, state, level-1 );
                BuildTree( currentNode.TopRightChild, state, level-1 );
                BuildTree( currentNode.TopLeftChild, state, level-1 );
            }
            else {
                if ( flag ) {
                    currentNode.CreateLeaves();
                    state.AddLeaves( );
                }
                else {
                    currentNode.BecomeLeaf();
                    state.AddLeaf( );
                }
            }
        }